From 68474c6c92c26ca702e1585d46bca0600bd756db Mon Sep 17 00:00:00 2001 From: ayushmaheshwari Date: Wed, 10 Apr 2024 00:43:02 +0530 Subject: [PATCH] fix for release not found in argo --- .../trigger/devtronApps/TriggerService.go | 6 +++--- .../in/WorkflowEventProcessorService.go | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/deployment/trigger/devtronApps/TriggerService.go b/pkg/deployment/trigger/devtronApps/TriggerService.go index ea99e5dd62..4c76c2b6ee 100644 --- a/pkg/deployment/trigger/devtronApps/TriggerService.go +++ b/pkg/deployment/trigger/devtronApps/TriggerService.go @@ -1029,7 +1029,7 @@ func (impl *TriggerServiceImpl) deployArgocdApp(overrideRequest *bean3.ValuesOve impl.logger.Debugw("argocd application created", "name", name) _, span = otel.Tracer("orchestrator").Start(ctx, "updateArgoPipeline") - updateAppInArgocd, err := impl.updateArgoPipeline(valuesOverrideResponse.Pipeline, valuesOverrideResponse.EnvOverride, ctx) + updateAppInArgocd, err := impl.updateArgoPipeline(ctx, valuesOverrideResponse.Pipeline, valuesOverrideResponse.EnvOverride) span.End() if err != nil { impl.logger.Errorw("error in updating argocd app ", "err", err) @@ -1068,13 +1068,13 @@ func (impl *TriggerServiceImpl) deployArgocdApp(overrideRequest *bean3.ValuesOve } // update repoUrl, revision and argo app sync mode (auto/manual) if needed -func (impl *TriggerServiceImpl) updateArgoPipeline(pipeline *pipelineConfig.Pipeline, envOverride *chartConfig.EnvConfigOverride, ctx context.Context) (bool, error) { +func (impl *TriggerServiceImpl) updateArgoPipeline(ctx context.Context, pipeline *pipelineConfig.Pipeline, envOverride *chartConfig.EnvConfigOverride) (bool, error) { if ctx == nil { impl.logger.Errorw("err in syncing ACD, ctx is NULL", "pipelineName", pipeline.Name) return false, nil } argoAppName := pipeline.DeploymentAppName - impl.logger.Infow("received payload, updateArgoPipeline", "appId", pipeline.AppId, "pipelineName", pipeline.Name, "envId", envOverride.TargetEnvironment, "argoAppName", argoAppName, "context", ctx) + impl.logger.Infow("received payload, updateArgoPipeline", "appId", pipeline.AppId, "pipelineName", pipeline.Name, "envId", envOverride.TargetEnvironment, "argoAppName", argoAppName) argoApplication, err := impl.argoClientWrapperService.GetArgoAppByName(ctx, argoAppName) if err != nil { impl.logger.Errorw("no argo app exists", "app", argoAppName, "pipeline", pipeline.Name) diff --git a/pkg/eventProcessor/in/WorkflowEventProcessorService.go b/pkg/eventProcessor/in/WorkflowEventProcessorService.go index 42ce401233..157ef04e8d 100644 --- a/pkg/eventProcessor/in/WorkflowEventProcessorService.go +++ b/pkg/eventProcessor/in/WorkflowEventProcessorService.go @@ -795,12 +795,14 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDPipelineDeleteEvent() error { impl.logger.Errorw("error in fetching pipeline by pipelineId", "err", err, "pipelineId", cdPipelineDeleteEvent.PipelineId) return } - impl.RemoveReleaseContextForPipeline(cdPipelineDeleteEvent) - //there is a possibility that when the pipeline was deleted, async request nats message was not consumed completely and could have led to dangling deployment app - //trying to delete deployment app once - err = impl.cdPipelineConfigService.DeleteHelmTypePipelineDeploymentApp(context.Background(), true, pipeline) - if err != nil { - impl.logger.Errorw("error, DeleteHelmTypePipelineDeploymentApp", "pipelineId", pipeline.Id) + if pipeline.DeploymentAppType == bean5.Helm { + impl.RemoveReleaseContextForPipeline(cdPipelineDeleteEvent) + //there is a possibility that when the pipeline was deleted, async request nats message was not consumed completely and could have led to dangling deployment app + //trying to delete deployment app once + err = impl.cdPipelineConfigService.DeleteHelmTypePipelineDeploymentApp(context.Background(), true, pipeline) + if err != nil { + impl.logger.Errorw("error, DeleteHelmTypePipelineDeploymentApp", "pipelineId", pipeline.Id) + } } } // add required logging here