Skip to content

Commit 0a45c32

Browse files
authored
fix: Case issue with pod State (#386) (#387)
1 parent bc89b11 commit 0a45c32

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

internal/controller/pod_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (r *podDeleteController) Reconcile(ctx context.Context, req ctrl.Request) (
230230
}
231231

232232
// handlePodChanged Deletes pods that meet the following criteria:
233-
// 1. The pod is in Error or CrashLoopBackoff state.
233+
// 1. The pod is in Error or CrashLoopBackOff state.
234234
// 2. The pod matches one or more AuthProxyWorkload resources.
235235
// 3. The pod is missing one or more proxy sidecar containers for the resources.
236236
func (r *podDeleteController) handlePodChanged(ctx context.Context, pod *corev1.Pod) error {

internal/controller/pod_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func TestPodDeleteController(t *testing.T) {
247247
if tc.setPodError {
248248
pods[0].Status.ContainerStatuses = []corev1.ContainerStatus{{
249249
Name: pods[0].Spec.Containers[0].Name,
250-
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackoff"}},
250+
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackOff"}},
251251
}}
252252
}
253253

internal/workload/podspec_updates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ func (u *Updater) CheckWorkloadContainers(wl *PodWorkload, matches []*cloudsqlap
242242
if cs.State.Terminated != nil && cs.State.Terminated.Reason == "Error" {
243243
return fmt.Errorf("pod is in an error state and missing sidecar containers %v", missingSidecars)
244244
}
245-
if cs.State.Waiting != nil && cs.State.Waiting.Reason == "CrashLoopBackoff" {
246-
return fmt.Errorf("pod is in a CrashLoopBackoff state and missing sidecar containers %v", missingSidecars)
245+
if cs.State.Waiting != nil && cs.State.Waiting.Reason == "CrashLoopBackOff" {
246+
return fmt.Errorf("pod is in a CrashLoopBackOff state and missing sidecar containers %v", missingSidecars)
247247
}
248248
}
249249

internal/workload/podspec_updates_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ func TestUpdater_CheckWorkloadContainers(t *testing.T) {
10581058
}
10591059
wlCfgWait.Pod.Status.ContainerStatuses = []corev1.ContainerStatus{{
10601060
Name: wlCfgWait.Pod.Spec.Containers[0].Name,
1061-
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackoff"}},
1061+
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackOff"}},
10621062
}}
10631063

10641064
// Pod configuration says it is running and is missing its proxy containers
@@ -1079,7 +1079,7 @@ func TestUpdater_CheckWorkloadContainers(t *testing.T) {
10791079
wlCfgMissingWait := podWorkload()
10801080
wlCfgMissingWait.Pod.Status.ContainerStatuses = []corev1.ContainerStatus{{
10811081
Name: wlCfgMissingWait.Pod.Spec.Containers[0].Name,
1082-
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackoff"}},
1082+
State: corev1.ContainerState{Waiting: &corev1.ContainerStateWaiting{Reason: "CrashLoopBackOff"}},
10831083
}}
10841084

10851085
// Pod configuration says it is in error and is missing one of the 2 sidecar

0 commit comments

Comments
 (0)