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 {