Skip to content

[usage] Add database functions for new usage control loop #12643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2022

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Sep 5, 2022

Description

This PR adds ways to retrieve and store records from d_b_usage as well as functions to retrieve workspace instances to consider in a control loop.

The anticipated control loop would work as follows:

  1. select drafts from d_b_usage
  2. select workspaces instances where stopping is in a given time range (passed to the control loop)
  3. select workspace instances where still running
  4. select workspace instances where workspaceInstanceId exists in drafts
  5. update usage for every instance that exists in drafts (might turn it into non-draft or not)
  6. insert usage for all other instances (with do-nothing policy on conflict)

We could potentially combine 2,3,4 in one query but we should also allow for only running Step 2) to seed the past without considering running instances.

Related Issue(s)

Fixes #

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@svenefftinge svenefftinge force-pushed the se/instances-to-reconcile branch from 4590a60 to f6d86c6 Compare September 5, 2022 06:59
@roboquat roboquat added size/XL and removed size/L labels Sep 5, 2022
@svenefftinge svenefftinge changed the title Se/instances-to-reconcile [usage] Add database functions for new usage control loop Sep 5, 2022
@svenefftinge svenefftinge force-pushed the se/instances-to-reconcile branch 2 times, most recently from 6381a8a to ab11df3 Compare September 5, 2022 07:46
@svenefftinge svenefftinge marked this pull request as ready for review September 5, 2022 07:53
@svenefftinge svenefftinge requested a review from a team September 5, 2022 07:53
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 5, 2022
@svenefftinge svenefftinge force-pushed the se/instances-to-reconcile branch from ab11df3 to 9ef1e18 Compare September 5, 2022 08:39
require.Equal(t, updatedDesc, drafts[0].Description)
}

func TestFindAllDraftUsage(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. We reviewed this together on a call.

/hold in case you want to make any last changes

@svenefftinge svenefftinge force-pushed the se/instances-to-reconcile branch from 9ef1e18 to 4bdf2c0 Compare September 5, 2022 09:11
@svenefftinge svenefftinge merged commit ba687e5 into main Sep 5, 2022
@svenefftinge svenefftinge deleted the se/instances-to-reconcile branch September 5, 2022 09:26
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants