-
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
WIP:feat(backend): Add Semaphore and Mutex fields to Workflow CR #11370
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -77,9 +77,20 @@ | |
} | ||
} | ||
|
||
var pipeline_options argocompiler.Options | ||
for _, platform := range t.platformSpec.Platforms { | ||
if platform.PipelineConfig.SemaphoreKey != "" || platform.PipelineConfig.MutexName != "" { | ||
Check failure on line 82 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
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.
|
||
pipeline_options = argocompiler.Options{ | ||
SemaphoreKey: platform.PipelineConfig.SemaphoreKey, | ||
Check failure on line 84 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
MutexName: platform.PipelineConfig.MutexName, | ||
Check failure on line 85 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
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. Let's add these individually, and only if they are specified in the IR. Users will typically only add one or the other. (So don't add mutex if the user only wants a semaphore, and vice versa.) |
||
} | ||
break | ||
} | ||
} | ||
|
||
var obj interface{} | ||
if util.CurrentExecutionType() == util.ArgoWorkflow { | ||
obj, err = argocompiler.Compile(job, kubernetesSpec, nil) | ||
obj, err = argocompiler.Compile(job, kubernetesSpec, &pipeline_options) | ||
} else if util.CurrentExecutionType() == util.TektonPipelineRun { | ||
obj, err = tektoncompiler.Compile(job, kubernetesSpec, &tektoncompiler.Options{LauncherImage: Launcher}) | ||
} | ||
|
@@ -300,9 +311,20 @@ | |
} | ||
} | ||
|
||
var pipeline_options *argocompiler.Options | ||
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. this looks copied from above. Is there any way to reuse it? |
||
for _, platform := range t.platformSpec.Platforms { | ||
if platform.PipelineConfig.SemaphoreKey != "" || platform.PipelineConfig.MutexName != "" { | ||
Check failure on line 316 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
pipeline_options = &argocompiler.Options{ | ||
SemaphoreKey: platform.PipelineConfig.SemaphoreKey, | ||
Check failure on line 318 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
MutexName: platform.PipelineConfig.MutexName, | ||
Check failure on line 319 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
} | ||
break | ||
} | ||
} | ||
|
||
var obj interface{} | ||
if util.CurrentExecutionType() == util.ArgoWorkflow { | ||
obj, err = argocompiler.Compile(job, kubernetesSpec, nil) | ||
obj, err = argocompiler.Compile(job, kubernetesSpec, pipeline_options) | ||
} else if util.CurrentExecutionType() == util.TektonPipelineRun { | ||
obj, err = tektoncompiler.Compile(job, kubernetesSpec, nil) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"google.golang.org/protobuf/proto" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
k8score "k8s.io/api/core/v1" | ||
v1 "k8s.io/api/core/v1" | ||
k8sres "k8s.io/apimachinery/pkg/api/resource" | ||
k8smeta "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
@@ -40,6 +41,8 @@ type Options struct { | |
// optional | ||
PipelineRoot string | ||
// TODO(Bobgy): add an option -- dev mode, ImagePullPolicy should only be Always in dev mode. | ||
SemaphoreKey string | ||
MutexName string | ||
} | ||
|
||
func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.SinglePlatformSpec, opts *Options) (*wfapi.Workflow, error) { | ||
|
@@ -76,6 +79,14 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S | |
} | ||
} | ||
|
||
var semaphore_key, mutex_name string | ||
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. camel case -- we're not in python :) |
||
if opts != nil && opts.SemaphoreKey != "" { | ||
semaphore_key = opts.SemaphoreKey | ||
} | ||
if opts != nil && opts.MutexName != "" { | ||
mutex_name = opts.MutexName | ||
} | ||
|
||
var kubernetesSpec *pipelinespec.SinglePlatformSpec | ||
if kubernetesSpecArg != nil { | ||
// clone kubernetesSpecArg, because we don't want to change it | ||
|
@@ -94,13 +105,9 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S | |
}, | ||
ObjectMeta: k8smeta.ObjectMeta{ | ||
GenerateName: retrieveLastValidString(spec.GetPipelineInfo().GetName()) + "-", | ||
// Note, uncomment the following during development to view argo inputs/outputs in KFP UI. | ||
// TODO(Bobgy): figure out what annotations we should use for v2 engine. | ||
// For now, comment this annotation, so that in KFP UI, it shows argo input/output params/artifacts | ||
// suitable for debugging. | ||
// | ||
// Uncomment during development for better debugging in KFP UI | ||
// Annotations: map[string]string{ | ||
// "pipelines.kubeflow.org/v2_pipeline": "true", | ||
// "pipelines.kubeflow.org/v2_pipeline": "true", | ||
// }, | ||
}, | ||
Spec: wfapi.WorkflowSpec{ | ||
|
@@ -117,8 +124,22 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S | |
}, | ||
ServiceAccountName: "pipeline-runner", | ||
Entrypoint: tmplEntrypoint, | ||
Synchronization: &wfapi.Synchronization{ | ||
Semaphore: &wfapi.SemaphoreRef{ | ||
ConfigMapKeyRef: &v1.ConfigMapKeySelector{ | ||
LocalObjectReference: v1.LocalObjectReference{ | ||
Name: "semaphore-config", | ||
}, | ||
Key: semaphore_key, | ||
}, | ||
}, | ||
Mutex: &wfapi.Mutex{ | ||
Name: mutex_name, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
c := &workflowCompiler{ | ||
wf: wf, | ||
templates: make(map[string]*wfapi.Template), | ||
|
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.