Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/pipeline/CdHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/go-pg/pg"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
"k8s.io/client-go/rest"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -600,10 +601,13 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int,
} else if workflowRunner.WorkflowType == POST {
isExtCluster = pipeline.RunPostStageInEnv
}
restConfig, err := impl.k8sUtil.GetRestConfigByCluster(clusterConfig)
if err != nil {
impl.Logger.Errorw("error in getting rest config by cluster id", "err", err)
return 0, err
var restConfig *rest.Config
if isExtCluster {
restConfig, err = impl.k8sUtil.GetRestConfigByCluster(clusterConfig)
if err != nil {
impl.Logger.Errorw("error in getting rest config by cluster id", "err", err)
return 0, err
}
}
// Terminate workflow
err = impl.workflowService.TerminateWorkflow(workflowRunner.ExecutorType, workflowRunner.Name, workflowRunner.Namespace, restConfig, isExtCluster, nil)
Expand Down
3 changes: 3 additions & 0 deletions pkg/pipeline/WorkflowService.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func (impl *WorkflowServiceImpl) TerminateWorkflow(executorType pipelineConfig.W
var err error
if executorType != "" {
workflowExecutor := impl.getWorkflowExecutor(executorType)
if restConfig == nil {
restConfig = impl.config
}
err = workflowExecutor.TerminateWorkflow(name, namespace, restConfig)
} else {
wfClient, err := impl.getWfClient(environment, namespace, isExt)
Expand Down