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: Daemon step updated 'pod delete' while pod is running #8399

Merged
merged 6 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/e2e/functional/stop-terminate-daemon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: stop-terminate-daemon-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: Daemon
template: sleep
- - name: B
template: pass

- name: sleep
daemon: true
container:
image: argoproj/argosay:v1
command: [ sleep ]
args: [ "999" ]

- name: pass
container:
image: argoproj/argosay:v1
command: [ sleep ]
args: [ "999" ]
18 changes: 18 additions & 0 deletions test/e2e/signals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ func (s *SignalsSuite) TestStopBehavior() {
})
}

func (s *SignalsSuite) TestStopBehaviorWithDaemon() {
s.Given().
Workflow("@functional/stop-terminate-daemon.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToHaveRunningPod, kill2xDuration).
ShutdownWorkflow(wfv1.ShutdownStrategyStop).
WaitForWorkflow(kill2xDuration).
Then().
ExpectWorkflow(func(t *testing.T, m *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Contains(t, []wfv1.WorkflowPhase{wfv1.WorkflowFailed, wfv1.WorkflowError}, status.Phase)
nodeStatus := status.Nodes.FindByDisplayName("Daemon")
if assert.NotNil(t, nodeStatus) {
assert.Equal(t, wfv1.NodeSucceeded, nodeStatus.Phase)
}
})
}

func (s *SignalsSuite) TestTerminateBehavior() {
s.Given().
Workflow("@functional/stop-terminate.yaml").
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/pod_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (woc *wfOperationCtx) queuePodsForCleanup() {
for _, obj := range objs {
pod := obj.(*apiv1.Pod)
nodeID := woc.nodeID(pod)
if !woc.execWf.Status.Nodes[nodeID].Fulfilled() {
if !woc.execWf.Status.Nodes[nodeID].Phase.Fulfilled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

not just Completed()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fulfilled will take care skipped and Omitted nodes also. Fulfilled is right one

// Fulfilled returns whether a phase is fulfilled, i.e. it completed execution or was skipped or omitted
func (phase NodePhase) Fulfilled() bool {
	return phase.Completed() || phase == NodeSkipped || phase == NodeOmitted
}

Copy link
Contributor

Choose a reason for hiding this comment

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

strange they are inconsistent

continue
}
switch determinePodCleanupAction(selector, pod.Labels, strategy, workflowPhase, pod.Status.Phase) {
Expand Down