Prevent OLM upgrades from overwriting operator-config ConfigMap#2441
Prevent OLM upgrades from overwriting operator-config ConfigMap#2441ELENAGER wants to merge 2 commits intoRamenDR:mainfrom
Conversation
Why ramen operator need to create or update the config? Please explain these flows:
Ideally the flows should be documented in docs/configmap.md. How ramen can tell if a user want to keep a default option? For example if a boolean options are unset, how ramen can tell if unset option in user configmap should be false or should sue the value from ramen default config? |
Signed-off-by: Elena Gershkovich <[email protected]>
Flows1) New install via OLM
2) New install via ramendev /
|
So we store all defaults in the executable as constants?
Why we need to read the defaults from this new config map if we store the default in the executable (based on step 1)?
Why we need to create the configmap? We already know the defaults, and there are no user config, so we use the defaults.
User owned configmap makes sense, since the user owns the configuration. Ramen should not create or update this file since it does not own the file.
ramendev can create the -default file - but since we know the defaults, there is no need to create this file.
This proves that the -default file is not need - we can start successfully without it.
Makes sense - this is the actual fix - OLM never touch the user config. |
internal/controller/ramenconfig.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| defaultsCfg = cfg |
There was a problem hiding this comment.
s/defaultsCfg/mergedCfg
internal/controller/ramenconfig.go
Outdated
|
|
||
| log.Info("created configmap", "namespace", newCM.Namespace, "name", newCM.Name) | ||
|
|
||
| return defaultRamenConfig, nil |
There was a problem hiding this comment.
return defaultsCfg instead
| // Desired Ramen config: defaults + preserve S3 from existing CM | ||
| desiredRamenConfig := defaultsCfg | ||
| desiredRamenConfig.S3StoreProfiles = existingCfg.S3StoreProfiles | ||
|
|
There was a problem hiding this comment.
we need to do the following for the other fields
- if existingCfg doesn't have the field populated, then use the defaultsCfg value
- if existingCfg has any value(even the default for that type), then use from the existingCfg
That keeps the bundle structure largely the same, reduces upgrade risk, and still fixes the “OLM overwrites user config” problem. Also it gives a cluster-visible “what defaults does this bundle ship?” object that support/QE can inspect. |
04dc32a to
6fcfe57
Compare
Signed-off-by: Elena Gershkovich <[email protected]>
Problem: During OLM upgrades, the operator-config ConfigMap gets re-applied from the bundle/CSV content. As a result, user-managed fields in RamenConfig (inside the S3 configuration) disappear after upgrades because they are replaced by the default config shipped with the bundle.
Fix: Split defaults from user configuration. OLM now generates a defaults ConfigMap with a -default suffix, while the operator manages a separate user ConfigMap at runtime. On startup (and after upgrades), the operator reads the *-default ConfigMap as the current defaults, then:
if a user ConfigMap exists, it preserves the user’s S3 settings by merging S3StoreProfiles into the defaults and updates the user ConfigMap if needed;
if no user ConfigMap exists, it creates one from the defaults.
This ensures OLM upgrades only update the defaults ConfigMap, while user S3 configuration is preserved across upgrades.
Fixes: https://issues.redhat.com/browse/DFBUGS-440