@@ -259,35 +259,21 @@ func (service *PollService) processEdgeStackCommand(ctx context.Context, command
259
259
return newOperationError ("stack" , command .Operation , err )
260
260
}
261
261
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
-
266
262
switch command .Operation {
267
263
case "add" , "replace" :
268
264
if err := service .edgeStackManager .DeployStack (ctx , stackData ); err != nil {
269
265
return service .portainerClient .SetEdgeStackStatus (stackData .ID , stackData .Version , portainer .EdgeStackStatusError , stackData .RollbackTo , fmt .Errorf ("failed to deploy async stack: %w" , err ).Error ())
270
266
}
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
-
276
267
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
-
281
268
if err := service .edgeStackManager .DeleteStack (ctx , stackData ); err != nil {
282
269
return service .portainerClient .SetEdgeStackStatus (stackData .ID , stackData .Version , portainer .EdgeStackStatusError , stackData .RollbackTo , fmt .Errorf ("failed to delete async stack: %w" , err ).Error ())
283
270
}
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
-
289
271
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 )
291
277
}
292
278
293
279
return nil
0 commit comments