summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* schema: migrate apt_configure needs local schema testssingle-schema-validation-a-dChad Smith2022-01-124-315/+116
|
* schema: migrate cc_apk_configure and add schema testsChad Smith2022-01-124-103/+147
|
* tests: apt_pipelining spellingChad Smith2022-01-121-1/+1
|
* tests: apt_pipelining schema testsChad Smith2022-01-121-3/+51
|
* testsChad Smith2022-01-122-12/+21
|
* schema: warn when multiple schema files present, but use the first oneChad Smith2022-01-123-7/+79
|
* integration testChad Smith2022-01-111-2/+41
|
* schema: clarify schema warning messageChad Smith2022-01-1110-57/+73
|
* schema: annotation fixes for lists and empty schemaChad Smith2022-01-112-4/+33
| | | | | | | | Add tests for _schemapath_for_cloudconfig as it was incorrectly constructing paths prefixes for list items. Prevent concatonation of path_prefix to a key if the key is the same indent_depth as prior line.
* schema: define schema meta for cc_apt_pipeliningChad Smith2022-01-111-28/+34
|
* schema: support legacy module schema and compisite global schemaChad Smith2022-01-112-24/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ultimately cloud-init wants a single JSON schema file defining composite schema for all cc_* modules instead of each module defining it's own sub-schema. Legacy schema definitions took the form or a "schema" attribute in each cc_* module. The "new" way would be adding schema $defs to the single config/cloud-init-schema-<version> file. End goal is to publish those static composite JSON schema files to schema validation services to allow externals to consume and validate user-data before spending resources on invalid instance launches. During migration from legacy schema definitions in each cc_* module, cloudinit needs to support cc_* modules which define schema localling within the cc_* module as a "schema" attribute. - get_schema: source config/cloud-init-schema* and supplement with legacy cc_*.schema definitions to bridge gap between legacy cc_*.schema defitions and the "new" full config/cloud-init-schema. - Add support for load_doc to handle legacy and combined schema defs - get_meta_doc will validate against global composite schema when 'schema' param absent - get_meta_doc will also limit scope of documentation to the specific meta["id"] attribute as defined in global schema $defs. To allow modules to avoid passing in their own sub-schema - get_meta_doc needs to find_modules containing "meta" instead of "schema" as non-legacy schema definitions exist in config/cloud-init-schema* instead of in python dicts as a cc_*.schema attribute
* schema: deliver single JSON schema file and Paths.schema_dirChad Smith2022-01-115-485/+12
| | | | | | | - Define single JSON schema file to allow for validation of full schema for provided user-data. - Package schema file in /etc/cloud/cloud-init-1.0.json - Add Paths.schema_dir and unpickle upgrade test handling
* schema: perform validate_cloudcfg_schema once in early bootChad Smith2022-01-114-25/+557
| | | | | | | | | | Validate full schema one time early in boot just after user-data is processed. This avoid 51+ repeated calls to validate_cloudcfg_schema on subsections of the schema. Moving validation to one place against the whole schema will allow for a single concise error/warning about schema violations in one place in logs.
* Remove 3.5 and xenial support (SC-711) (#1167)James Falcon2022-01-1026-237/+137
| | | | | | | | | | | | Includes: - Update tox.ini and .travis.yml accordingly - Cleanup tox.ini with new tox syntax and cloud-init dependencies - Update documentation accordingly - Replace/remove xenial references where additional testing isn't required - Remove xenial checks in integration tests - Replace yield_fixture with fixture in pytest tests Sections of code commented with lines like "Remove when Xenial is no longer supported" still exist as they're require additional testing.
* tests: mock LXD datasource detection in ds-identify on LXD containers (#1178)Chad Smith2022-01-101-0/+10
| | | | | | | | | | On LXD containers /dev/lxd/sock will always exist. Mock dscheck_LXD to return 1 (NOT_FOUND) to avoid leaking into test environment and returning LXD as detected. We have integration tests covering proper LXD datasource detection so we don't need a Unit test validating the [ -S /dev/lxd/sock] that is in ds-identify.
* pylint: silence errors on compat code for old jsonschema (#1172)Paride Legovini2022-01-101-2/+2
|
* testing: Add 3.10 Test Coverage (#1173)Brett Holman2022-01-071-0/+1
| | | | Multiple supported distros (arch/fedora) have changed their default python version to 3.10. We should include it in the test matrix.
* Remove unittests from integration test job in travis (#1141)Brett Holman2022-01-071-1/+1
| | | | | Currently the integration test job executes unittests as part of package build. The unittests have their own jobs, so this coverage is redundant and unnecessary. Save time and remove this test.
* Don't throw exceptions for empty cloud config (#1130)Brett Holman2022-01-063-7/+67
| | | | | Warn during boot when an empty config is provided. Likewise, `cloud-init devel schema --annotate` should not throw exception, return something meaningful instead.
* bsd/resolv.d/ avoid duplicated entries (#1163)Gonéri Le Bouder2022-01-041-2/+2
| | | | Ensure we don't add duplicated nameserver or searchdomains. This can happen on OpenBSD because of dhcpleased.
* sources/azure: do not persist failed_desired_api_version flag (#1159)Chris Patterson2022-01-042-27/+45
| | | | | | | | | | | If get_imds_data_with_api_fallback() falls back to the minimum required API version, it is effectively pinned to the old API version forever. Remove the failed_desired_api_version property to prevent persistence of the flag between calls and/or reboots. The continued presence of this flag in obj.pkl should be harmless. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
* Update cc_ubuntu_advantage calls to assume-yes (#1158)John Chittum2022-01-043-7/+20
| | | | | | | | | | | cloud-init currently makes calls to ubuntu_advantage without assume-yes. some ua enable commands, such as ua enable fips, have prompts. In an automated environment, calling ua enable without --assume-yes will result in errors and not applying the change. This sets --assume-yes by default for all enable commands. This capability was added two years ago in ua commit 576e605ceb5f so should be safe for use in all systems at this time. LP: #1954842
* openbsd: properly restart the network on 7.0 (#1150)Gonéri Le Bouder2022-01-041-4/+14
| | | | OpenBSD 7.0 comes with a new service called dhcpleased to manage the DHCP requests.
* Add .git-blame-ignore-revs (#1161)James Falcon2021-12-161-0/+4
| | | So git doesn't use formatting changes for git blame
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-15441-31496/+43425
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* Include dpkg frontend lock in APT_LOCK_FILES (#1153)James Falcon2021-12-141-1/+8
|
* tests/cmd/query: fix test run as root and add coverage for defaults (#1156)Chris Patterson2021-12-141-3/+41
| | | | | | | | | | | | | | test_handle_args_error_on_invalid_vaname_paths() would fail when run as root due to invocation of load_userdata() on the default user/vendor data locations under the instance link. - Mock load_userdata() for this test case to avoid loads. - Update _setup_paths() to configure cloud_dir in temporary location. - Add new test case to verify that the default locations are loaded when unspecified. LP: #1825027 Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
* Schema processing changes (SC-676) (#1144)James Falcon2021-12-132-39/+113
| | | | | | | * Use proper logging * Add parsing for patternProperties * Add label to annotate patternProperties * Log warning if schema parsing fails during metaschema processing * Some schema test fixes
* Add dependency workaround for impish in bddeb (#1148)Brett Holman2021-12-131-0/+2
| | | | dh_systemd is now included in the default helper, no need to specify it anymore for impish
* netbsd: install new dep packages (#1151)Gonéri Le Bouder2021-12-131-0/+2
| | | | - netifaces - jsonschema
* find_devs_with_openbsd: ensure we return the last entry (#1149)Gonéri Le Bouder2021-12-132-8/+2
| | | | | | | | | | | | | | | `sysctl -n hw.disknames` returns a trailing `\n`. We need to clean this up. In addition, the criteria matching system is a source of problem because: - we don't have a way to look up the label of the partition - we've got situation where an ISO image can be exposed through a virtio block device. So we just totally ignore the value of `criteria`. We end-up with a slightly longer loop of mount-retry. But this way we're sure we don't miss a configuration disk. Tested on Kubvirt with the help of Brady Pratt @jbpratt.
* sources/azure: remove unnecessary hostname bounce (#1143)Chris Patterson2021-12-104-415/+0
| | | | | | | | | | | | | | | | | | Thanks to [1], the hostname is set prior to network bring-up. The Azure data source has been bouncing the hostname during setup(), occurring after the hostname has already been properly configured. Note that this doesn't prevent leaking the image's hostname during Azure's _get_data() when it brings up ephemeral DHCP. However, as are not guaranteed to have the hostname metadata available from a truly "local" source, this behavior is to be expected unless we disable `send host-name` from dhclient config. [1]: https://github.com/canonical/cloud-init/commit/133ad2cb327ad17b7b81319fac8f9f14577c04df Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
* find_devs/openbsd: accept ISO on disk (#1132)Gonéri Le Bouder2021-12-092-4/+5
| | | | | | | | | | | | When the metadata is an ISO image and is exposed through a disk, the device is called `/dev/sd?a` internally. For instance `/dev/sd1a`. It can then be mounted with `mount_cd9660 /dev/sd1a /mnt`. Metadata in the FAT32 format are exposed as `/dev/sd?i`. With this change, we try to mount `/dev/sd?a` in addition to `/dev/sd?i`. Closes: https://github.com/ContainerCraft/kmi/issues/12
* Improve error log message when mount failed (#1140)Ksenija Stanojevic2021-12-091-2/+4
|
* add KsenijaS as a contributor (#1145)Ksenija Stanojevic2021-12-091-0/+1
|
* travis - don't run integration tests if no deb (#1139)Brett Holman2021-12-081-3/+5
| | | | | | | If building the *.deb fails, exit Currently integration tests will run and fail with a non-obvious message. This makes it so the last thing in the logs is whatever caused the build to fail.
* factor out function for getting top level directory of cloudinit (#1136)Brett Holman2021-12-0810-30/+111
| | | | | | | | | | | | Add a test helper to get top level directory Many tests need to get the location of files & dirs within the cloud-init project directory. Tests implement this in various different ways, and often those ways depend on the current working directory of the pytest invocation. Create helper functions (and tests) that gets the path of the top directory or any sub directory under the top directory. This function does not depend on the environment.
* testing: Add deterministic test id (#1138)Brett Holman2021-12-071-1/+7
| | | | | Parametrized pytest tests get named by on their parameters. If a name has random characters, it can break the test collection of when using pytest-xdist. Replace random name with deterministic name.
* mock sleep() in azure test (#1137)Brett Holman2021-12-071-1/+2
|
* Add miraclelinux support (#1128)Haruki TSURUMOTO2021-12-0715-16/+70
|
* docs: Make MACs lowercase in network config (#1135)James Falcon2021-12-062-3/+5
| | | LP: #1876941
* Add Strict Metaschema Validation (#1101)Brett Holman2021-12-0625-291/+701
| | | | | | | | | | | | | | | | | | Improve schema validation. This adds strict validation of config module definitions at testing time, with plumbing included for future runtime validation. This eliminates a class of bugs resulting from schemas that have definitions that are incorrect, but get interpreted by jsonschema as "additionalProperties" that are therefore ignored. - Add strict meta-schema for jsonschema unit test validation - Separate schema from module metadata structure - Improve type annotations for various functions and data types Cleanup: - Remove unused jsonschema "required" elements - Eliminate manual memoization in schema.py:get_schema(), reference module.__doc__ directly
* update dead link (#1133)Brett Holman2021-12-061-1/+1
| | | Fix dead link to "contributing" page in README
* cloudinit/net: handle two different routes for the same ip (#1124)Emanuele Giuseppe Esposito2021-12-062-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | If we set a dhcp server side like this: $ cat /var/tmp/cloud-init/cloud-init-dhcp-f0rie5tm/dhcp.leases lease { ... option classless-static-routes 31.169.254.169.254 0.0.0.0,31.169.254.169.254 10.112.143.127,22.10.112.140 0.0.0.0,0 10.112.140.1; ... } cloud-init fails to configure the routes via 'ip route add' because to there are two different routes for 169.254.169.254: $ ip -4 route add 192.168.1.1/32 via 0.0.0.0 dev eth0 $ ip -4 route add 192.168.1.1/32 via 10.112.140.248 dev eth0 But NetworkManager can handle such scenario successfully as it uses "ip route append". So change cloud-init to also use "ip route append" to fix the issue: $ ip -4 route append 192.168.1.1/32 via 0.0.0.0 dev eth0 $ ip -4 route append 192.168.1.1/32 via 10.112.140.248 dev eth0 Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> RHBZ: #2003231
* docs: pin mistune dependency (#1134)James Falcon2021-12-061-0/+1
|
* Reorganize unit test locations under tests/unittests (#1126)Brett Holman2021-12-03175-1715/+1899
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This attempts to standardize unit test file location under test/unittests/ such that any source file located at cloudinit/path/to/file.py may have a corresponding unit test file at test/unittests/path/to/test_file.py. Noteworthy Comments: ==================== Four different duplicate test files existed: test_{gpg,util,cc_mounts,cc_resolv_conf}.py Each of these duplicate file pairs has been merged together. This is a break in git history for these files. The test suite appears to have a dependency on test order. Changing test order causes some tests to fail. This should be rectified, but for now some tests have been modified in tests/unittests/config/test_set_passwords.py. A helper class name starts with "Test" which causes pytest to try executing it as a test case, which then throws warnings "due to Class having __init__()". Silence by changing the name of the class. # helpers.py is imported in many test files, import paths change cloudinit/tests/helpers.py -> tests/unittests/helpers.py # Move directories: cloudinit/distros/tests -> tests/unittests/distros cloudinit/cmd/devel/tests -> tests/unittests/cmd/devel cloudinit/cmd/tests -> tests/unittests/cmd/ cloudinit/sources/helpers/tests -> tests/unittests/sources/helpers cloudinit/sources/tests -> tests/unittests/sources cloudinit/net/tests -> tests/unittests/net cloudinit/config/tests -> tests/unittests/config cloudinit/analyze/tests/ -> tests/unittests/analyze/ # Standardize tests already in tests/unittests/ test_datasource -> sources test_distros -> distros test_vmware -> sources/vmware test_handler -> config # this contains cloudconfig module tests test_runs -> runs
* Fix exception when no activator found (#1129)James Falcon2021-12-023-4/+14
| | | | | | | | Given that there are additional network management tools that we haven't yet supported with activators, we should log a warning and continue without network activation here, especially since this was a no-op for years. LP: #1948681
* jinja: provide and document jinja-safe key aliases in instance-data (SC-622) ↵Chad Smith2021-12-029-137/+326
| | | | | | | | | | | | | | | | | | | | (#1123) Allow #cloud-config and cloud-init query to use underscore-delimited "jinja-safe" key aliases for any instance-data.json keys containing jinja operator characters. This provides a means to use Jinja's dot-notation instead of square brackets and quoting to reference "unsafe" obtain attribute names. Support for these aliased keys is available to both #cloud-config user-data and `cloud-init query`. For example #cloud-config alias access can look like: {{ ds.config.user_network_config }} - instead of - {{ ds.config["user.network-config"] }}
* testing: Remove date from final_message test (SC-638) (#1127)James Falcon2021-12-021-13/+6
|
* Move GCE metadata fetch to init-local (SC-502) (#1122)James Falcon2021-12-024-4/+87
| | | | | | GCE currently fetches metadata after network has come up. There's no reason we can't fetch at init-local time, so update GCE to fetch at init-local time to be more performant and consistent with other datasources.