Commit 29da915
fix: wait for CR finalizers before deleting operators
Addresses Code Rabbit review: the script was deleting operators
immediately after requesting CR deletion, which could interrupt
finalizer processing if the deletion was still in progress.
Changes:
- Add polling loop after CR deletion to wait for finalizers to complete
- Check every 2 seconds for up to 60 seconds that all CRs are gone
- Only proceed to delete Subscriptions/CSVs after CRs are confirmed deleted
- Warn if CRs are still stuck after timeout (indicates stuck finalizers)
- Use wc -l with arithmetic to count CRs (avoids grep -vc || echo issues)
- Properly handle empty output (0 lines = 0 CRs)
This ensures operators have time to properly clean up Deployments,
ReplicaSets, and Pods before we remove the operators themselves,
preventing orphaned resources.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 1ae57fc commit 29da915
1 file changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
131 | 150 | | |
132 | 151 | | |
133 | 152 | | |
| |||
0 commit comments