-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
refactor: change the logic of delete pod during retry. Fixes: #12538 #12734
base: main
Are you sure you want to change the base?
Changes from all commits
38c00db
d08d334
0d93cb6
65d25e2
a196700
33a6f61
ba01622
8feee6d
4cb1f83
7d53e33
7b0dc53
8fbb3bf
ad4d350
9da1c5b
9b01549
2dfee1b
d6ac764
d01bb65
51bfa7f
8950a75
9a27062
cf4b6cb
e588918
14c06b6
d7ae0ae
cc04729
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 |
---|---|---|
|
@@ -28,7 +28,6 @@ rules: | |
- get | ||
- list | ||
- watch | ||
- delete | ||
- apiGroups: | ||
- "" | ||
resources: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ rules: | |
- get | ||
- list | ||
- watch | ||
- delete | ||
- apiGroups: | ||
- "" | ||
resources: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: retry-parameters- | ||
spec: | ||
entrypoint: main | ||
arguments: | ||
parameters: | ||
- name: message1 | ||
value: "hello" | ||
- name: message2 | ||
value: "world" | ||
templates: | ||
- name: main | ||
container: | ||
image: argoproj/argosay:v2 | ||
command: [sh, -c] | ||
args: ["echo {{workflow.parameters.message1}} {{workflow.parameters.message2}}; exit 1"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -590,6 +590,13 @@ func (wfc *WorkflowController) processNextPodCleanupItem(ctx context.Context) bo | |
if err != nil && !apierr.IsNotFound(err) { | ||
return err | ||
} | ||
case labelBatchDeletePodsCompleted: | ||
// When running here, means that all pods that need to be deleted for the retry operation have been completed. | ||
workflowName := podName | ||
err := wfc.labelWorkflowRetried(ctx, namespace, workflowName) | ||
if err != nil { | ||
return err | ||
} | ||
Comment on lines
+593
to
+599
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. I think there's a problem here, We may end up in a situation where a retry workflow starts but still having pods that's yet to be cleaned up |
||
} | ||
return nil | ||
}() | ||
|
@@ -602,6 +609,37 @@ func (wfc *WorkflowController) processNextPodCleanupItem(ctx context.Context) bo | |
return true | ||
} | ||
|
||
func (wfc *WorkflowController) labelWorkflowRetried(ctx context.Context, namespace string, workflowName string) error { | ||
err := retry.RetryOnConflict(retry.DefaultRetry, func() error { | ||
err := wfc.patchWorkflowLabels(ctx, namespace, workflowName, map[string]string{ | ||
common.LabelKeyWorkflowRetryingStatus: "Retried", | ||
}) | ||
return err | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (wfc *WorkflowController) patchWorkflowLabels(ctx context.Context, namespace string, workflowName string, labels map[string]string) error { | ||
data, err := json.Marshal(&wfv1.WorkflowTaskResult{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: labels, | ||
}, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = wfc.wfclientset.ArgoprojV1alpha1().Workflows(namespace).Patch(ctx, | ||
workflowName, | ||
types.MergePatchType, | ||
data, | ||
metav1.PatchOptions{}, | ||
) | ||
return err | ||
} | ||
|
||
func (wfc *WorkflowController) getPodFromAPI(ctx context.Context, namespace string, podName string) (*apiv1.Pod, error) { | ||
pod, err := wfc.kubeclientset.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{}) | ||
if err != 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.
what would be the potential issue without wait here