You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add CancelHealthCheckOnNewRevision feature to avoid getting stuck on failing commits
This feature allows health checks to be cancelled when a new source revision
becomes available, preventing the controller from getting stuck waiting for
full timeout durations when fixes are already available.
Features:
- New opt-in feature flag: CancelHealthCheckOnNewRevision (default: false)
- Health checks are cancelled early when new revisions are detected (~5s vs 5min timeout)
- Uses the new WaitForSetWithContext method for clean context-based cancellation
- Preserves existing behavior when feature is disabled
The implementation monitors source revisions during health checks and cancels
ongoing checks when new revisions are available, allowing immediate processing
of potential fixes instead of waiting for full timeout periods.
Signed-off-by: Stephen Solka <[email protected]>
The kustomize-controller fails to reconcile new revisions after a health check failure due to incorrect revision detection logic in `kustomization_indexers.go:62`.
5
+
6
+
## Test Added
7
+
Added test case `reconciles new revision after health check failure` to `kustomization_wait_test.go` (lines 449-545).
8
+
9
+
## The Fix
10
+
In `internal/controller/kustomization_indexers.go:62`, change:
11
+
```diff
12
+
- if conditions.IsReady(&list.Items[i]) && repo.GetArtifact().HasRevision(d.Status.LastAttemptedRevision) {
13
+
+ if conditions.IsReady(&list.Items[i]) && repo.GetArtifact().HasRevision(d.Status.LastAppliedRevision) {
14
+
```
15
+
16
+
## Test Scenario
17
+
1. Deploy a Kustomization with a bad image that fails health checks
18
+
2. Verify it becomes NOT Ready with LastAttemptedRevision = bad revision
19
+
3. Update GitRepository with fixed manifest (good image)
20
+
4. Verify Kustomization reconciles the new revision and becomes Ready
21
+
22
+
## Expected Behavior
23
+
- Test should FAIL with current code (Kustomization stays stuck on bad revision)
24
+
- Test should PASS after applying the fix (Kustomization reconciles new revision)
25
+
26
+
## To Run Test
27
+
```bash
28
+
# Install kubebuilder first if needed
29
+
make test
30
+
31
+
# Or run specific test once environment is set up
32
+
go test -v ./internal/controller -run "TestKustomizationReconciler_WaitConditions/reconciles_new_revision_after_health_check_failure"
0 commit comments