Skip to content

Commit a33aa47

Browse files
fix(edge-agent): remove redundant status updates [BE-11683] (#497)
1 parent d13279b commit a33aa47

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

edge/poll_async.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,35 +259,21 @@ func (service *PollService) processEdgeStackCommand(ctx context.Context, command
259259
return newOperationError("stack", command.Operation, err)
260260
}
261261

262-
if err := service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusAcknowledged, stackData.RollbackTo, ""); err != nil {
263-
return newOperationError("stack", command.Operation, err)
264-
}
265-
266262
switch command.Operation {
267263
case "add", "replace":
268264
if err := service.edgeStackManager.DeployStack(ctx, stackData); err != nil {
269265
return service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusError, stackData.RollbackTo, fmt.Errorf("failed to deploy async stack: %w", err).Error())
270266
}
271-
272-
if err := service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusDeploying, stackData.RollbackTo, ""); err != nil {
273-
return newOperationError("stack", command.Operation, err)
274-
}
275-
276267
case "remove":
277-
if err := service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusRemoving, stackData.RollbackTo, ""); err != nil {
278-
return newOperationError("stack", command.Operation, err)
279-
}
280-
281268
if err := service.edgeStackManager.DeleteStack(ctx, stackData); err != nil {
282269
return service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusError, stackData.RollbackTo, fmt.Errorf("failed to delete async stack: %w", err).Error())
283270
}
284-
285-
if err := service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusRemoved, stackData.RollbackTo, ""); err != nil {
286-
return newOperationError("stack", command.Operation, err)
287-
}
288-
289271
default:
290-
return newOperationError("schedule", command.Operation, errors.New("operation not supported"))
272+
return service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusError, stackData.RollbackTo, fmt.Errorf("operation not supported: %s", command.Operation).Error())
273+
}
274+
275+
if err := service.portainerClient.SetEdgeStackStatus(stackData.ID, stackData.Version, portainer.EdgeStackStatusAcknowledged, stackData.RollbackTo, ""); err != nil {
276+
return newOperationError("stack", command.Operation, err)
291277
}
292278

293279
return nil

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ require (
143143
github.com/miekg/dns v1.1.50 // indirect
144144
github.com/miekg/pkcs11 v1.1.1 // indirect
145145
github.com/mitchellh/go-homedir v1.1.0 // indirect
146+
github.com/mitchellh/go-ps v1.0.0 // indirect
146147
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
147148
github.com/moby/buildkit v0.17.2 // indirect
148149
github.com/moby/docker-image-spec v1.3.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT
433433
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
434434
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
435435
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
436+
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
437+
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
436438
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
437439
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
438440
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=

0 commit comments

Comments
 (0)