Skip to content
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

fix: persist workspace id/name & experiment id for historic allocations [DET-10378] #9550

Merged
merged 11 commits into from
Jun 26, 2024

Conversation

corban-beaird
Copy link
Contributor

@corban-beaird corban-beaird commented Jun 20, 2024

Ticket

DET-10378

Description

Creates allocation_workspace_information table, responsible for persisting workspace id/name & experiment id for historic allocation reports. Adds new entries on successful creation of allocation for trials & NTSC tasks.

Backfills table using existing process used to retrieve workspace & experiment information for the historic allocation CSV endpoints.

Modifies logic for historic allocation report to leverage allocation_workspace_information instead of resolving based on current state.

Modifies existing e2e test to confirm workspace name is consistent when experiments are moved & deleted.

Test Plan

  • e2e test passes

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

Copy link

netlify bot commented Jun 20, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 1fe4274
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/667b5ba347e9ff00083ada72

Copy link
Contributor

@eecsliu eecsliu left a comment

Choose a reason for hiding this comment

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

It looks mostly good, though I have some slight concerns about how it behaves in the event insertion into allocation_workspace_info fails but allocation starts.

master/internal/command/command.go Outdated Show resolved Hide resolved
@@ -459,38 +459,13 @@ func (m *Master) getResourceAllocations(c echo.Context) error {
Where("ts.event_type = 'IMAGEPULL'").
Group("a.allocation_id")

taskWorkspaceIDs := db.Bun().NewSelect().
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just
chef_kiss

Love to see this removed

-- Populate the new table with existing data based on the previous method of resolving the workspace info & experiment_id
insert into allocation_workspace_info (allocation_id, workspace_id, workspace_name, experiment_id)
select
allocation_workspace.allocation_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: de-indent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I also de-indent all the above select columns as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda like the indentation for clarity, but I will make sure that I'm consistent with my case (insert into & select should be caps)

master/internal/trial.go Outdated Show resolved Hide resolved
master/internal/trial.go Outdated Show resolved Hide resolved
@corban-beaird corban-beaird added the to-cherry-pick Pull requests that need to be cherry-picked into the current release label Jun 24, 2024
@corban-beaird corban-beaird force-pushed the corban/historic-alloc-workspace-info branch from c205145 to 2cd5f4b Compare June 24, 2024 21:18
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 67.21311% with 20 lines in your changes missing coverage. Please review.

Project coverage is 49.82%. Comparing base (2331e5b) to head (1fe4274).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9550      +/-   ##
==========================================
- Coverage   52.20%   49.82%   -2.39%     
==========================================
  Files         753     1247     +494     
  Lines      112452   162278   +49826     
  Branches     2888     2888              
==========================================
+ Hits        58711    80847   +22136     
- Misses      53569    81259   +27690     
  Partials      172      172              
Flag Coverage Δ
backend 43.94% <67.21%> (+9.73%) ⬆️
harness 63.74% <ø> (ø)
web 46.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
master/pkg/model/task.go 15.26% <ø> (ø)
master/pkg/model/workspace.go 0.00% <ø> (ø)
master/internal/core.go 6.51% <0.00%> (ø)
master/internal/command/command.go 66.80% <63.63%> (ø)
master/internal/trial.go 41.86% <54.54%> (ø)
master/internal/task/postgres_allocations.go 53.84% <77.77%> (ø)

... and 489 files with indirect coverage changes

Copy link
Contributor

@carolinaecalderon carolinaecalderon left a comment

Choose a reason for hiding this comment

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

looks good, modulo a few nits & making sure CircleCI is green.
If more tests can't be added in this PR I do want to see this PR linked in a backlog ticket to write them

master/internal/command/command.go Outdated Show resolved Hide resolved
master/internal/task/postgres_allocations.go Show resolved Hide resolved
@corban-beaird corban-beaird force-pushed the corban/historic-alloc-workspace-info branch from f4e1272 to 9a06d53 Compare June 25, 2024 16:43
AllocationID AllocationID `db:"allocation_id" bun:"allocation_id,notnull"`
ExperimentID int `db:"experiment_id" bun:"experiment_id"`
WorkspaceID int `db:"workspace_id" bun:"workspace_id,notnull"`
WorkspaceName string `db:"workspace_name" bun:"workspace_name,notnull"`
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason why we need to persist workspace name separately? is it to avoid doing another join on the workspaces table?

if at the time of the allocation/persist, the workspace (let's say ID=1) had name "myworkspace", but when fetching historical records the workspace 1 had changed names to "neworkspacename", is expected behavior to show the old name or the latest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention here is to show the old name, this was primarily done to handle cases where the workspace had been deleted

@azhou-determined
Copy link
Contributor

do we have a sense of how long the migration will take? might be worth calling out in release notes.

Copy link
Contributor

@azhou-determined azhou-determined left a comment

Choose a reason for hiding this comment

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

few clarifying questions but otherwise lgtm

@corban-beaird
Copy link
Contributor Author

corban-beaird commented Jun 25, 2024

do we have a sense of how long the migration will take? might be worth calling out in release notes.

@azhou-determined
I had concern about the migration being pretty time intensive, but @eecsliu had ran the select query that populates the values for the insert that the migration does to backfill and it returned in around 500ms on Grenoble, so I'm under the impression it won't be to performance heavy.

@corban-beaird corban-beaird force-pushed the corban/historic-alloc-workspace-info branch from 0dd2204 to 96eb30e Compare June 25, 2024 20:59
Copy link
Contributor

@eecsliu eecsliu left a comment

Choose a reason for hiding this comment

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

looks good! Thanks for handling it :)

Copy link
Contributor

@gt2345 gt2345 left a comment

Choose a reason for hiding this comment

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

LGTM

alloc_experiments AS (
SELECT
allocations.allocation_id,
rtrim(substring(task_id, '\d+?\.'), '.')::int AS experiment_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically this can be any string, right? Should we have a fallback in case there is some "bad" data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! If there's not a match or if the string is null, this will return null

@corban-beaird corban-beaird merged commit fa1c1e1 into main Jun 26, 2024
82 of 98 checks passed
@corban-beaird corban-beaird deleted the corban/historic-alloc-workspace-info branch June 26, 2024 01:06
github-actions bot pushed a commit that referenced this pull request Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed to-cherry-pick Pull requests that need to be cherry-picked into the current release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants