Skip to content

Commit 55451ec

Browse files
fix: opj should failed if ops not found pod (#308)
* ops-not-found-pod * 优化e2e * 优化ut * 优化ut * 优化ut
1 parent 6b9b766 commit 55451ec

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

pkg/controllers/collaset/collaset_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var _ = Describe("collaset controller", func() {
119119
return len(podList.Items) == 1
120120
}, 5*time.Second, 1*time.Second).Should(BeTrue())
121121
Expect(c.Get(context.TODO(), types.NamespacedName{Namespace: cs.Namespace, Name: cs.Name}, cs)).Should(BeNil())
122-
Expect(expectedStatusReplicas(c, cs, 0, 0, 0, 1, 1, 0, 0, 0)).Should(BeNil())
122+
Eventually(func() error { return expectedStatusReplicas(c, cs, 0, 0, 0, 1, 1, 0, 0, 0) }, 5*time.Second, 1*time.Second).Should(BeNil())
123123

124124
// label pod to trigger replace
125125
originPod := podList.Items[0]

pkg/controllers/operationjob/operationjob_manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ func (r *ReconcileOperationJob) filterAndOperateAllowOpsTargets(
118118
}
119119

120120
if enablePodOpsLifecycle && candidate.Pod == nil {
121+
MarkCandidateFailed(candidate)
122+
ojutils.SetOpsStatusError(candidate, appsv1alpha1.ReasonPodNotFound, "failed to operate a non-exist pod")
121123
return nil
122124
}
123125

test/e2e/apps/collaset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ var _ = SIGDescribe("CollaSet", func() {
10581058
return true
10591059
}
10601060
return false
1061-
}, 12*time.Second, time.Second).Should(BeTrue())
1061+
}, 12*time.Second, time.Microsecond).Should(BeTrue())
10621062
Expect(duration > time.Duration(*cls.Spec.UpdateStrategy.OperationDelaySeconds)*time.Second-4).Should(BeTrue())
10631063

10641064
By("Wait for update finished")

0 commit comments

Comments
 (0)