← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1400793] [NEW] default merging for cloud-config is not right.

 

Public bug reported:

long ago, 2 cloud-configs merged in one way.
after new the new mergers that seems to be changed.

$ cat f1.yaml
#cloud-config
snappy:
  packages: [orig_pkg1, orig_pkg2]
  ssh_enabled: True
ssh_authorized_keys:
  - mykey@smoser

$ cat f2.yaml
#cloud-config
snappy:
  packages: [updated_pkg1, updated_pkg2]

$ PYTHONPATH=$PWD ./tools/ccfg-merge-debug  f1.yaml f2.yaml
#cloud-config

# from 2 files
# part-001
# part-002

---
snappy:
    packages:
    - updated_pkg1
    - updated_pkg2
ssh_authorized_keys:
- mykey@smoser
...

the above is different than the expected behavior from long ago, which is to act like 'mergemanydict' does:
$ cat oldmerge.py
#!/usr/bin/python
from cloudinit import util
import sys, yaml
print util.mergemanydict([yaml.load(open(f)) for f in sys.argv[1:]], reverse=True)

$ python oldmerge.py f1.yaml f2.yaml
{'snappy': {'packages': ['updated_pkg1', 'updated_pkg2'], 'ssh_enabled': True}, 'ssh_authorized_keys': ['mykey@smoser']}

The bug here is that 'ssh_enabled' got dropped. as the second config's 'snappy' completely replaced the first.
Note, also that its not sufficient to just change the DEF_MERGERS to be 'dict('no_replace')'.

** Affects: cloud-init
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1400793

Title:
  default merging for cloud-config is not right.

Status in Init scripts for use on cloud images:
  New

Bug description:
  long ago, 2 cloud-configs merged in one way.
  after new the new mergers that seems to be changed.

  $ cat f1.yaml
  #cloud-config
  snappy:
    packages: [orig_pkg1, orig_pkg2]
    ssh_enabled: True
  ssh_authorized_keys:
    - mykey@smoser

  $ cat f2.yaml
  #cloud-config
  snappy:
    packages: [updated_pkg1, updated_pkg2]

  $ PYTHONPATH=$PWD ./tools/ccfg-merge-debug  f1.yaml f2.yaml
  #cloud-config

  # from 2 files
  # part-001
  # part-002

  ---
  snappy:
      packages:
      - updated_pkg1
      - updated_pkg2
  ssh_authorized_keys:
  - mykey@smoser
  ...

  the above is different than the expected behavior from long ago, which is to act like 'mergemanydict' does:
  $ cat oldmerge.py
  #!/usr/bin/python
  from cloudinit import util
  import sys, yaml
  print util.mergemanydict([yaml.load(open(f)) for f in sys.argv[1:]], reverse=True)

  $ python oldmerge.py f1.yaml f2.yaml
  {'snappy': {'packages': ['updated_pkg1', 'updated_pkg2'], 'ssh_enabled': True}, 'ssh_authorized_keys': ['mykey@smoser']}

  The bug here is that 'ssh_enabled' got dropped. as the second config's 'snappy' completely replaced the first.
  Note, also that its not sufficient to just change the DEF_MERGERS to be 'dict('no_replace')'.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1400793/+subscriptions


Follow ups

References