cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

Ubuntu/focal 24 1.x:fix(cli): retain support for --files argument before subcommand

Open blackboxsw opened this issue 1 year ago • 1 comments

Proposed Commit Message (rebase commit, not squash merge)

    fix(cli): retain support for --files argument before subcommand
    
    Upstream dropped support for a generic positional --file argument ordered
    on the command line before the cloud-init subcommand because the
    --files argument is only applicable to the specific subcommands init,
    modules and single.
    
    Add functionality to retain support for --file or -f argument both
    before and after the subcommand to avoid regressions in stable releases due
    to a change in behavior.
    
    LP: #2064300

Additional Context

When approved, this same quilt patch will be applied to upstream/ubuntu/(jammy|mantic)-24.1.x branches and uploaded to unapproved queue for focal, jammy and mantic. This quilt patch and related debian/changelog entries will also by sync'd to the unreleased upstream/ubuntu/(focal|jammy|mantic) branches to ensure next new-upstream-snapshot SRU of 24.2 also includes this backport.

Test Steps

quilt push -a; tox -e py3; quilt pop -a
build-package
sbuild .... ../out/*dsc
lxc launch ubuntu-daily:focal test-f
lxc exec test-f bash
$ cat >1.yaml <<EOF
#cloud-config
hostname: worked
EOF
$ cloud-init clean  --logs
# confirm failure of published deb
$ apt update; apt install cloud-init; cloud-init --version
/usr/bin/cloud-init 24.1.3-0ubuntu1~20.04.1
$ cloud-init -f 1.yaml init
usage: /usr/bin/cloud-init [-h] [--version] [--debug] [--force]
                           {init,modules,single,query,features,analyze,devel,collect-logs,clean,status,schema}
                           ...
/usr/bin/cloud-init: error: argument subcommand: invalid choice: '1.yaml' (choose from 'init', 'modules', 'single', 'query', 'features', 'analyze', 'devel', 'collect-logs', 'clean', 'status', 'schema')
$ exit
# Test new deb
lxc file push *deb test-f/
lxc exec test-f -- apt install /*deb
$ cloud-init -f 1.yaml init
$ hostname   # expect hostname to change to worked
worked

Checklist

Merge type

  • [x] Squash merge using "Proposed Commit Message"
  • [ ] Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

blackboxsw avatar Apr 30 '24 21:04 blackboxsw

  • quilt push -a; tox -e py3; quilt pop -a success py3: OK (135.10=setup[8.46]+cmd[126.64] seconds) *build-package ,sbuild success
Status: successful
Version: 24.1.3-0ubuntu1~20.04.3
  • lxc test
$ lxc launch ubuntu-daily:focal test-f
Creating test-f
Starting test-f                             
 lxc exec test-f bash
root@test-f:~# cat >1.yaml <<EOF
> #cloud-config
> hostname: worked
> EOF
root@test-f:~# cloud-init clean  --logs
root@test-f:~# apt update; apt install cloud-init; cloud-init --version
...
/usr/bin/cloud-init 24.1.3-0ubuntu1~20.04.1
# confirm fail
root@test-f:~# cloud-init -f 1.yaml init
usage: /usr/bin/cloud-init [-h] [--version] [--debug] [--force]
                           {init,modules,single,query,features,analyze,devel,collect-logs,clean,status,schema}
                           ...
/usr/bin/cloud-init: error: argument subcommand: invalid choice: '1.yaml' (choose from 'init', 'modules', 'single', 'query', 'features', 'analyze', 'devel', 'collect-logs', 'clean', 'status', 'schema')
root@test-f:~# exit
# Test new deb 
lxc file push *deb test-f/
lxc exec test-f bash
root@test-f:~# apt install /cloud-init_24.1.3-0ubuntu1~20.04.3_all.deb 
...
Setting up cloud-init (24.1.3-0ubuntu1~20.04.3) ...
root@test-f:~# cloud-init -f 1.yaml init
Cloud-init v. 24.1.3-0ubuntu1~20.04.3 running 'init' at Tue, 30 Apr 2024 22:49:24 +0000. Up 1839.16 seconds.
ci-info: ++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
...
root@test-f:~# hostname
worked

# Confirm -f placement after subcommand works as well
root@test-f:~# hostname test-f
root@test-f:~# hostname
test-f
root@test-f:~# cloud-init clean
root@test-f:~#  cloud-init init -f 1.yaml
Cloud-init v. 24.1.3-0ubuntu1~20.04.3 running 'init' at Tue, 30 Apr 2024 22:52:03 +0000. Up 1998.22 seconds.
...
root@test-f:~# hostname
worked

blackboxsw avatar Apr 30 '24 22:04 blackboxsw