Skip to content

Commit

Permalink
Refactor logic to exclude all Pod which are not in the phase "Running"
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Bornhold <[email protected]>
  • Loading branch information
johbo committed Jun 7, 2024
1 parent a7fb8f5 commit 7bae817
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions operator/backupcontroller/controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ func (ts *BackupTestSuite) Test_GivenBackupAndMountedRWOPVCOnOneNode_ExpectBacku

pvc1.Status.Phase = corev1.ClaimBound
pvc2.Status.Phase = corev1.ClaimBound
ts.UpdateStatus(pvc1, pvc2)
pod1.Status.Phase = corev1.PodRunning
pod2.Status.Phase = corev1.PodRunning
ts.UpdateStatus(pvc1, pvc2, pod1, pod2)

result := ts.whenReconciling(ts.BackupResource)
ts.Assert().GreaterOrEqual(result.RequeueAfter, 30*time.Second)
Expand Down Expand Up @@ -359,7 +361,9 @@ func (ts *BackupTestSuite) Test_GivenBackupAndMountedRWOPVCOnTwoNodes_ExpectBack

pvc1.Status.Phase = corev1.ClaimBound
pvc2.Status.Phase = corev1.ClaimBound
ts.UpdateStatus(pvc1, pvc2)
pod1.Status.Phase = corev1.PodRunning
pod2.Status.Phase = corev1.PodRunning
ts.UpdateStatus(pvc1, pvc2, pod1, pod2)

result := ts.whenReconciling(ts.BackupResource)
ts.Assert().GreaterOrEqual(result.RequeueAfter, 30*time.Second)
Expand Down Expand Up @@ -395,7 +399,9 @@ func (ts *BackupTestSuite) Test_GivenBackupAndMountedRWOPVCOnOneNodeWithFinished
ts.EnsureResources(ts.BackupResource, pvc1, pod1, pod2)

pvc1.Status.Phase = corev1.ClaimBound
ts.UpdateStatus(pvc1)
pod1.Status.Phase = corev1.PodRunning
pod2.Status.Phase = corev1.PodRunning
ts.UpdateStatus(pvc1, pod1, pod2)

result := ts.whenReconciling(ts.BackupResource)
ts.Assert().GreaterOrEqual(result.RequeueAfter, 30*time.Second)
Expand Down
4 changes: 2 additions & 2 deletions operator/backupcontroller/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func (b *BackupExecutor) listAndFilterPVCs(ctx context.Context, annotation strin
return nil, fmt.Errorf("list pods: %w", err)
}
for _, pod := range pods.Items {
if pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed {
log.V(1).Info("Ignoring terminated Pod", "pod", pod.GetName())
if pod.Status.Phase != corev1.PodRunning {
log.V(1).Info("Ignoring Pod which is not running", "pod", pod.GetName())
continue
}
for _, volume := range pod.Spec.Volumes {
Expand Down

0 comments on commit 7bae817

Please sign in to comment.