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

fix(controller): shutdownstrategy on running workflow #5289

Merged
merged 12 commits into from
Mar 6, 2021

Conversation

sarabala1979
Copy link
Member

Signed-off-by: Saravanan Balasubramanian sarabala1979@gmail.com
fixes #5288
Checklist:

Signed-off-by: Saravanan Balasubramanian <sarabala1979@gmail.com>
@sarabala1979 sarabala1979 linked an issue Mar 4, 2021 that may be closed by this pull request
@sarabala1979 sarabala1979 marked this pull request as ready for review March 4, 2021 20:59
@@ -27,7 +27,7 @@ func (woc *wfOperationCtx) applyExecutionControl(ctx context.Context, pod *apiv1
return nil
case apiv1.PodPending:
// Check if we are currently shutting down
if woc.execWf.Spec.Shutdown != "" {
if woc.wf.Spec.Shutdown != "" {
Copy link
Member

@terrytangyuan terrytangyuan Mar 5, 2021

Choose a reason for hiding this comment

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

This is really easy to make mistakes. I know that there are notes on the use of wf v.s. execWf but I wonder if we could refactor a bit to prevent the misuse of woc.execWf on Suspend and Shutdown.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Mainly Shutdown and Suspend can be changed during the runtime. The above fix is only for the WorkflowTemplateRef scenario rest of the scenario will work as expected.
Possible refactoring for prevent:

  1. Code can update Shutdown and Suspend on workflow.specandworkflow.status.storedWorkflowSpec`.
  2. Code needs to construct the execWf in each execution. This is a little bit costly operation on each execution.

I am thinking option 1, We just use execWf for all places. Let me talk to the team about what they think.

Copy link
Member Author

Choose a reason for hiding this comment

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

After given thought. if the user did patch through kubectl then option 1 won't work.

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

how come woc.wf and woc.execWf are not the same? this is very confusing

should we actually be using woc.wf.ExecSpec()

@alexec alexec changed the title fix: fix horner the shutdownstrategy on running workflow fix(controller): shutdownstrategy on running workflow Mar 5, 2021
@sarabala1979
Copy link
Member Author

how come woc.wf and woc.execWf are not the same? this is very confusing

should we actually be using woc.wf.ExecSpec()
woc.wf. and woc.execwf is same for normal workflow usecase. But in workflowtemplateRef scenario, execwf will be calculated the first time. and stored in storedWorkflowSpec. storedWorkflowSpec will be used for future execution. Suspend and Shutdown will be updated later point of runtime.

Another way to fix this issue is checking Suspend and Shutdown in workflow and recalculate the storedWorkflowSpec

@alexec
Copy link
Contributor

alexec commented Mar 5, 2021

I think if we create one func on woc, we can make sure that func is correct

workflow/controller/operator.go Outdated Show resolved Hide resolved
workflow/controller/exec_control.go Outdated Show resolved Hide resolved
// Only delete pods that are not part of an onExit handler if we are "Stopping" or all pods if we are "Terminating"
_, onExitPod := pod.Labels[common.LabelKeyOnExit]

if !woc.execWf.Spec.Shutdown.ShouldExecute(onExitPod) {
woc.log.Infof("Deleting Pending pod %s/%s as part of workflow shutdown with strategy: %s", pod.Namespace, pod.Name, woc.execWf.Spec.Shutdown)
if !woc.GetShutdownStrategy().ShouldExecute(onExitPod) {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor - could even be woc.ShouldExecute(...)

workflow/controller/operator.go Outdated Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
@sarabala1979 sarabala1979 merged commit a5d1acc into argoproj:master Mar 6, 2021
This was referenced Mar 8, 2021
@simster7 simster7 mentioned this pull request Apr 19, 2021
50 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shutdown strategy is not working 2.12.x onwards. Look into tests failing when using exec spec
3 participants