forked from canonical/cloud-init
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(schema): only write network-config if instance dir present (canon…
…ical#4635) Only write /var/lib/cloud/instance/network-config.json once datasource is detected. The /var/lib/clound/instance symlink is created by Init.instancify after datasource detection is complete. Migrate creation of /var/lib/cloud/instance/network-config.json out of apply_network_config and into instancify, after the datasource is detected. This fixes a bug by ensuring /var/lib/cloud/instance exists before persisting /v/l/cloud/instance/network-config.json. Fixes canonicalGH-4630
- Loading branch information
1 parent
05f039c
commit 15a38b8
Showing
5 changed files
with
129 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""NoCloud datasource integration tests.""" | ||
import json | ||
|
||
import pytest | ||
from pycloudlib.lxd.instance import LXDInstance | ||
|
||
from tests.integration_tests.decorators import retry | ||
from tests.integration_tests.instances import IntegrationInstance | ||
from tests.integration_tests.integration_settings import PLATFORM | ||
from tests.integration_tests.util import verify_clean_log | ||
|
||
DS_NONE_BASE_CFG = """\ | ||
datasource_list: [None] | ||
datasource: | ||
None: | ||
metadata: | ||
instance-id: my-iid-uuid | ||
userdata_raw: | | ||
#cloud-config | ||
runcmd: | ||
- touch /var/tmp/success-with-datasource-none | ||
""" | ||
|
||
LXD_METADATA_DS_NONE_BASE_CFG = """\ | ||
/etc/cloud/cloud.cfg.d/99-force-dsnone.cfg: | ||
when: | ||
- create | ||
- copy | ||
create_only: false | ||
template: dsnone.tpl | ||
properties: {} | ||
""" | ||
|
||
|
||
@retry(tries=30, delay=1) | ||
def wait_for_cloud_init_status_file(instance: LXDInstance): | ||
status_file = instance.read_from_file("/run/cloud-init/status.json") | ||
assert len(status_file) | ||
|
||
|
||
@pytest.mark.lxd_use_exec | ||
@pytest.mark.skipif( | ||
PLATFORM != "lxd_container", | ||
reason="Requires LXD container with custom metadata setup", | ||
) | ||
def test_datasource_none_discovery(client: IntegrationInstance): | ||
"""Integration test for #4635. | ||
Test that DataSourceNone detection (used by live installers) doesn't | ||
generate errors or warnings. | ||
""" | ||
log = client.read_from_file("/var/log/cloud-init.log") | ||
verify_clean_log(log) | ||
# Limit datasource detection to DataSourceNone. | ||
client.write_to_file( | ||
"/etc/cloud/cloud.cfg.d/99-force-dsnone.cfg", DS_NONE_BASE_CFG | ||
) | ||
client.execute("cloud-init clean --logs --reboot") | ||
wait_for_cloud_init_status_file(client) | ||
status = json.loads(client.execute("cloud-init status --format=json")) | ||
assert [] == status["errors"] | ||
assert {} == status["recoverable_errors"] | ||
client.execute("cloud-init status --wait") | ||
assert client.execute("test -f /var/tmp/success-with-datasource-none").ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters