Skip to content

Conversation

@kadinsayani
Copy link
Member

This PR fixes the following regression:
https://github.com/canonical/lxd-ci/actions/runs/12367790805/job/34516721509#step:11:93.

We always need to check config keys applied to VM's to ensure container-specific prefixed keys are disallowed.

@kadinsayani kadinsayani changed the title lxd/instance: Move check for container-specific prefixed keys applied to VMs up VM: Move check for container-specific prefixed keys applied to VMs up Dec 17, 2024

// Check if the key is a valid prefix and whether or not it requires a subkey.
knownPrefixes := append(instancetype.ConfigKeyPrefixesAny, instancetype.ConfigKeyPrefixesContainer...)
if strings.HasSuffix(key, ".") {
Copy link
Member

@simondeziel simondeziel Dec 17, 2024

Choose a reason for hiding this comment

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

Shouldn't we simply reject anything that ends with a trailing . as that's never going to be a valid config key anyway so why bother doing more checks?

Copy link
Member Author

@kadinsayani kadinsayani Dec 17, 2024

Choose a reason for hiding this comment

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

We can do that, however, the additional check allows us to return more specific error messages:
"Unknown configuration key: %q" if the key is not known and "%q requires a subkey" if the key is known but missing a subkey. Also, the check is pretty inexpensive computationally since the knownPrefixes slice is only 5 elements.

@tomponline tomponline merged commit e19037e into canonical:main Dec 17, 2024
26 checks passed
@kadinsayani kadinsayani deleted the config-key-validation-fix branch April 22, 2025 13:18
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.

3 participants