canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
3.01k stars 887 forks source link

fix: avoid deprecation logs for calling cli stages #5770

Closed blackboxsw closed 1 month ago

blackboxsw commented 1 month ago

Includes a git revert of bd6cd1fbee12ac81ff6c46cc5f979cfdf76e5e13.

Proposed Commit Message

fix: avoid deprecation logs for calling cli stages

Avoid deprecating command line calls to cloud-init boot.

When cloud-init's boot stages are invoked directly on the command line
is typically an attempt to add suppplemental configuration to a
system after initial boot has completed.
Although direct calls to cloud-init boot stages could lead to
misconfiguration if boot stages are called out of sequence
of customized /etc/cloud/cloud.cfg altering which config modules are
run during the boot stage, the support of such uses or custom
environments is out of scope for this feature. It remains a simple
tool to apply additional configuration via user-data onto an existing
system after initial boot.

At some point in the future, a new subcommand may be provided by
cloud-init tooling to allow for supplemental configuration of user-data
post-boot, in that event this --file feature will become deprecated in
favor of a cleaner/simpler alternative.

Fixes GH-5726

Additional Context

This fix will be backported to Ubuntu Oracular as a bug fix as well, avoiding exit 2 from cloud-init status and DEPRECATION or INFO level logs for users or tooling which call cloud-init boot stages with the --file param.

5726

Test Steps

CLOUD_INIT_OS_IMAGE=oracular CLOUD_INIT_CLOUD_INIT_SOURCE=IN_PLACE tox -e integration-tests -- tests/integration_tests/cmd/test_stages.py

# Test stable series non-deprecation level logs by modifying cloudint/features.py locally before running against focal
sed -i 's/devel/22.1/' cloudinit/features.py 
CLOUD_INIT_OS_IMAGE=focal CLOUD_INIT_CLOUD_INIT_SOURCE=IN_PLACE tox -e integration-tests -- tests/integration_tests/cmd/test_stages.py

Merge type

blackboxsw commented 1 month ago

The intent of only supporting this subset of functionality was to continue to limit other uses calling into these boot stages directly post-boot. But, per the comment below we probably should leave both approaches intact as they are very nearly the same functionality as --files just adds to the merged config just as adding a new file in /etc/cloud/cloud.cfg.d/*. So it doesn't make sense to allow one path and not the other.

Upon further conversation w/ @holmanb @TheRealFalcon about this limited revert of the deprecation message:

If we only allowing cloud-init init --files but do not allow admins to add new files into /etc/cloud/cloud.cfg.d/some.cfg and call cloud-init init we are disallowing nearly the same behavior that the <cloud_init_boot_stage> --files parameter provides.

Instead of trying to permit some command line calls to cloud-init boot stages only in certain scenarios, we will leave this feature un-deprecated as a whole until upstream can provide a functional alternative in sub-command cloud-init apply.