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

Support archiving/unarchiving runs on the backend #552

Merged
merged 16 commits into from
Dec 19, 2018

Conversation

yebrahim
Copy link
Contributor

@yebrahim yebrahim commented Dec 17, 2018

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 Reviewable

@@ -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"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

@@ -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;"`
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 == "" {
Copy link
Contributor

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)
}

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@neuromage neuromage left a 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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good tip, done.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Dec 18, 2018
@neuromage
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot removed the lgtm label Dec 19, 2018
@yebrahim
Copy link
Contributor Author

/test kubeflow-pipeline-e2e-test

Copy link
Contributor

@neuromage neuromage left a 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.

@yebrahim
Copy link
Contributor Author


backend/src/common/client/api_server/run_client.go, line 155 at r5 (raw file):

Previously, neuromage (Ajay Gopinathan) wrote…

nit: failed to 'unarchive runs'. Do we need the second error too? Seems to be saying the same thing.

One is internal and the other external, so they can have the same message.
Fixed the typo.

@yebrahim
Copy link
Contributor Author

/test kubeflow-pipeline-e2e-test

@k8s-ci-robot k8s-ci-robot removed the lgtm label Dec 19, 2018
@neuromage
Copy link
Contributor

/lgtm

Copy link
Member

@IronPan IronPan left a comment

Choose a reason for hiding this comment

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

/lgtm

@IronPan
Copy link
Member

IronPan commented Dec 19, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 549a366 into kubeflow:master Dec 19, 2018
@yebrahim yebrahim deleted the be-archive-bit branch December 19, 2018 22:09
magdalenakuhn17 pushed a commit to magdalenakuhn17/pipelines that referenced this pull request Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants