-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix removing array type values in machine pool configs #10741
Fix removing array type values in machine pool configs #10741
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that we're going to want to change the functionality of syncMachineConfigWithLatest
and just replace the metadata instead of merging.
With that said, let's see how this works in practice.
1e1ead2
to
cd7f936
Compare
shell/utils/custom-merge.ts
Outdated
* | ||
* This helper function addresses the issue by always replacing the old array with the new array during the merge process. | ||
*/ | ||
export function customMerge(obj1 = {}, obj2 = {}): Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the possible usages outside of shell/edit/provisioning.cattle.io.cluster, can this live there and be titled something like poolConfigMerge?
Otherwise it probably needs to be generic and go into utils/object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't validated by vsphere creds yet, but general edit of non-vsphere looks good. If you've validated the issue is resolved then lets get this in.
I just tested it and it works as expected |
Summary
Fixes #10693
In
rke2.vue
, before saving the new changes made to the machine pools configuration we runsyncMachineConfigWithLatest
function, it gets the latest(last saved) config from the BE, then uses Lodashmerge
function to update it with the current changes made by the user. The problem is that if the user removes an item from an array type config value(e.g. network in vSphere), it will never work due to the default behaviour of Lodashmerge
function. Example:A new helper function
customMerge
is created to address the issue by correctly replacing the old array values with the new values during the merge process.Areas or cases that should be tested
This change is not limited to vSphere's machine pool config, any array type values for any provider's machine pool config will be affected. I haven't found any examples so far, but I believe the removing issue exists for any provider's array type value in their machine pool config, and this PR should fix them too.
Areas which could experience regressions
Same as above.
Screenshot/Video
Screen.Recording.2024-04-02.at.1.26.27.PM.mov
Checklist