Skip to content

Conversation

@simondeziel
Copy link
Member

No description provided.

@simondeziel simondeziel requested a review from Copilot July 25, 2025 18:44

This comment was marked as outdated.

@simondeziel simondeziel changed the title Instance utils unit tests lxd/instance: Allow setting lxc.net config keys through raw.lxc (from Incus) Jul 25, 2025
@simondeziel simondeziel force-pushed the instance-utils-unit-tests branch 2 times, most recently from 9fc5ed6 to 319d3fe Compare July 25, 2025 19:06
@simondeziel simondeziel requested a review from Copilot July 25, 2025 19:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR allows setting lxc.net config keys through raw.lxc configuration by removing previous restrictions. The change originates from Incus and enables broader network configuration options for LXD instances.

Key changes:

  • Removes validation restrictions on lxc.net.* configuration keys
  • Improves MAC address generation using a more efficient approach
  • Modernizes string splitting using strings.Cut instead of strings.SplitN

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lxd/instance/instance_utils.go Removes network config restrictions, updates string parsing and MAC generation
lxd/instance/instance_utils_test.go Adds comprehensive test coverage for parsing and validation functions
Comments suppressed due to low confidence (2)

lxd/instance/instance_utils_test.go:64

  • The error message says "Expected empty key" but this assertion is checking if the actual key matches the expected key, not if it's empty. The message should be "Expected key to match for test case: %s"
		assert.Equal(t, test.key, key, "Expected empty key for test case: %s", test.name)

lxd/instance/instance_utils_test.go:65

  • The error message says "Expected empty value" but this assertion is checking if the actual value matches the expected value, not if it's empty. The message should be "Expected value to match for test case: %s"
		assert.Equal(t, test.val, val, "Expected empty value for test case: %s", test.name)

@simondeziel simondeziel force-pushed the instance-utils-unit-tests branch from 229fc9f to e15341f Compare July 25, 2025 19:15
simondeziel and others added 4 commits July 25, 2025 15:17
It's still usually a bad idea but there's no strong need to special case
those vs the rest.

Signed-off-by: Stéphane Graber <[email protected]>
(cherry picked from commit e13e674dae437564eb25e59b9145bf18a81d8171)
Signed-off-by: Simon Deziel <[email protected]>
License: Apache-2.0
@simondeziel simondeziel force-pushed the instance-utils-unit-tests branch from e15341f to fff3494 Compare July 25, 2025 19:17
@simondeziel simondeziel force-pushed the instance-utils-unit-tests branch from fff3494 to de9b51b Compare July 25, 2025 19:24
@simondeziel simondeziel marked this pull request as ready for review July 25, 2025 20:34
@simondeziel simondeziel requested a review from tomponline July 25, 2025 20:36
@tomponline
Copy link
Member

@simondeziel whats the reason behind needing this?

@skozina should we be adding more raw.* support for specific container runtimes?

@skozina
Copy link
Contributor

skozina commented Aug 4, 2025

Yup, I thought we want to limit the number of low-level tunables in general, to avoid the cases when LXD lags behind the latest changes in the lower layer configs. Curious to hear more about the need here.

@simondeziel
Copy link
Member Author

@simondeziel whats the reason behind needing this?

Saw this pass by and found the (dropped) validation could have been done more efficiently. Since this was only reachable via raw.lxc, I felt it was OK to allow for more exotic config which are outside of the supported path anyway.

@simondeziel
Copy link
Member Author

@skozina should we be adding more raw.* support for specific container runtimes?

It's no adding support for more top level raw.* key but about relaxing the constraints on what you can do with the existing raw.lxc key.

@tomponline
Copy link
Member

@simondeziel thanks, is this needed for something you're working on?

@simondeziel
Copy link
Member Author

@simondeziel thanks, is this needed for something you're working on?

No. It seems like you have reasons not to want the cherry-pick which is fine with me (I just don't know why but that's OK :)
Should I drop the single cherry-pick from the PR and keep the rest which is mostly tests.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

As this has plenty of tests and the actual liblxc integration change removes code I'm going to go ahead with the merge. Thanks!

@tomponline tomponline merged commit daf4d95 into canonical:main Aug 7, 2025
31 checks passed
@simondeziel simondeziel deleted the instance-utils-unit-tests branch August 7, 2025 15:20
@skozina
Copy link
Contributor

skozina commented Aug 8, 2025

Sound good to me. Considering this is an existing unsupported tunnable, there's really no need to have the explicit restrictions for the IP address only.

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.

4 participants