Skip to content

Add pro feature flag (stable-4.0)#17703

Merged
tomponline merged 6 commits intocanonical:stable-4.0from
simondeziel:pro-stable-4.0
Feb 20, 2026
Merged

Add pro feature flag (stable-4.0)#17703
tomponline merged 6 commits intocanonical:stable-4.0from
simondeziel:pro-stable-4.0

Conversation

@simondeziel
Copy link
Copy Markdown
Member

No description provided.

simondeziel and others added 6 commits February 19, 2026 18:47
Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit 5f6ff2c)
Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit 4106bd3)
Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit 6568ac5)
Signed-off-by: Stéphane Graber <[email protected]>
(cherry picked from commit bb0d433)
License: Apache-2.0
Copy link
Copy Markdown

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 adds support for detecting Ubuntu Pro attachment status and advertising it through the LXD user agent. The implementation checks if the host is running Ubuntu and is attached to an Ubuntu Pro subscription, then adds a "pro" feature flag to the user agent string.

Changes:

  • Modified UserAgentFeatures to validate inputs and return errors, with behavior change from assignment to append
  • Added new ubuntupro package to detect Ubuntu Pro attachment status via CLI
  • Integrated Ubuntu Pro detection into daemon initialization using OS release information

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
shared/version/useragent.go Added input validation for whitespace in features and changed error handling from void to error return; changed behavior from assignment to append
lxd/ubuntupro/client.go New client implementation for checking Ubuntu Pro attachment status via CLI
lxd/ubuntupro/client_test.go Comprehensive tests for Ubuntu Pro client functionality
lxd/sys/os.go Added ReleaseInfo field to store OS release information from /etc/os-release
lxd/daemon.go Integrated Ubuntu Pro client in daemon Ready() method; updated UserAgentFeatures error handling
lxd/api_cluster.go Updated UserAgentFeatures calls to handle new error return value

// Determine if the host is attached to Ubuntu Pro and update the user agent accordingly.
isAttached, err := s.pro.isHostAttached()
if err != nil {
logger.Debug("Failed to check if host is Ubuntu Pro attached")
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The logger.Debug call should include the error in the log context for better debugging. Based on patterns in the codebase (e.g., lxd/daemon_images.go:243, lxd/images.go:1684), errors should be logged using log.Ctx. You'll need to import log "gopkg.in/inconshreveable/log15.v2" and then use: logger.Debug("Failed to check if host is Ubuntu Pro attached", log.Ctx{"err": err})

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +63
func UserAgentFeatures(features []string) error {
for _, feature := range features {
if strings.IndexFunc(feature, unicode.IsSpace) >= 0 {
return errors.New("User agent features may not contain whitespace")
}
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The new whitespace validation in UserAgentFeatures lacks test coverage. Given that the shared/version package has comprehensive tests (version_test.go), the new validation logic should be tested. Consider adding tests that verify:

  1. Features without whitespace are accepted
  2. Features with spaces, tabs, newlines, etc. are rejected
  3. The error message is correct
  4. Multiple features can be added successfully

Copilot uses AI. Check for mistakes.
@simondeziel simondeziel marked this pull request as ready for review February 20, 2026 14:03
@tomponline tomponline merged commit c00de89 into canonical:stable-4.0 Feb 20, 2026
57 of 60 checks passed
@simondeziel simondeziel deleted the pro-stable-4.0 branch February 20, 2026 19:40
tomponline added a commit to tomponline/lxd-pkg-snap that referenced this pull request Mar 6, 2026
tomponline added a commit to canonical/lxd-pkg-snap that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants