Skip to content

Commit

Permalink
removing hard coded deployment app name
Browse files Browse the repository at this point in the history
  • Loading branch information
iamayushm committed Jul 31, 2024
1 parent a3c112c commit 8d34a07
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion api/helm-app/service/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *gRPC.D
// do not add app in the list which are created using cd_pipelines (check combination of clusterId, namespace, releaseName)
var toExcludeFromList bool
for _, helmCdPipeline := range helmCdPipelines {
helmAppReleaseName := util2.BuildDeployedAppName(helmCdPipeline.App.AppName, helmCdPipeline.Environment.Name)
helmAppReleaseName := helmCdPipeline.DeploymentAppName
if deployedapp.AppName == helmAppReleaseName && int(deployedapp.EnvironmentDetail.ClusterId) == helmCdPipeline.Environment.ClusterId && deployedapp.EnvironmentDetail.Namespace == helmCdPipeline.Environment.Namespace {
toExcludeFromList = true
break
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/manifest/ManifestCreationService.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (impl *ManifestCreationServiceImpl) GetValuesOverrideForTrigger(overrideReq
appLabelJsonByte = nil
}
mergedValues, err := impl.mergeOverrideValues(envOverride, releaseOverrideJson, configMapJson, appLabelJsonByte, strategy)
appName := fmt.Sprintf("%s-%s", overrideRequest.AppName, envOverride.Environment.Name)
appName := pipeline.DeploymentAppName
mergedValues, err = impl.autoscalingCheckBeforeTrigger(newCtx, appName, envOverride.Namespace, mergedValues, overrideRequest)
if err != nil {
impl.logger.Errorw("error in autoscaling check before trigger", "pipelineId", overrideRequest.PipelineId, "err", err)
Expand Down
14 changes: 0 additions & 14 deletions pkg/deployment/trigger/devtronApps/TriggerService.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,20 +956,6 @@ func (impl *TriggerServiceImpl) buildManifestPushTemplate(overrideRequest *bean3
return manifestPushTemplate, err
}

// getAcdAppGitOpsRepoName returns the GitOps repository name, configured for the argoCd app
func (impl *TriggerServiceImpl) getAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) {
//this method should only call in case of argo-integration and gitops configured
acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
impl.logger.Errorw("error in getting acd token", "err", err)
return "", err
}
ctx := context.Background()
ctx = context.WithValue(ctx, "token", acdToken)
acdAppName := fmt.Sprintf("%s-%s", appName, environmentName)
return impl.argoClientWrapperService.GetGitOpsRepoName(ctx, acdAppName)
}

func (impl *TriggerServiceImpl) getManifestPushService(triggerEvent bean.TriggerEvent) publish.ManifestPushService {
var manifestPushService publish.ManifestPushService
if triggerEvent.ManifestStorageType == bean2.ManifestStorageGit {
Expand Down
12 changes: 5 additions & 7 deletions pkg/pipeline/AppDeploymentTypeChangeManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,10 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context
continue
}

deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
// delete request
var err error
if envDeploymentConfig.DeploymentAppType == bean3.ArgoCd {
err = impl.deleteArgoCdApp(ctx, pipeline, deploymentAppName, true)
err = impl.deleteArgoCdApp(ctx, pipeline, pipeline.DeploymentAppName, true)

} else {

Expand Down Expand Up @@ -560,7 +559,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context
}
if err != nil {
impl.logger.Errorw("error registering app on ACD with error: "+err.Error(),
"deploymentAppName", deploymentAppName,
"deploymentAppName", pipeline.DeploymentAppName,
"envId", pipeline.EnvironmentId,
"appId", pipeline.AppId,
"err", err)
Expand All @@ -576,7 +575,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context

if err != nil {
impl.logger.Errorw("error deleting app on "+envDeploymentConfig.DeploymentAppType,
"deployment app name", deploymentAppName,
"deployment app name", pipeline.DeploymentAppName,
"err", err)

// deletion failed, append to the list of failed pipelines
Expand Down Expand Up @@ -736,7 +735,6 @@ func (impl *AppDeploymentTypeChangeManagerImpl) fetchDeletedApp(ctx context.Cont
if err != nil {
impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", pipeline.AppId, "envId", pipeline.EnvironmentId, "err", err)
}
deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
if envDeploymentConfig.DeploymentAppType == bean3.ArgoCd {
appIdentifier := &helmBean.AppIdentifier{
ClusterId: pipeline.Environment.ClusterId,
Expand All @@ -746,12 +744,12 @@ func (impl *AppDeploymentTypeChangeManagerImpl) fetchDeletedApp(ctx context.Cont
_, err = impl.helmAppService.GetApplicationDetail(ctx, appIdentifier)
} else {
req := &application.ApplicationQuery{
Name: &deploymentAppName,
Name: &pipeline.DeploymentAppName,
}
_, err = impl.application.Get(ctx, req)
}
if err != nil {
impl.logger.Errorw("error in getting application detail", "err", err, "deploymentAppName", deploymentAppName)
impl.logger.Errorw("error in getting application detail", "err", err, "deploymentAppName", pipeline.DeploymentAppName)
}

if err != nil && checkAppReleaseNotExist(err) {
Expand Down
7 changes: 3 additions & 4 deletions pkg/pipeline/DeploymentPipelineConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func (impl *CdPipelineConfigServiceImpl) DeleteCdPipeline(pipeline *pipelineConf
}
//delete app from argo cd, if created
if pipeline.DeploymentAppCreated == true {
deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
deploymentAppName := pipeline.DeploymentAppName
if util.IsAcdApp(envDeploymentConfig.DeploymentAppType) {
if !forceDelete && !deleteResponse.ClusterReachable {
impl.logger.Errorw("cluster connection error", "err", clusterBean.ErrorInConnecting)
Expand Down Expand Up @@ -964,8 +964,7 @@ func (impl *CdPipelineConfigServiceImpl) DeleteACDAppCdPipelineWithNonCascade(pi
}
//delete app from argo cd with non-cascade, if created
if pipeline.DeploymentAppCreated && util.IsAcdApp(envDeploymentConfig.DeploymentAppType) {
appDetails, err := impl.appRepo.FindById(pipeline.AppId)
deploymentAppName := fmt.Sprintf("%s-%s", appDetails.AppName, pipeline.Environment.Name)
deploymentAppName := pipeline.DeploymentAppName
impl.logger.Debugw("acd app is already deleted for this pipeline", "pipeline", pipeline)
cascadeDelete := false
req := &application2.ApplicationDeleteRequest{
Expand Down Expand Up @@ -2061,7 +2060,7 @@ func (impl *CdPipelineConfigServiceImpl) DeleteCdPipelinePartial(pipeline *pipel
impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", pipeline.AppId, "envId", pipeline.EnvironmentId, "err", err)
return deleteResponse, err
}
deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
deploymentAppName := pipeline.DeploymentAppName
if util.IsAcdApp(envDeploymentConfig.DeploymentAppType) {
if !forceDelete && !deleteResponse.ClusterReachable {
impl.logger.Errorw("cluster connection error", "err", clusterBean.ErrorInConnecting)
Expand Down

0 comments on commit 8d34a07

Please sign in to comment.