Skip to content

Commit 2335f1f

Browse files
committed
panic recovered go-routines
1 parent 65e1424 commit 2335f1f

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

client/argocdServer/connection/Connection.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"github.com/argoproj/argo-cd/v2/pkg/apiclient/account"
2323
"github.com/argoproj/argo-cd/v2/util/settings"
24+
"github.com/devtron-labs/common-lib/async"
2425
"github.com/devtron-labs/common-lib/utils/k8s"
2526
"github.com/devtron-labs/devtron/client/argocdServer/bean"
2627
config2 "github.com/devtron-labs/devtron/client/argocdServer/config"
@@ -81,6 +82,7 @@ type ArgoCDConnectionManagerImpl struct {
8182
gitOpsConfigReadService config.GitOpsConfigReadService
8283
runTimeConfig *k8s.RuntimeConfig
8384
argoCDConfigGetter config2.ArgoCDConfigGetter
85+
asyncRunnable *async.Runnable
8486
}
8587

8688
func NewArgoCDConnectionManagerImpl(Logger *zap.SugaredLogger,
@@ -92,7 +94,8 @@ func NewArgoCDConnectionManagerImpl(Logger *zap.SugaredLogger,
9294
versionService version.VersionService,
9395
gitOpsConfigReadService config.GitOpsConfigReadService,
9496
runTimeConfig *k8s.RuntimeConfig,
95-
argoCDConfigGetter config2.ArgoCDConfigGetter) (*ArgoCDConnectionManagerImpl, error) {
97+
argoCDConfigGetter config2.ArgoCDConfigGetter,
98+
asyncRunnable *async.Runnable) (*ArgoCDConnectionManagerImpl, error) {
9699
argoUserServiceImpl := &ArgoCDConnectionManagerImpl{
97100
logger: Logger,
98101
settingsManager: settingsManager,
@@ -105,13 +108,17 @@ func NewArgoCDConnectionManagerImpl(Logger *zap.SugaredLogger,
105108
gitOpsConfigReadService: gitOpsConfigReadService,
106109
runTimeConfig: runTimeConfig,
107110
argoCDConfigGetter: argoCDConfigGetter,
111+
asyncRunnable: asyncRunnable,
108112
}
109113
if !runTimeConfig.LocalDevMode {
110114
grpcConfig, err := argoCDConfigGetter.GetGRPCConfig()
111115
if err != nil {
112116
Logger.Errorw("error in GetAllGRPCConfigs", "error", err)
113117
}
114-
go argoUserServiceImpl.ValidateGitOpsAndGetOrUpdateArgoCdUserDetail(grpcConfig)
118+
runnableFunc := func() {
119+
argoUserServiceImpl.ValidateGitOpsAndGetOrUpdateArgoCdUserDetail(grpcConfig)
120+
}
121+
asyncRunnable.Execute(runnableFunc)
115122
}
116123
return argoUserServiceImpl, nil
117124
}

pkg/build/trigger/HandlerService.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
99
"github.com/caarlos0/env"
10+
"github.com/devtron-labs/common-lib/async"
1011
blob_storage "github.com/devtron-labs/common-lib/blob-storage"
1112
"github.com/devtron-labs/common-lib/utils"
1213
bean4 "github.com/devtron-labs/common-lib/utils/bean"
@@ -116,6 +117,7 @@ type HandlerServiceImpl struct {
116117
clusterService cluster.ClusterService
117118
envService environment.EnvironmentService
118119
K8sUtil *k8s.K8sServiceImpl
120+
asyncRunnable *async.Runnable
119121
}
120122

121123
func NewHandlerServiceImpl(Logger *zap.SugaredLogger, workflowService executor.WorkflowService,
@@ -141,6 +143,7 @@ func NewHandlerServiceImpl(Logger *zap.SugaredLogger, workflowService executor.W
141143
clusterService cluster.ClusterService,
142144
envService environment.EnvironmentService,
143145
K8sUtil *k8s.K8sServiceImpl,
146+
asyncRunnable *async.Runnable,
144147
) *HandlerServiceImpl {
145148
buildxCacheFlags := &BuildxCacheFlags{}
146149
err := env.Parse(buildxCacheFlags)
@@ -174,6 +177,7 @@ func NewHandlerServiceImpl(Logger *zap.SugaredLogger, workflowService executor.W
174177
clusterService: clusterService,
175178
envService: envService,
176179
K8sUtil: K8sUtil,
180+
asyncRunnable: asyncRunnable,
177181
}
178182
config, err := types.GetCiConfig()
179183
if err != nil {
@@ -628,7 +632,12 @@ func (impl *HandlerServiceImpl) triggerCiPipeline(trigger types.Trigger) (int, e
628632
}
629633

630634
middleware.CiTriggerCounter.WithLabelValues(pipeline.App.AppName, pipeline.Name).Inc()
631-
go impl.ciService.WriteCITriggerEvent(trigger, pipeline, workflowRequest)
635+
636+
runnableFunc := func() {
637+
impl.ciService.WriteCITriggerEvent(trigger, pipeline, workflowRequest)
638+
}
639+
impl.asyncRunnable.Execute(runnableFunc)
640+
632641
return savedCiWf.Id, err
633642
}
634643

pkg/workflow/dag/WorkflowDagExecutor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,10 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger
10501050
} else {
10511051
ciArtifactArr = append(ciArtifactArr, pluginArtifacts[0])
10521052
}
1053-
go impl.WriteCiSuccessEvent(request, pipelineModal, buildArtifact)
1053+
runnableFunc := func() {
1054+
impl.WriteCiSuccessEvent(request, pipelineModal, buildArtifact)
1055+
}
1056+
impl.asyncRunnable.Execute(runnableFunc)
10541057
async := false
10551058

10561059
// execute auto trigger in batch on CI success event

wire_gen.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)