Allow to upgrade Sylva-unit-operator, flux and eso from dedicated source
Warning
This MR depends on the one allowing existing_source: sylva-projects/sylva-core!5992 (merged)
To avoid GitOps chicken and egg issue: if we want to use last operator version in last version of sylva, we need to upgrade first the operator before updating the SylvaUnitRelease.
This MR introduces new optional parameter in the SylvaUnitRelease: operatorSource which may be used to update only the sylva-unit-operator (and flux and eso)
If operatorSource is set, the sylva-unit-operator creates a new source and wait for sylva-unit-operator, flux and eso to be up to date.
If not, if sylvaUnitsSource changed, the sylva-unit-operator creates a new source and wait for sylva-unit-operator, flux and eso to be up to date.
If not the operator reconcile (or not) the sulvyUnitRelease
This MR contains 3 commits:
- the feature itself
- the unit tests
- a CEL to forbid modifying sylvaUnitsSource to another value than operatorSource if operatorSource is set
Fix: #63 (closed) sylva-projects/sylva-core#2376 (closed) and #40 (closed)
graph TD
subgraph "Initial State"
A[SylvaUnitsRelease created]
B[GitRepository created]
C[HelmRelease created pointing to GitRepository]
D[HelmRelease deploys Kustomizations: flux-system, eso, suro]
E[Kustomizations point to same GitRepository]
A --> B
B --> C
C --> D
D --> E
end
subgraph "1 Step Upgrade (sylvaUnitsSource)"
F[Modify sylvaUnitsSource.branch = 'feature-branch']
G[New GitRepository created]
H1[flux-system, eso and suro Kustomizations updated IMMEDIATELY to new source]
I1[Wait for Kustomizations Ready = true]
J1[HelmRelease updated to new source]
K1[Old GitRepository deleted]
F --> G
G --> H1
H1 --> I1
I1 --> J1
J1 --> K1
end
subgraph "2 Steps Upgrade (operatorSource)"
L[Add operatorSource different from sylvaUnitsSource]
M[New GitRepository operatorSource created]
N[flux-system, eso and suro Kustomizations updated to operatorSource]
O[Wait for Kustomizations Ready = true]
P[HelmRelease STAYS on original sylvaUnitsSource]
Q[Step 2: sylvaUnitsSource.branch = operatorSource.branch]
S[HelmRelease updated to new sylvaUnitsSource]
T[Old GitRepository deleted]
L --> M
M --> N
N --> O
O --> P
Q --> S
S --> T
end
E -->|Method 1| F
E -->|Method 2| L
style F fill:#e1f5fe
style L fill:#fff3e0
style Q fill:#fff3e0
style H1 fill:#e8f5e8
style N fill:#e8f5e8
style P fill:#ffebee
style J1 fill:#e8f5e8
style S fill:#e8f5e8
Tests
I tested 1 step and 2 steps upgrades on a local environment using https://gitlab.com/sylva-projects/sylva-core/-/commits/test-suro-upgrade, modifying the SUR sources manually.
It seems to be working as expected.
Inspired from !419 (closed)