Skip to content
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

[BUG] Specifying vm_overrides with cloud.profile runner does not merge configuration from the profile #63351

Open
a-wildman opened this issue Dec 21, 2022 · 2 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage Salt-Cloud

Comments

@a-wildman
Copy link

Description of Issue

When supplying vm_overrides to the cloud.profile runner, any top-level keys in vm_overrides cause the associated definitions in the profile to be completely overwritten (i.e. replaced, whereas the expectation was that they would be merged)

Steps to Reproduce Issue

Given the following profile definition :

my-vm-profile:
  # [...]

  devices:
    disk:
      Hard disk 1:
        size: 5
        thin_provision: False
      Hard disk 2:
        size: 128
        thin_provision: True
    network:
      Network adapter 1:
        name: VM Network
        switch_type: standard
        adapter_type: vmxnet3

calling the following (intending for the above profile definitions to take effect while specifying an IP address):

salt-run cloud.profile profile=my-vm-profile names=new-vm.example.com vm_overrides="{'devices' : {'network' : {'Network adapter 1' : {'ip' : '192.168.0.10'} } } }"

causes the entire devices entry to be replaced with what is specified on the command line (i.e. disk definitions are gone).

This is caused by dict.update being used to apply the overrides definition in salt.cloud.vm_config() (whereas salt.utils.dictupdate.update() would merge them, e.g.:

diff --git a/salt/cloud/__init__.py b/salt/cloud/__init__.py
index 2b21483599..35292003f7 100644
--- a/salt/cloud/__init__.py
+++ b/salt/cloud/__init__.py
@@ -1313,7 +1313,7 @@ class Cloud:
         vm = main.copy()
         vm = salt.utils.dictupdate.update(vm, provider)
         vm = salt.utils.dictupdate.update(vm, profile)
-        vm.update(overrides)
+        vm = salt.utils.dictupdate.update(vm, overrides)
         vm["name"] = name
         return vm

Versions Report

This was observed on 3002.9, but code inspection shows this is still the case in 3005

@a-wildman a-wildman changed the title Specifying vm_overrides with cloud.profile runner does not merge configuration from the profile [BUG] Specifying vm_overrides with cloud.profile runner does not merge configuration from the profile Dec 21, 2022
@OrangeDog OrangeDog added Bug broken, incorrect, or confusing behavior Salt-Cloud needs-triage labels Dec 21, 2022
@a-wildman
Copy link
Author

Looks like this may be fixed in 2c72c04

@a-wildman
Copy link
Author

a-wildman commented Oct 24, 2023

See also #64610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage Salt-Cloud
Projects
None yet
Development

No branches or pull requests

2 participants