Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of suitable architecture for conversion when LXD is clustered #14586

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lxd/instance/instance_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func ResolveImage(ctx context.Context, tx *db.ClusterTx, projectName string, sou
// A nil list indicates that we can't tell at this stage, typically for private images.
func SuitableArchitectures(ctx context.Context, s *state.State, tx *db.ClusterTx, projectName string, sourceInst *cluster.Instance, sourceImageRef string, req api.InstancesPost) ([]int, error) {
// Handle cases where the architecture is already provided.
if shared.ValueInSlice(req.Source.Type, []string{"migration", "none"}) && req.Architecture != "" {
if shared.ValueInSlice(req.Source.Type, []string{"conversion", "migration", "none"}) && req.Architecture != "" {
Copy link
Member

Choose a reason for hiding this comment

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

As a separate PR please can we have constants created for these values so we can see where they are referenced in the code.

id, err := osarch.ArchitectureId(req.Architecture)
if err != nil {
return nil, err
Expand All @@ -556,9 +556,9 @@ func SuitableArchitectures(ctx context.Context, s *state.State, tx *db.ClusterTx
return []int{id}, nil
}

// For migration, an architecture must be specified in the req.
if req.Source.Type == "migration" && req.Architecture == "" {
return nil, api.StatusErrorf(http.StatusBadRequest, "An architecture must be specified in migration requests")
// For migration and conversion, an architecture must be specified in the req.
if shared.ValueInSlice(req.Source.Type, []string{"conversion", "migration"}) && req.Architecture == "" {
return nil, api.StatusErrorf(http.StatusBadRequest, "An architecture must be specified in migration or conversion requests")
}

// For none, allow any architecture.
Expand Down
Loading