|
| 1 | +# PR #2296 Summary: Fix Deprecation Conditions |
| 2 | + |
| 3 | +## Title Change |
| 4 | + |
| 5 | +**Before:** |
| 6 | +``` |
| 7 | +🐛 report Unknown for deprecation status when catalog unavailable and prevent error leak |
| 8 | +``` |
| 9 | + |
| 10 | +**After:** |
| 11 | +``` |
| 12 | +🐛 Fix deprecation conditions showing install errors and improve condition semantics |
| 13 | +``` |
| 14 | + |
| 15 | +## What This PR Fixes |
| 16 | + |
| 17 | +Fixes [issue #2008](https://github.com/operator-framework/operator-controller/issues/2008) and addresses review comments: |
| 18 | +- ✅ [Comment #3524229770](https://github.com/operator-framework/operator-controller/pull/2296#issuecomment-3524229770) - Remove False deprecation conditions (cleaner YAML) |
| 19 | +- ✅ [Comment #3524241806](https://github.com/operator-framework/operator-controller/pull/2296#issuecomment-3524241806) - Use correct Reason values per status |
| 20 | + |
| 21 | +## Changes Summary |
| 22 | + |
| 23 | +| What Changed | Main (Before) | This PR (After) | |
| 24 | +|--------------|---------------|-----------------| |
| 25 | +| **Install errors** | Leak into deprecation conditions ❌ | Stay in Progressing/Installed only ✅ | |
| 26 | +| **Catalog unavailable** | Shows `False` (claims "not deprecated") ❌ | Shows `Unknown` (honest: can't check) ✅ | |
| 27 | +| **Bundle reference** | Uses resolved bundle ❌ | Uses installed bundle ✅ | |
| 28 | +| **Not deprecated** | Shows `False` with `Reason: Deprecated` ❌ | **Condition absent** (clean YAML) ✅ | |
| 29 | +| **Reason values** | Always `Deprecated` ❌ | Context-specific (`Deprecated`, `NotDeprecated`, `DeprecationStatusUnknown`, `Absent`) ✅ | |
| 30 | +| **When set** | Only after successful resolution | After resolution, install, and during rollout ✅ | |
| 31 | + |
| 32 | +## Condition Behavior |
| 33 | + |
| 34 | +| Scenario | Status | Reason | Condition Present? | |
| 35 | +|----------|--------|--------|-------------------| |
| 36 | +| **IS deprecated** | `True` | `Deprecated` | ✅ Yes | |
| 37 | +| **NOT deprecated** | - | - | ❌ No (absent = clean!) | |
| 38 | +| **Catalog unavailable** | `Unknown` | `DeprecationStatusUnknown` | ✅ Yes | |
| 39 | +| **No bundle installed** | `Unknown` | `Absent` | ✅ Yes (BundleDeprecated only) | |
| 40 | + |
| 41 | +## Before/After Examples |
| 42 | + |
| 43 | +### Example 1: Not Deprecated (Clean YAML!) |
| 44 | + |
| 45 | +**Before (Main):** |
| 46 | +```yaml |
| 47 | +status: |
| 48 | + conditions: |
| 49 | + - type: Deprecated |
| 50 | + status: "False" # ❌ Noisy |
| 51 | + reason: Deprecated # ❌ Wrong reason for False! |
| 52 | + - type: PackageDeprecated |
| 53 | + status: "False" # ❌ Noisy |
| 54 | + reason: Deprecated |
| 55 | + - type: ChannelDeprecated |
| 56 | + status: "False" # ❌ Noisy |
| 57 | + reason: Deprecated |
| 58 | + - type: BundleDeprecated |
| 59 | + status: "False" # ❌ Noisy |
| 60 | + reason: Deprecated |
| 61 | +``` |
| 62 | +
|
| 63 | +**After (This PR):** |
| 64 | +```yaml |
| 65 | +status: |
| 66 | + conditions: |
| 67 | + - type: Progressing |
| 68 | + status: "True" |
| 69 | + reason: Succeeded |
| 70 | + - type: Installed |
| 71 | + status: "True" |
| 72 | + # ✅ No deprecation conditions = not deprecated (clean!) |
| 73 | +``` |
| 74 | + |
| 75 | +### Example 2: Install Error (Original Bug #2008) |
| 76 | + |
| 77 | +**Before (Main):** |
| 78 | +```yaml |
| 79 | +status: |
| 80 | + conditions: |
| 81 | + - type: Progressing |
| 82 | + status: "True" |
| 83 | + reason: Retrying |
| 84 | + message: "validating bundle: dependency not supported" |
| 85 | + - type: PackageDeprecated |
| 86 | + status: "False" |
| 87 | + reason: Failed # ❌ Install error leaking! |
| 88 | + message: "validating bundle: dependency not supported" # ❌ Wrong! |
| 89 | +``` |
| 90 | +
|
| 91 | +**After (This PR):** |
| 92 | +```yaml |
| 93 | +status: |
| 94 | + conditions: |
| 95 | + - type: Progressing |
| 96 | + status: "True" |
| 97 | + reason: Retrying |
| 98 | + message: "validating bundle: dependency not supported" |
| 99 | + # ✅ PackageDeprecated absent = not deprecated |
| 100 | + # ✅ Install error stays in Progressing only! |
| 101 | +``` |
| 102 | + |
| 103 | +### Example 3: Catalog Removed |
| 104 | + |
| 105 | +**Before (Main):** |
| 106 | +```yaml |
| 107 | +# Bundle v1.0.0 installed, then catalog deleted |
| 108 | +status: |
| 109 | + conditions: |
| 110 | + - type: BundleDeprecated |
| 111 | + status: "False" # ❌ Claims "not deprecated" when we can't check! |
| 112 | + reason: Absent |
| 113 | +``` |
| 114 | +
|
| 115 | +**After (This PR):** |
| 116 | +```yaml |
| 117 | +# Bundle v1.0.0 installed, then catalog deleted |
| 118 | +status: |
| 119 | + conditions: |
| 120 | + - type: BundleDeprecated |
| 121 | + status: "Unknown" # ✅ Honest: we can't check |
| 122 | + reason: DeprecationStatusUnknown |
| 123 | +``` |
| 124 | +
|
| 125 | +### Example 4: Actually Deprecated |
| 126 | +
|
| 127 | +**Before (Main):** |
| 128 | +```yaml |
| 129 | +status: |
| 130 | + conditions: |
| 131 | + - type: PackageDeprecated |
| 132 | + status: "True" |
| 133 | + reason: Deprecated |
| 134 | + message: "migrate to new-package" |
| 135 | + - type: BundleDeprecated |
| 136 | + status: "True" # ❌ Shows resolved bundle (not installed!) |
| 137 | + reason: Deprecated |
| 138 | +``` |
| 139 | +
|
| 140 | +**After (This PR):** |
| 141 | +```yaml |
| 142 | +status: |
| 143 | + conditions: |
| 144 | + - type: PackageDeprecated |
| 145 | + status: "True" |
| 146 | + reason: Deprecated |
| 147 | + message: "migrate to new-package" |
| 148 | + - type: BundleDeprecated |
| 149 | + status: "True" # ✅ Shows installed bundle |
| 150 | + reason: Deprecated |
| 151 | +``` |
| 152 | +
|
| 153 | +## New Reason Constants |
| 154 | +
|
| 155 | +Added to `api/v1/common_types.go`: |
| 156 | +```go |
| 157 | +ReasonDeprecated = "Deprecated" // When True |
| 158 | +ReasonDeprecationStatusUnknown = "DeprecationStatusUnknown" // When Unknown |
| 159 | +// No ReasonNotDeprecated - conditions are absent when not deprecated! |
| 160 | +``` |
| 161 | + |
| 162 | +## Implementation Highlights |
| 163 | + |
| 164 | +### Simplified Logic (Clear → Add Only What We Need) |
| 165 | + |
| 166 | +```go |
| 167 | +func SetDeprecationStatus(...) { |
| 168 | + // 1. Clear all deprecation conditions first |
| 169 | + apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1.TypeDeprecated) |
| 170 | + apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1.TypePackageDeprecated) |
| 171 | + apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1.TypeChannelDeprecated) |
| 172 | + apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1.TypeBundleDeprecated) |
| 173 | + |
| 174 | + // 2. Only add conditions when there's something to report |
| 175 | + if !hasCatalogData { |
| 176 | + // Add Unknown conditions |
| 177 | + return |
| 178 | + } |
| 179 | + |
| 180 | + if len(packageMessages) > 0 { |
| 181 | + // Only add when True |
| 182 | + setDeprecationCondition(ext, ocv1.TypePackageDeprecated, metav1.ConditionTrue, ...) |
| 183 | + } |
| 184 | + // Not deprecated? Already cleared, nothing to do! |
| 185 | +} |
| 186 | +``` |
| 187 | + |
| 188 | +## Stats |
| 189 | + |
| 190 | +- 📝 **15 files changed** |
| 191 | +- ➕ **774 additions** (mostly tests) |
| 192 | +- ➖ **243 deletions** |
| 193 | +- ✅ **All tests passing** |
| 194 | +- ✅ **Linter clean** |
| 195 | +- ✅ **33% less code** in core SetDeprecationStatus function |
| 196 | + |
| 197 | +## Testing Coverage |
| 198 | + |
| 199 | +Added comprehensive test cases: |
| 200 | +- ✅ No catalog data scenarios |
| 201 | +- ✅ Resolution fails with/without deprecation data |
| 202 | +- ✅ Boxcutter rollout scenarios |
| 203 | +- ✅ Catalog removed scenarios |
| 204 | +- ✅ All deprecation combinations |
| 205 | + |
| 206 | +## Review Comments Addressed |
| 207 | + |
| 208 | +### ✅ Joe's Comment #3524229770 |
| 209 | +> "Should we include False conditions? They add noise." |
| 210 | + |
| 211 | +**Solution:** Conditions are now **absent** when not deprecated. Much cleaner YAML output! |
| 212 | + |
| 213 | +### ✅ Joe's Comment #3524241806 |
| 214 | +> "Wrong to have Reason: Deprecated when status is False or Unknown." |
| 215 | + |
| 216 | +**Solution:** Added proper reason values: |
| 217 | +- `Deprecated` → when True (something IS deprecated) |
| 218 | +- `DeprecationStatusUnknown` → when Unknown (can't check catalog) |
| 219 | +- `Absent` → when no bundle installed (BundleDeprecated only) |
| 220 | +- No `NotDeprecated` reason needed - conditions are simply absent! |
| 221 | + |
| 222 | +## Closes |
| 223 | + |
| 224 | +- #2008 - Install errors leaking into deprecation conditions |
| 225 | + |
0 commit comments