Skip to content

lxd: add preference for LXD cloud-init.* config keys over user keys#1108

Merged
blackboxsw merged 3 commits into
canonical:mainfrom
blackboxsw:lxd-ds
Nov 18, 2021
Merged

lxd: add preference for LXD cloud-init.* config keys over user keys#1108
blackboxsw merged 3 commits into
canonical:mainfrom
blackboxsw:lxd-ds

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

Proposed Commit Message

lxd: add preference for LXD cloud-init.* config keys over user keys

LXD now adds cloud-init scoped configuration keys network-config,
user-data and vendor-data. The existing user.user-data,
user.vendor-data, user.network-config and meta-data will be
deprecated in newer LXD.

cloud-init will prefer LXD config keys cloud-init.* keys above
user.* keys even if both are present.

Expectation is that the configuration user.network-config,
user.meta-data, user.user-data and user.vendor-data* keys should
not be present at the same time as the comparable cloud-init.* keys.

Also drop awareness of user.network_mode as this was deprecated
from LXD 2.1.

Additional Context

Test Steps

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Only major comment is the warning.

# the dict path {LXD_SOCKET_API_VERSION: {config: {...}}.
response = session.get(config_url)
LOG.debug("[GET] [HTTP:%d] %s", response.status_code, config_url)
if not response.ok:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice additional error checking in this section

Comment thread cloudinit/sources/DataSourceLXD.py
Comment thread cloudinit/sources/DataSourceLXD.py
assert 0 == m_lstat.call_count


class TestReadMetadata:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how this test is structured.

@blackboxsw blackboxsw force-pushed the lxd-ds branch 2 times, most recently from aa59b2c to b4e79b9 Compare November 18, 2021 20:45
LXD now adds cloud-init scoped configuration keys network-config,
user-data and vendor-data. The existing user.user-data,
user.vendor-data, user.network-config and meta-data will be
deprecated in newer LXD.

cloud-init will prefer LXD config keys cloud-init.* keys above
user.* keys even if both are present.

Expectation is that the configuration user.network-config,
user.meta-data, user.user-data and user.vendor-data* keys should
not be present at the same time as the comparable cloud-init.* keys.
Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@blackboxsw blackboxsw merged commit 7ebf04e into canonical:main Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants