Skip to content

Commit

Permalink
Persists pause reason during eds status update
Browse files Browse the repository at this point in the history
  • Loading branch information
clamoriniere committed Jan 25, 2021
1 parent cb836bd commit 2b56fe4
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/extendeddaemonset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ const (
ExtendedDaemonSetStatusReasonPreStartHookError ExtendedDaemonSetStatusReason = "PreStartHookError"
// ExtendedDaemonSetStatusReasonPostStartHookError represent PostStartHookError as the reason for the ExtendedDaemonSet status state
ExtendedDaemonSetStatusReasonPostStartHookError ExtendedDaemonSetStatusReason = "PostStartHookError"
// ExtendedDaemonSetStatusReasonStartError represent StartError as the reason for the ExtendedDaemonSet status state
ExtendedDaemonSetStatusReasonStartError ExtendedDaemonSetStatusReason = "StartError"
// ExtendedDaemonSetStatusReasonUnknown represents an Unknown reason for the status state
ExtendedDaemonSetStatusReasonUnknown ExtendedDaemonSetStatusReason = "Unknown"
)
Expand Down
7 changes: 2 additions & 5 deletions controllers/extendeddaemonset_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ var _ = Describe("ExtendedDaemonSet e2e successful canary deployment update", fu
Name: eds.Status.ActiveReplicaSet,
}
Eventually(withERS(ersKey, ers, func() bool {
fmt.Fprintf(GinkgoWriter, "ERS status:\n%s\n", spew.Sdump(ers.Status))
return ers.Status.Status == "active" && int(ers.Status.Available) == len(nodeList.Items)
}), timeout, interval).Should(BeTrue())
})
Expand Down Expand Up @@ -538,7 +539,6 @@ var _ = Describe("ExtendedDaemonSet e2e successful canary deployment update", fu
if eds.Annotations == nil {
eds.Annotations = make(map[string]string)
}

eds.Annotations[datadoghqv1alpha1.ExtendedDaemonSetCanaryValidAnnotationKey] = canaryReplicaSet
eds.Spec.Template.Spec.Containers[0].Image = fmt.Sprintf("k8s.gcr.io/pause:3.1")
}
Expand All @@ -548,12 +548,9 @@ var _ = Describe("ExtendedDaemonSet e2e successful canary deployment update", fu
func() string { return "Unable to update the EDS" },
)

Expect(k8sClient.Get(ctx, key, eds)).Should(Succeed())
fmt.Fprintf(GinkgoWriter, "EDS status:\n%s\n", spew.Sdump(eds.Status))

Eventually(withEDS(key, eds, func() bool {
return eds.Status.ActiveReplicaSet == canaryReplicaSet
}), timeout, interval).Should(BeTrue())
}), timeout, interval).Should(BeTrue(), "eds status should be updated")

canaryPods := &corev1.PodList{}
listOptions := []client.ListOption{
Expand Down
2 changes: 1 addition & 1 deletion controllers/extendeddaemonsetreplicaset/strategy/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func manageCanaryPodFailures(pods []*v1.Pod, params *Parameters, result *Result,
// Unpausing is a manual action and takes precedence
result.IsPaused = false
result.PausedReason = ""
case !result.IsPaused && autoPauseEnabled:
case autoPauseEnabled:
// Handle cases related to failure to start states
if cannotStart {
result.IsPaused = true
Expand Down
1 change: 1 addition & 0 deletions examples/failure-cases/foo-eds_config_error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
maxRestartsDuration: 10m
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
1 change: 1 addition & 0 deletions examples/failure-cases/foo-eds_image_pull_error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
maxRestartsDuration: 10m
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
3 changes: 2 additions & 1 deletion examples/failure-cases/foo-eds_restarts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ spec:
maxRestarts: 2
autoFail:
enabled: true
maxRestarts: 10
maxRestarts: 5
maxRestartsDuration: 10m
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
maxRestartsDuration: 10m
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
1 change: 1 addition & 0 deletions examples/foo-eds_v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
enabled: false
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
1 change: 1 addition & 0 deletions examples/foo-eds_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ spec:
maxRestarts: 5
rollingUpdate:
maxParallelPodCreation: 1
maxUnavailable: 2
slowStartIntervalDuration: 1m
template:
spec:
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/utils/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func convertReasonToEDSStatusReason(reason string) datadoghqv1alpha1.ExtendedDae
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonCreateContainerConfigError,
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonCreateContainerError,
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonPreStartHookError,
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonPostStartHookError:
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonPostStartHookError,
datadoghqv1alpha1.ExtendedDaemonSetStatusReasonStartError:
return t
default:
return datadoghqv1alpha1.ExtendedDaemonSetStatusReasonUnknown
Expand Down

0 comments on commit 2b56fe4

Please sign in to comment.