Skip to content

Commit cab0928

Browse files
committed
update check and tests
1 parent 090c74f commit cab0928

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

pkg/controllers/work/apply_controller.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,8 @@ func trackPDBAvailability(curObj *unstructured.Unstructured) (ApplyAction, error
475475
}
476476
// Check if conditions are up-to-date
477477
if poddisruptionbudget.ConditionsAreUpToDate(&pdb) {
478-
if cond := meta.FindStatusCondition(pdb.Status.Conditions, policyv1.DisruptionAllowedCondition); cond != nil {
479-
if cond.Status == metav1.ConditionTrue && cond.Reason == policyv1.SufficientPodsReason {
480-
klog.V(2).InfoS("PodDisruptionBudget is available", "pdb", klog.KObj(curObj))
481-
return manifestAvailableAction, nil
482-
}
483-
}
478+
klog.V(2).InfoS("PodDisruptionBudget is available", "pdb", klog.KObj(curObj))
479+
return manifestAvailableAction, nil
484480
}
485481
klog.V(2).InfoS("Still need to wait for PodDisruptionBudget to be available", "pdb", klog.KObj(curObj))
486482
return manifestNotAvailableYetAction, nil

pkg/controllers/work/apply_controller_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ func TestTrackResourceAvailability(t *testing.T) {
14201420
expected: manifestNotAvailableYetAction,
14211421
err: nil,
14221422
},
1423-
"Test PodDisruptionBudget available": {
1423+
"Test PodDisruptionBudget available (sufficient pods)": {
14241424
gvr: utils.PodDisruptionBudgetGVR,
14251425
obj: &unstructured.Unstructured{
14261426
Object: map[string]interface{}{
@@ -1487,7 +1487,7 @@ func TestTrackResourceAvailability(t *testing.T) {
14871487
expected: manifestNotAvailableYetAction,
14881488
err: nil,
14891489
},
1490-
"Test PodDisruptionBudget unavailable": {
1490+
"Test PodDisruptionBudget available (insufficient pods)": {
14911491
gvr: utils.PodDisruptionBudgetGVR,
14921492
obj: &unstructured.Unstructured{
14931493
Object: map[string]interface{}{
@@ -1502,22 +1502,23 @@ func TestTrackResourceAvailability(t *testing.T) {
15021502
"minAvailable": 1,
15031503
},
15041504
"status": map[string]interface{}{
1505-
"currentHealthy": 1,
1505+
"currentHealthy": 2,
15061506
"desiredHealthy": 1,
15071507
"observedGeneration": 2,
1508-
"disruptionsAllowed": 1,
1508+
"disruptionsAllowed": 0,
15091509
"expectedPods": 1,
15101510
"conditions": []interface{}{
15111511
map[string]interface{}{
1512-
"type": "DisruptionAllowed",
1513-
"status": "False",
1514-
"reason": "InsufficientPods",
1512+
"type": "DisruptionAllowed",
1513+
"status": "False",
1514+
"reason": "InsufficientPods",
1515+
"observedGeneration": 2,
15151516
},
15161517
},
15171518
},
15181519
},
15191520
},
1520-
expected: manifestNotAvailableYetAction,
1521+
expected: manifestAvailableAction,
15211522
err: nil,
15221523
},
15231524
}

0 commit comments

Comments
 (0)