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): set pod name version annotation when no lock #12965

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 11 additions & 15 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,15 @@ func (woc *wfOperationCtx) operate(ctx context.Context) {
return
}
woc.updated = wfUpdate
if !acquired {
if !woc.releaseLocksForPendingShuttingdownWfs(ctx) {
woc.log.Warn("Workflow processing has been postponed due to concurrency limit")
phase := woc.wf.Status.Phase
if phase == wfv1.WorkflowUnknown {
phase = wfv1.WorkflowPending
}
woc.markWorkflowPhase(ctx, phase, msg)
return
}
if !acquired && !woc.releaseLocksForPendingShuttingdownWfs(ctx) {
woc.log.Warn("Workflow processing has been postponed due to concurrency limit")
phase := woc.wf.Status.Phase
if phase == wfv1.WorkflowUnknown {
phase = wfv1.WorkflowPending
setWfPodNamesAnnotation(woc.wf)
Copy link
Contributor

Choose a reason for hiding this comment

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

hate to be picky but wondering if we could just set this in one place at the top of the function? like maybe logic like "if annotation isn't set, then set it". Is there any reason it should ever not be set? That would handle any future cases where we preemptively exit for whatever reason.

}
woc.markWorkflowPhase(ctx, phase, msg)
return
}
}

Expand Down Expand Up @@ -4055,16 +4054,13 @@ func (woc *wfOperationCtx) getServiceAccountTokenName(ctx context.Context, name
return secrets.TokenNameForServiceAccount(account), nil
}

// setWfPodNamesAnnotation sets an annotation on a workflow with the pod naming
// convention version
// setWfPodNamesAnnotation sets an annotation on a workflow with the pod naming convention version
func setWfPodNamesAnnotation(wf *wfv1.Workflow) {
podNameVersion := wfutil.GetPodNameVersion()

if wf.Annotations == nil {
wf.Annotations = map[string]string{}
}

wf.Annotations[common.AnnotationKeyPodNameVersion] = podNameVersion.String()
wf.Annotations[common.AnnotationKeyPodNameVersion] = wfutil.GetPodNameVersion().String()
}

// getChildNodeIdsAndLastRetriedNode returns child node ids and last retried node, which are marked as `NodeStatus.NodeFlag.Retried=true`.
Expand Down