-
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
Add pipeline version api methods #2338
Changes from 13 commits
087f2ab
3972ab9
e2c2def
b329fe0
a488eef
c97d39c
be61038
20de892
386e6af
cd8043d
380a302
546e9d3
22404e8
4802241
9408182
48f0697
9ed59b8
f83218f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import ( | |
|
||
const ( | ||
DefaultFakeUUID = "123e4567-e89b-12d3-a456-426655440000" | ||
fakeUUIDOne = "123e4567-e89b-12d3-a456-426655440001" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upper case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
) | ||
|
||
type FakeClientManager struct { | ||
|
@@ -45,7 +46,7 @@ type FakeClientManager struct { | |
} | ||
|
||
func NewFakeClientManager(time util.TimeInterface, uuid util.UUIDGeneratorInterface) ( | ||
*FakeClientManager, error) { | ||
*FakeClientManager, error) { | ||
|
||
if time == nil { | ||
glog.Fatalf("The time parameter must not be null.") // Must never happen | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -814,3 +814,101 @@ func (r *ResourceManager) MarkSampleLoaded() error { | |
func (r *ResourceManager) getDefaultSA() string { | ||
return common.GetStringConfigWithDefault(defaultPipelineRunnerServiceAccountEnvVar, defaultPipelineRunnerServiceAccount) | ||
} | ||
|
||
func (r *ResourceManager) CreatePipelineVersion(apiVersion *api.PipelineVersion, pipelineFile []byte) (*model.PipelineVersion, error) { | ||
// Extract the parameter from the pipeline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameter -> parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
params, err := util.GetParameters(pipelineFile) | ||
if err != nil { | ||
return nil, util.Wrap(err, "Create pipeline version failed") | ||
} | ||
|
||
// Extract pipeline id | ||
var pipelineId = "" | ||
for _, resourceReference := range apiVersion.ResourceReferences { | ||
if resourceReference.Key.Type == api.ResourceType_PIPELINE && | ||
resourceReference.Relationship == api.Relationship_OWNER { | ||
pipelineId = resourceReference.Key.Id | ||
} | ||
} | ||
if len(pipelineId) == 0 { | ||
return nil, util.Wrap( | ||
err, "Create pipeline version failed due to missing pipeline id") | ||
} | ||
|
||
// Construct model.PipelineVersion | ||
version := &model.PipelineVersion{ | ||
Name: apiVersion.Name, | ||
PipelineId: pipelineId, | ||
Status: model.PipelineVersionCreating, | ||
Parameters: params, | ||
CodeSourceUrl: apiVersion.CodeSourceUrl, | ||
} | ||
version, err = r.pipelineStore.CreatePipelineVersion(version) | ||
if err != nil { | ||
return nil, util.Wrap(err, "Create pipeline version failed") | ||
} | ||
|
||
// Store the pipeline file | ||
err = r.objectStore.AddFile( | ||
pipelineFile, storage.CreatePipelinePath(fmt.Sprint(version.UUID))) | ||
if err != nil { | ||
return nil, util.Wrap(err, "Create pipeline version failed") | ||
} | ||
|
||
// After pipeline version being created in DB and pipeline file being | ||
// saved in minio server, set this pieline version to status ready. | ||
version.Status = model.PipelineVersionReady | ||
err = r.pipelineStore.UpdatePipelineVersionStatus( | ||
version.UUID, version.Status) | ||
if err != nil { | ||
return nil, util.Wrap(err, "Create pipeline version failed") | ||
} | ||
|
||
return version, nil | ||
} | ||
|
||
func (r *ResourceManager) GetPipelineVersion(versionId string) (*model.PipelineVersion, error) { | ||
return r.pipelineStore.GetPipelineVersion(versionId) | ||
} | ||
|
||
func (r *ResourceManager) ListPipelineVersions(pipelineId string, opts *list.Options) (pipelines []*model.PipelineVersion, total_size int, nextPageToken string, err error) { | ||
return r.pipelineStore.ListPipelineVersions(pipelineId, opts) | ||
} | ||
|
||
func (r *ResourceManager) DeletePipelineVersion(pipelineVersionId string) error { | ||
_, err := r.pipelineStore.GetPipelineVersion(pipelineVersionId) | ||
if err != nil { | ||
return util.Wrap(err, "Delete pipeline version failed") | ||
} | ||
|
||
// Mark pipeline as deleting so it's not visible to user. | ||
err = r.pipelineStore.UpdatePipelineVersionStatus( | ||
pipelineVersionId, model.PipelineVersionDeleting) | ||
if err != nil { | ||
return util.Wrap(err, "Delete pipeline version failed") | ||
} | ||
|
||
err = r.objectStore.DeleteFile(storage.CreatePipelinePath( | ||
fmt.Sprint(pipelineVersionId))) | ||
if err != nil { | ||
glog.Errorf( | ||
"%v", | ||
errors.Wrapf( | ||
err, | ||
"Failed to delete pipeline file for pipeline version %v", | ||
pipelineVersionId)) | ||
return util.Wrap(err, "Delete pipeline version failed") | ||
} | ||
err = r.pipelineStore.DeletePipelineVersion(pipelineVersionId) | ||
if err != nil { | ||
glog.Errorf( | ||
"%v", | ||
errors.Wrapf( | ||
err, | ||
"Failed to delete pipeline DB entry for pipeline %v", | ||
pipelineVersionId)) | ||
return util.Wrap(err, "Delete pipeline version failed") | ||
} | ||
|
||
return nil | ||
} |
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.
this URL looks not right. as reference can u check URL to list run by experiment?
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.
changed api path
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.
Another related api path question. If we merge this PR, users can call api server to directly manipulate (create, delete, get, list) versions in spite that they can't do that from FE. Would that be ok, say, considered as a too-early or premature exposure?
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.
You could, in implementation, return not implemented.
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.
ah, I commented out the http point in pipeline.proto, so i can leave the method implementation in its expected final state. BTW, by doing the comment-out, the curl returns "not found".