LP: #2020397 - Opt-out for custom image dependency validation
Some custom images might not have any package manager at all,
thus fail the (curtin) late commands on deployment for custom
image dependency validation (cloud-init and netplan packages).
Even though these checks may be perceived as a regression in
such cases, it is likely better to keep them by default, for
more robust checks/assertions on deployment vs. boot errors.
As a workaround, users could add late commands to create/remove
symlinks of the package manager command to /bin/true to fake it,
but that is hacky, and might fail after source code changes.
So, let's provide a way for these users to opt-out of custom
image dependency validation with the curtin_userdata preseed
(since these checks are introduced as curtin late commands),
in an upstream-maintained manner.
In the curtin_userdata preseed/template, introduce this line:
custom_validation: 0
This would seem better than introducing per-custom image
properties (database changes involved, probably) or some
CLI/UI changes and pipe them to the deployment functions.
Tests
=====
Steps: download centos70 image, upload as custom, deploy.
Default:
start: cmd-install/stage-late: executing late commands
start: cmd-install/stage-late/98-validate-custom-image-has-cloud-init: running 'curtin in-target -- bash -c dpkg-query -s cloud-init || (echo "cloud-init not detected, ..." && exit 1)'
...
bash: dpkg-query: command not found
cloud-init not detected, MAAS will not be able to configure this machine properly
...
98-validate-custom-image-has-cloud-init command failed
finish: cmd-install/stage-late/98-validate-custom-image-has-cloud-init: FAIL: running 'curtin in-target -- bash -c dpkg-query -s cloud-init || (echo "cloud-init not detected, ..." && exit 1)'
...
finish: cmd-install/stage-late: FAIL: executing late commands
curtin: Installation failed with exception: Unexpected error while running command.
Opt-out:
start: cmd-install/stage-late: executing late commands
...
finish: cmd-install/stage-late: SUCCESS: executing late commands
curtin: Installation finished.
Unit tests:
$ make install-dependencies
$ make bin/pytest
$ bin/pytest src/maasserver/tests/test_preseed.py -k TestGetCustomImageDependencyValidation -v --no-header --no-summary
...
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_custom_centos PASSED [ 14%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_custom_rhel PASSED [ 28%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_custom_ubuntu PASSED [ 42%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_linuxes PASSED [ 57%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_linuxes_skip_zero PASSED [ 71%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_linuxes_skip_zero_only PASSED [ 85%]
src/maasserver/tests/test_preseed.py::TestGetCustomImageDependencyValidation::test_validation_for_non_custom PASSED [100%]
...
Signed-off-by: Mauricio Faria de Oliveira <email address hidden>
UNIT TESTS
-b lp2020397-opt-out lp:~mfo/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED maas-ci. internal: 8080/job/ maas-tester/ 2661/console 138c592eaea0806 b2d38fc072
LOG: http://
COMMIT: 26be7fdf406b47d