@@ -523,28 +523,27 @@ func (s *clusterImpl) Delete(ctx context.Context, req *v1.ResourceByID) (*empty.
523
523
return nil , err
524
524
}
525
525
526
- log .Infow ("resuming argo workflow" , "workflow-name" , workflow .GetName ())
527
-
528
- // Resume the workflow so that it may move to the destroy phase without
529
- // waiting for cleanupExpiredClusters() to kick in.
530
- _ , err = s .argoWorkflowsClient .ResumeWorkflow (s .argoClientCtx , & workflowpkg.WorkflowResumeRequest {
531
- Name : workflow .GetName (),
532
- Namespace : s .workflowNamespace ,
533
- })
534
- if err != nil {
535
- log .Warnw ("failed to resume workflow, this is OK if the workflow is not waiting" ,
536
- "workflow-name" , req .GetId (),
537
- "error" , err ,
538
- )
539
- }
540
- if value , exists := workflow .GetLabels ()["needsExit" ]; exists {
541
- log .Infow ("argo workflow requires exit to stop looping" , "needsExit" , value )
526
+ if workflow .Spec .Suspend != nil && * workflow .Spec .Suspend {
527
+ // Resume the workflow so that it may move to the destroy phase without
528
+ // waiting for cleanupExpiredClusters() to kick in.
529
+ log .Infow ("resuming argo workflow" , "workflow-name" , workflow .GetName ())
530
+ _ , err = s .argoWorkflowsClient .ResumeWorkflow (s .argoClientCtx , & workflowpkg.WorkflowResumeRequest {
531
+ Name : workflow .GetName (),
532
+ Namespace : s .workflowNamespace ,
533
+ })
534
+ if err != nil {
535
+ log .Warnw ("failed to resume workflow, this is OK if the workflow is not waiting" ,
536
+ "workflow-name" , req .GetId (),
537
+ "error" , err ,
538
+ )
539
+ }
540
+ } else {
542
541
log .Infow ("stopping argo workflow" , "workflow-name" , workflow .GetName ())
543
542
_ , err = s .argoWorkflowsClient .StopWorkflow (s .argoClientCtx , & workflowpkg.WorkflowStopRequest {
544
543
Name : workflow .GetName (),
545
544
Namespace : s .workflowNamespace ,
546
545
NodeFieldSelector : "" ,
547
- Message : "Seeking end " ,
546
+ Message : "Destroying cluster. End workflow loop. " ,
548
547
})
549
548
if err != nil {
550
549
log .Warnw ("failed to stop workflow, this is OK if the workflow is not running" ,
@@ -663,13 +662,29 @@ func (s *clusterImpl) cleanupExpiredClusters() {
663
662
continue
664
663
}
665
664
666
- log .Infow ("resuming an argo workflow that has expired" , "workflow-name" , workflow .GetName ())
667
- _ , err = s .argoWorkflowsClient .ResumeWorkflow (s .argoClientCtx , & workflowpkg.WorkflowResumeRequest {
668
- Name : workflow .GetName (),
669
- Namespace : s .workflowNamespace ,
670
- })
671
- if err != nil {
672
- log .Warnw ("failed to resume argo workflow" , "workflow-name" , workflow .GetName (), "error" , err )
665
+ if workflow .Spec .Suspend != nil && * workflow .Spec .Suspend {
666
+ log .Infow ("resuming an argo workflow that has expired" , "workflow-name" , workflow .GetName ())
667
+ _ , err = s .argoWorkflowsClient .ResumeWorkflow (s .argoClientCtx , & workflowpkg.WorkflowResumeRequest {
668
+ Name : workflow .GetName (),
669
+ Namespace : s .workflowNamespace ,
670
+ })
671
+ if err != nil {
672
+ log .Warnw ("failed to resume argo workflow" , "workflow-name" , workflow .GetName (), "error" , err )
673
+ }
674
+ } else {
675
+ log .Infow ("stopping argo workflow that expired" , "workflow-name" , workflow .GetName ())
676
+ _ , err = s .argoWorkflowsClient .StopWorkflow (s .argoClientCtx , & workflowpkg.WorkflowStopRequest {
677
+ Name : workflow .GetName (),
678
+ Namespace : s .workflowNamespace ,
679
+ NodeFieldSelector : "" ,
680
+ Message : "Destroying cluster. End workflow loop." ,
681
+ })
682
+ if err != nil {
683
+ log .Warnw ("failed to stop workflow, this is OK if the workflow is not running" ,
684
+ "workflow-name" , req .GetId (),
685
+ "error" , err ,
686
+ )
687
+ }
673
688
}
674
689
}
675
690
0 commit comments