Skip to content

Commit

Permalink
lxd/instance: Move check for container-specific prefixed keys applied…
Browse files Browse the repository at this point in the history
… to VMs up

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

Signed-off-by: Kadin Sayani <[email protected]>
  • Loading branch information
kadinsayani committed Dec 17, 2024
1 parent d537da4 commit 5651d63
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lxd/instance/instance_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ func ValidConfig(sysOS *sys.OS, config map[string]string, expanded bool, instanc
}

func validConfigKey(os *sys.OS, key string, value string, instanceType instancetype.Type) error {
// Disallow keys with container-specific prefixes such as "linux.sysctl." and "limits.kernel." for VMs.
if instanceType == instancetype.VM && shared.StringHasPrefix(key, instancetype.ConfigKeyPrefixesContainer...) {
return fmt.Errorf("%q isn't supported for %q", key, instanceType)
}

// 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, ".") {
// Disallow keys with container-specific prefixes such as "linux.sysctl." and "limits.kernel." for VMs.
if instanceType == instancetype.VM && shared.StringHasPrefix(key, instancetype.ConfigKeyPrefixesContainer...) {
return fmt.Errorf("%q isn't supported for %q", key, instanceType)
}

if !(key == instancetype.ConfigVolatilePrefix || shared.ValueInSlice(key, knownPrefixes)) {
// Not a known prefix.
return fmt.Errorf("Unknown configuration key: %q", key)
Expand Down

0 comments on commit 5651d63

Please sign in to comment.