From ebc25e45d3c4271c582764446a77bb0d5f51e0e5 Mon Sep 17 00:00:00 2001 From: Oscar Zhou <100548325+oscarzhou-portainer@users.noreply.github.com> Date: Sat, 12 Apr 2025 10:24:23 +1200 Subject: [PATCH] fix(edge): redeploy edge stack doesn't apply to std agents [BE-11766] (#633) --- api/dataservices/endpointrelation/tx.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/dataservices/endpointrelation/tx.go b/api/dataservices/endpointrelation/tx.go index 2b2d90280..bc58678fd 100644 --- a/api/dataservices/endpointrelation/tx.go +++ b/api/dataservices/endpointrelation/tx.go @@ -93,6 +93,10 @@ func (service ServiceTx) AddEndpointRelationsForEdgeStack(endpointIDs []portaine } } + service.service.mu.Lock() + service.service.endpointRelationsCache = nil + service.service.mu.Unlock() + if err := service.service.updateStackFnTx(service.tx, edgeStackID, func(edgeStack *portainer.EdgeStack) { edgeStack.NumDeployments += len(endpointIDs) }); err != nil { @@ -119,6 +123,10 @@ func (service ServiceTx) RemoveEndpointRelationsForEdgeStack(endpointIDs []porta } } + service.service.mu.Lock() + service.service.endpointRelationsCache = nil + service.service.mu.Unlock() + if err := service.service.updateStackFnTx(service.tx, edgeStackID, func(edgeStack *portainer.EdgeStack) { edgeStack.NumDeployments -= len(endpointIDs) }); err != nil {