-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support archiving/unarchiving runs on the backend #552
Conversation
@@ -31,7 +31,7 @@ import ( | |||
scheduledworkflow "github.com/kubeflow/pipelines/backend/src/crd/pkg/apis/scheduledworkflow/v1alpha1" | |||
scheduledworkflowclient "github.com/kubeflow/pipelines/backend/src/crd/pkg/client/clientset/versioned/typed/scheduledworkflow/v1alpha1" | |||
"github.com/pkg/errors" | |||
"k8s.io/apimachinery/pkg/apis/meta/v1" | |||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can remove explicit name since it's the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vscode keeps adding it back with autoformat. I can remove it, but no guarantees it won't pop back up in the future haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, no feel free to keep it as is, not a big deal
backend/src/apiserver/model/run.go
Outdated
@@ -18,6 +18,7 @@ type Run struct { | |||
UUID string `gorm:"column:UUID; not null; primary_key"` | |||
DisplayName string `gorm:"column:DisplayName; not null;"` /* The name that user provides. Can contain special characters*/ | |||
Name string `gorm:"column:Name; not null;"` /* The name of the K8s resource. Follow regex '[a-z0-9]([-a-z0-9]*[a-z0-9])?'*/ | |||
StorageState string `gorm:"column:StorageState;"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should StorageState have a default value? Maybe we can also add not null, and enforce that all runs are in a valid state (archived or available).
Can we add a test to the CreateRun call to ensure that the state is valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, done.
Didn't add a new test, just a field to the expected object in old tests, since it's required now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this was done in the insertion code path here. Let me know if you think there's a better way. @IronPan @neuromage.
@@ -238,12 +260,16 @@ func parseResourceReferences(resourceRefString sql.NullString) ([]*model.Resourc | |||
} | |||
|
|||
func (s *RunStore) CreateRun(r *model.RunDetail) (*model.RunDetail, error) { | |||
if r.StorageState == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would default to AVAILABLE if r.StorageState was empty or in state UNKNOWN. If it's specified as one of AVAILABLE or ARCHIVED, I would keep it as is, and if it's neither one of those options, I would return an error.
Something like:
switch r.StorageState {
case "", api.Run_STORAGE_STATE_UNKNOWN.String():
r.StorageState = ...AVAILABLE
case api.Run_STORAGESTATE_ARCHIVED.String(), api.Run_STORAGESTATE_AVAILABLE:
break;
default:
return nil, fmt.Errorf("unknown storage state specified: %q", r.StorageState)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this would put the burden on clients to fill in a value for that field. I think this isn't something clients should be forced to do, this is why I also removed the UNSPECIFIED enum option.
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sync'ed offline. Added some validation around this, PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
@@ -262,7 +262,11 @@ func parseResourceReferences(resourceRefString sql.NullString) ([]*model.Resourc | |||
func (s *RunStore) CreateRun(r *model.RunDetail) (*model.RunDetail, error) { | |||
if r.StorageState == "" { | |||
r.StorageState = api.Run_STORAGESTATE_AVAILABLE.String() | |||
} else if r.StorageState != api.Run_STORAGESTATE_AVAILABLE.String() && | |||
r.StorageState != api.Run_STORAGESTATE_ARCHIVED.String() { | |||
return nil, util.NewInvalidInputError("Invalid value for StorageState field: %s.", r.StorageState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: %q will quote the invalid storage set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tip, done.
/lgtm |
/test kubeflow-pipeline-e2e-test |
cc7ef20
to
78ce694
Compare
78ce694
to
ec339c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Reviewed 18 of 18 files at r1, 9 of 9 files at r2, 2 of 2 files at r3, 2 of 2 files at r4, 11 of 11 files at r5.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @yebrahim, @IronPan, and @vicaire)
backend/src/common/client/api_server/run_client.go, line 155 at r5 (raw file):
return util.NewUserError(err, fmt.Sprintf("Failed to archive runs. Params: '%+v'", parameters),
nit: failed to 'unarchive runs'. Do we need the second error too? Seems to be saying the same thing.
backend/src/common/client/api_server/run_client.go, line 155 at r5 (raw file): Previously, neuromage (Ajay Gopinathan) wrote…
One is internal and the other external, so they can have the same message. |
/test kubeflow-pipeline-e2e-test |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: IronPan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: IronPan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Part of #247.
This PR adds two new endpoints to archive and unarchive runs. The proto field is an enum to make this easier to extend in the future.
/assign @IronPan
/assign @neuromage
This change is