|
| 1 | +# Fix deprecation conditions when catalog is unavailable |
| 2 | + |
| 3 | +Fixes #2008 |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This PR fixes how deprecation conditions are reported when the catalog is unavailable or resolution fails: |
| 8 | + |
| 9 | +- **Show Unknown when catalog is unavailable**: When a catalog is removed or unreachable, deprecation conditions now correctly show `Unknown` instead of `False`, so users know "we don't know if it's deprecated" rather than "definitely not deprecated" |
| 10 | + |
| 11 | +- **Report installed bundle deprecation, not resolved**: BundleDeprecated now reflects the currently installed bundle's status, not the bundle being installed during an upgrade |
| 12 | + |
| 13 | +- **Keep deprecation data separate from errors**: Install and validation errors stay in Progressing/Installed conditions, never leak into deprecation conditions |
| 14 | + |
| 15 | +- **Handle catalog deprecation data on failures**: When resolution fails but the catalog still returns deprecation warnings, those warnings now reach users |
| 16 | + |
| 17 | +## TL;DR |
| 18 | + |
| 19 | +`SetDeprecationStatus` now properly handles three scenarios: |
| 20 | + |
| 21 | +**1. No catalog data (catalog removed or unreachable)** |
| 22 | +- All deprecation conditions → `Unknown` |
| 23 | +- BundleDeprecated reason → `Absent` only when no bundle installed, `Deprecated` when bundle exists |
| 24 | + |
| 25 | +**2. Catalog available with deprecation warnings** |
| 26 | +- PackageDeprecated → `True` if catalog marks package deprecated |
| 27 | +- ChannelDeprecated → `True` if requested channel marked deprecated |
| 28 | +- BundleDeprecated → reflects the **installed** bundle (not the one being installed) |
| 29 | +- Deprecated (rollup) → `True` if any deprecation signal present |
| 30 | + |
| 31 | +**3. Resolution fails but returns deprecation data** |
| 32 | +- Deprecation warnings shown even when installation cannot proceed |
| 33 | +- Progressing condition shows the resolution error |
| 34 | +- Deprecation conditions show catalog warnings separately |
| 35 | + |
| 36 | +## Key Changes |
| 37 | + |
| 38 | +### Controller Logic |
| 39 | +- Added defer to update deprecation status at the end of reconciliation |
| 40 | +- Track `hadCatalogDeprecationData` flag to distinguish "catalog absent" from "catalog says not deprecated" |
| 41 | +- Use installed bundle name from `revisionStates.Installed`, not the resolved bundle |
| 42 | + |
| 43 | +### SetDeprecationStatus Function |
| 44 | +- Simplified from ~90 lines to ~50 lines using helper function |
| 45 | +- Handle `hasCatalogData=false` case to set all conditions Unknown |
| 46 | +- BundleDeprecated uses correct reason based on whether bundle exists |
| 47 | + |
| 48 | +### Tests |
| 49 | +- Added `TestClusterExtensionResolutionFailsWithoutCatalogDeprecationData` - verifies Unknown status when catalog unavailable |
| 50 | +- Enhanced `TestSetDeprecationStatus` with 3 new test cases for catalog absence scenarios |
| 51 | +- Added scenario descriptions to all related tests for clarity |
| 52 | + |
| 53 | +## Examples |
| 54 | + |
| 55 | +### Before (incorrect behavior) |
| 56 | +```yaml |
| 57 | +# Bundle v1.0.0 installed, catalog removed |
| 58 | +Deprecated: False/Deprecated # ❌ Wrong - should be Unknown |
| 59 | +BundleDeprecated: False/Absent # ❌ Wrong - bundle exists but shows Absent |
| 60 | +``` |
| 61 | +
|
| 62 | +### After (correct behavior) |
| 63 | +```yaml |
| 64 | +# Bundle v1.0.0 installed, catalog removed |
| 65 | +Deprecated: Unknown/Deprecated # ✅ Correct - we don't know |
| 66 | +BundleDeprecated: Unknown/Deprecated # ✅ Correct - bundle exists, catalog unknown |
| 67 | +``` |
| 68 | +
|
| 69 | +### During Upgrade (fixed) |
| 70 | +```yaml |
| 71 | +# Upgrading from v1.0.0 to v1.0.1 (v1.0.1 not installed yet) |
| 72 | +BundleDeprecated: shows v1.0.0 status # ✅ Correct - reflects installed bundle |
| 73 | +``` |
| 74 | +
|
| 75 | +## Testing |
| 76 | +
|
| 77 | +All tests pass: |
| 78 | +- ✅ `TestSetDeprecationStatus` - 11 test cases covering all deprecation scenarios |
| 79 | +- ✅ `TestClusterExtensionResolutionFailsWithoutCatalogDeprecationData` - catalog unavailable |
| 80 | +- ✅ `TestClusterExtensionResolutionFailsWithDeprecationData` - resolution fails with warnings |
| 81 | +- ✅ `TestClusterExtensionBoxcutterApplierFailsDoesNotLeakDeprecationErrors` - errors don't leak |
| 82 | +- ✅ All existing controller tests |
| 83 | + |
| 84 | +## Files Changed |
| 85 | + |
| 86 | +``` |
| 87 | +13 files changed, 723 insertions(+), 144 deletions(-) |
| 88 | +``` |
| 89 | +
|
| 90 | +**Controller:** |
| 91 | +- `clusterextension_controller.go` - defer logic, simplified SetDeprecationStatus |
| 92 | +- `clusterextension_controller_test.go` - new tests and scenario descriptions |
| 93 | +
|
| 94 | +**API/Docs:** |
| 95 | +- `clusterextension_types.go` - updated deprecation condition documentation |
| 96 | +- `olmv1-api-reference.md` - updated API docs |
| 97 | +- CRD manifests - regenerated with updated descriptions |
| 98 | +
|
0 commit comments