← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1812676] [NEW] cloud-init-per mishandles commands with dashes

 

Public bug reported:

It was found that when there is a dash in cloud-init-per command
name and cloud-init-per is executed through cloud-init's bootcmd, e.g:

bootcmd:
- cloud-init-per instance mycmd-bootcmd /usr/bin/mycmd

the command is executed on each boot. However, running the same
cloud-init-per command manually after boot doesn't reveal the issue. Turns
out the issue comes from 'migrator' cloud-init module which renames all
files in /var/lib/cloud/instance/sem/ replacing dashes with underscores. As
migrator runs before bootcmd it renames
    
/var/lib/cloud/instance/sem/bootper.mycmd-bootcmd.instance
to
/var/lib/cloud/instance/sem/bootper.mycmd_bootcmd.instance

so cloud-init-per doesn't see it and thinks that the comment was never ran
before. On next boot the sequence repeats.

There are multiple ways to resolve the issue. This patch takes the
following approach: 'canonicalize' sem names by replacing dashes with
underscores (this is consistent with post-'migrator' contents of
/var/lib/cloud/instance/sem/). We, however, need to be careful: in case
someone had a command with dashes before and he had migrator module enables
we need to see the old sem file (or the command will run again and this can
be as bad as formatting a partition!) so we add a small 'migrator' part to
cloud-init-per script itself checking for legacy sem names.

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

** Patch added: "0001-cloud-init-per-don-t-use-dashes-in-sem-names.patch"
   https://bugs.launchpad.net/bugs/1812676/+attachment/5231108/+files/0001-cloud-init-per-don-t-use-dashes-in-sem-names.patch

-- 
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/1812676

Title:
  cloud-init-per mishandles commands with dashes

Status in cloud-init:
  New

Bug description:
  It was found that when there is a dash in cloud-init-per command
  name and cloud-init-per is executed through cloud-init's bootcmd, e.g:

  bootcmd:
  - cloud-init-per instance mycmd-bootcmd /usr/bin/mycmd

  the command is executed on each boot. However, running the same
  cloud-init-per command manually after boot doesn't reveal the issue. Turns
  out the issue comes from 'migrator' cloud-init module which renames all
  files in /var/lib/cloud/instance/sem/ replacing dashes with underscores. As
  migrator runs before bootcmd it renames
      
  /var/lib/cloud/instance/sem/bootper.mycmd-bootcmd.instance
  to
  /var/lib/cloud/instance/sem/bootper.mycmd_bootcmd.instance

  so cloud-init-per doesn't see it and thinks that the comment was never ran
  before. On next boot the sequence repeats.

  There are multiple ways to resolve the issue. This patch takes the
  following approach: 'canonicalize' sem names by replacing dashes with
  underscores (this is consistent with post-'migrator' contents of
  /var/lib/cloud/instance/sem/). We, however, need to be careful: in case
  someone had a command with dashes before and he had migrator module enables
  we need to see the old sem file (or the command will run again and this can
  be as bad as formatting a partition!) so we add a small 'migrator' part to
  cloud-init-per script itself checking for legacy sem names.

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


Follow ups