From cee997e0b38e3bc3207feb1d9b80f7b8ab1d5c49 Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:10:28 -0300 Subject: [PATCH] fix(edgestacks): reorder operations to properly update the endpoint relations BE-11233 (#12239) --- api/internal/edge/edgestacks/service.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/internal/edge/edgestacks/service.go b/api/internal/edge/edgestacks/service.go index a000fdd79..4fc6943af 100644 --- a/api/internal/edge/edgestacks/service.go +++ b/api/internal/edge/edgestacks/service.go @@ -101,14 +101,14 @@ func (service *Service) PersistEdgeStack( stack.EntryPoint = composePath stack.NumDeployments = len(relatedEndpointIds) - if err := service.updateEndpointRelations(tx, stack.ID, relatedEndpointIds); err != nil { - return nil, fmt.Errorf("unable to update endpoint relations: %w", err) - } - if err := tx.EdgeStack().Create(stack.ID, stack); err != nil { return nil, err } + if err := service.updateEndpointRelations(tx, stack.ID, relatedEndpointIds); err != nil { + return nil, fmt.Errorf("unable to update endpoint relations: %w", err) + } + return stack, nil }