-
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
feat(backend): Add TTL Strategy in Workflow Spec for Post-Completion Cleanup #11352
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,19 @@ | |
} | ||
} | ||
|
||
var pipeline_options argocompiler.Options | ||
for _, platform := range t.platformSpec.Platforms { | ||
if platform.PipelineConfig.PipelineTtl != 0 { | ||
Check failure on line 82 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
pipeline_options = argocompiler.Options{ | ||
TtlSeconds: platform.PipelineConfig.PipelineTtl, | ||
Check failure on line 84 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) | ||
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. |
||
} else if util.CurrentExecutionType() == util.TektonPipelineRun { | ||
obj, err = tektoncompiler.Compile(job, kubernetesSpec, &tektoncompiler.Options{LauncherImage: Launcher}) | ||
} | ||
|
@@ -300,9 +310,19 @@ | |
} | ||
} | ||
|
||
var pipeline_options *argocompiler.Options | ||
for _, platform := range t.platformSpec.Platforms { | ||
if platform.PipelineConfig.PipelineTtl != 0 { | ||
Check failure on line 315 in backend/src/apiserver/template/v2_template.go GitHub Actions / backend-tests
|
||
pipeline_options = &argocompiler.Options{ | ||
TtlSeconds: platform.PipelineConfig.PipelineTtl, | ||
Check failure on line 317 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) | ||
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. |
||
} else if util.CurrentExecutionType() == util.TektonPipelineRun { | ||
obj, err = tektoncompiler.Compile(job, kubernetesSpec, nil) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,13 @@ type Options struct { | |
// optional | ||
PipelineRoot string | ||
// TODO(Bobgy): add an option -- dev mode, ImagePullPolicy should only be Always in dev mode. | ||
TtlSeconds int32 | ||
} | ||
|
||
const ( | ||
pipeline_default_ttlSeconds = int32(30) | ||
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 casing :) |
||
) | ||
|
||
func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.SinglePlatformSpec, opts *Options) (*wfapi.Workflow, error) { | ||
// clone jobArg, because we don't want to change it | ||
jobMsg := proto.Clone(jobArg) | ||
|
@@ -86,6 +91,11 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S | |
} | ||
} | ||
|
||
pipeline_ttlseconds := pipeline_default_ttlSeconds | ||
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 casing here too |
||
if &opts.TtlSeconds != nil { | ||
pipeline_ttlseconds = opts.TtlSeconds | ||
} | ||
|
||
// initialization | ||
wf := &wfapi.Workflow{ | ||
TypeMeta: k8smeta.TypeMeta{ | ||
|
@@ -117,6 +127,9 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S | |
}, | ||
ServiceAccountName: "pipeline-runner", | ||
Entrypoint: tmplEntrypoint, | ||
TTLStrategy: &wfapi.TTLStrategy{ | ||
SecondsAfterCompletion: &pipeline_ttlseconds, | ||
}, | ||
}, | ||
} | ||
c := &workflowCompiler{ | ||
|
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.
Camel casing required to stay consistent with golang variable definition standards -
PipelineOptions