From dd7b99ed41424c3e86cf4fbd245648527088de63 Mon Sep 17 00:00:00 2001 From: Din Music Date: Thu, 5 Dec 2024 08:53:37 +0000 Subject: [PATCH] lxd/instance/instance_utils: Fix detection of suitable architecture when LXD is clustered Signed-off-by: Din Music --- lxd/instance/instance_utils.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lxd/instance/instance_utils.go b/lxd/instance/instance_utils.go index ef394074e927..886160dba288 100644 --- a/lxd/instance/instance_utils.go +++ b/lxd/instance/instance_utils.go @@ -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 != "" { id, err := osarch.ArchitectureId(req.Architecture) if err != nil { return nil, err @@ -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.