longhorn: [BUG] helm upgrade won't apply customize default setting
Is your feature request related to a problem? Please describe.
The longhorn-default-setting ConfigMap sync to settings CR only when settings CR does not exist. This means that during helm upgrade if the user changes the setting, then it won’t applies to settings CR (but applies to longhorn-default-setting ConfigMap only)
helm upgrade longhorn longhorn/longhorn -n longhorn-system \
--set defaultSettings.backupTarget=<new-backup-target> \
--set defaultSettings.backupTargetCredentialSecret=<new-backup-target-credential-secret>
Describe the solution you’d like
I think we could configure the settings CR directly. So, we don’t have to write a setting controller to reconcile to longhorn-default-setting ConfigMap to settings CR. However, to accomplish it, we need to have a structural schema on CRDs and also, have an admission webhook to validate the input of these settings.
Describe alternatives you’ve considered
N/A
Additional context
Related issues
- https://github.com/longhorn/longhorn/issues/2562#issuecomment-832413461
- https://github.com/longhorn/longhorn/issues/2539#issuecomment-827290662
- https://github.com/longhorn/longhorn/issues/2611
- https://github.com/longhorn/longhorn/issues/2744
- https://github.com/longhorn/longhorn/issues/2825
- https://github.com/longhorn/longhorn/issues/3398
- https://github.com/longhorn/longhorn/issues/3458
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 46 (38 by maintainers)
I just rollback to previous ConfigMap and implement the setting update in upgrade path. Looks feasible. I will submit the PR after fully testing.
If the Longhorn version is changed, update the latest settings provided by users. If not changed, don’t update the setting.
Only update the manifests and the version is not changed, then the setting will not be updated.
Yes, we already known it, thanks.
Validate on longhorn
Test steps Result Pass
Test 1. Fresh installation Check default setting value working properly at each step
Test 2.1 Upgrade from v1.1.x/v1.2.x to master-head and without a new customized-default-settings.yaml Check default setting value working properly at each step
Test 3 Upgrade from v1.1.x/v1.2.x to master-head and with a new customized-default-settings.yaml Check default setting value working properly at each step
cc @innobead , @derekbit
Add more e2e test cases for in-place update via config map controller. https://github.com/longhorn/longhorn-tests/pull/969
cc @cchien816
Yes, I’m working on it.
Also tested the upgrade on Rancher UI. The default settings set in v1.2.4 are reserved as expected after upgrading to v1.3.0.
It seems that the Setting CR solution is still blocked by https://github.com/longhorn/longhorn/issues/1879#issuecomment-947332276
I am fine with rollbacking to use the ConfigMap for now.
Validate on longhorn
Test steps Result Pass
Test 1. Fresh installation Check default setting value working properly at each step
Test 2.1 Upgrade from v1.1.x/v1.2.x to master-head and without a new customized-default-settings.yaml Check default setting value working properly at each step
Test 3 Upgrade from v1.1.x/v1.2.x to master-head and with a new customized-default-settings.yaml Check default setting value working properly at each step
cc @innobead , @derekbit
Three manual test cases.
Test 1. Fresh installation
1. Create customized-default-settings.yaml
2. Install Longhorn with customized-default-settings.yaml
Then, check the default settings.
3. Update default settings using kubectl
4. Upgrade (Longhorn version is not changed, and longhorn-manager tag is changed)
4.1 Without a new customized-default-settings.yaml
The default settings should not be modified.
4.2 With a new customized-default-settings.yaml
Then, check if the default settings are updated as expected.
Update default settings using kubectl
5. Delete longhorn-manager and wait for restart.
Check the default settings that should not be modified.
6. Upgrade (Longhorn version is not changed, and longhorn-manager tag is not changed)
Update default settings using kubectl
With a new-customized-default-settings2.yaml
Check the default settings
With a new-customized-default-settings3.yaml
Check the default settings
Test 2. Upgrade from v1.1.x or v1.2.x to master-head and without a new customized-default-settings.yaml
1. Install Longhorn v1.1.x or v1.2.x with customized-default-settings.yaml
Then, check the default settings.
2. Upgrade to master-head
The default settings should not be modified.
Then, follow the steps from Test 1. Step3-Step6
Test 3. Upgrade from v1.1.x or v1.2.x to master-head and with a new customized-default-settings.yaml
1. Install Longhorn v1.1.x or v1.2.x with customized-default-settings.yaml
Then, check the default settings.
2. Upgrade to master-head
Then, check if the default settings are updated as expected.
3. Update default settings using kubectl
4. Delete longhorn-manager and wait for restart.
Check the default settings that should not be modified.
The design isIn the upgrade path and before~~CreateOrUpdateLonghornVersionSetting, doupdateCustomizedDefaultSetting.InupdateCustomizedDefaultSetting- check if the LH version will be updated~~ - If no, don’t update any default settings and exit directly~~ ~- - If yes, read the customized default settings from latest ConfigMap user provided~~ ~~ - update the settings to latest values~~Just saw the test in https://github.com/longhorn/longhorn/issues/2570#issuecomment-1004601106. The Longhorn version is not enough, so I change the design. The design is
☝️ just saw this part as you said.
If this possibly happens, then we should revert these changes. @derekbit well done to find out this corner!
The way you proposed is a way to do it, but the helm chart is not just for install or upgrade, it is probably used by users to update the existing manifests instead of only upgrading to a new Longhorn version, so a version flag to determine if need to update settings probably will not work completely?
Also, probably need to consider the consistency between the config map and settings via controllers.
Helm cannot guarantee the setting CR create/update happens after the setting CRD is registered although post-install hook on the setting CR is applied.
No, there is a probability of hitting the error after applying the solution.
Validation - PASSED
This test result only applies for master-head version. Due to an API version issue for the moment, upgrading from v1.2.2 or 1.1.3 will be tested in backport issues.
With the fix, Longhorn will now respect the customized values. Also, when upgrading without additional customization the setting values will be carry over.
Detail steps:
$ helm install longhorn ./longhorn/chart --set defaultSettings.defaultReplicaCount=11 -n longhorn-system$ kubectl get setting/default-replica-count -n longhorn-systemhelm upgrade longhorn ./longhorn/chart --set defaultSettings.defaultReplicaCount=7 -n longhorn-systemAdditional test for deleting setting:
$ kubectl delete setting/default-replica-count -n longhorn-systemAfter the team review meeting, we could revisit it again after the longhorn bumped the CRD version to
v1beta2, to see if it is doable or not.