Skip to content

Commit 6820ffe

Browse files
feat: refactoring deployment app name usage (#5702)
* removing hard coded deployment app name * removing %s-%s usage * wip: query change for enterprise * wip * wip * wip * adding release mode in deployment config * wip: release changes * left join on pco and artifact * handling empty release mode - backward compatibility * fixing panic * migration number changes (#5692) * refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696) * fix: Decode secret fix on add update oss (#5695) * ValidateEncodedDataByDecoding in case add or update secret * wire fix from main * minor refactor * comment * saving pco concurrency case handled (#5688) * migration updated * main merge and migration script updated * wip * review changes * fix sql no --------- Co-authored-by: Prakash <prakash.kumar@devtron.ai>
1 parent f1aa1fc commit 6820ffe

22 files changed

+311
-188
lines changed

api/bean/AppView.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ type AppEnvironmentContainer struct {
144144
type DeploymentDetailContainer struct {
145145
InstalledAppId int `json:"installedAppId,omitempty"`
146146
AppId int `json:"appId,omitempty"`
147+
PcoId int `json:"pcoId"`
147148
CdPipelineId int `json:"cdPipelineId,omitempty"`
148149
TriggerType string `json:"triggerType,omitempty"`
149150
ParentEnvironmentName string `json:"parentEnvironmentName"`
@@ -183,6 +184,8 @@ type DeploymentDetailContainer struct {
183184
HelmPackageName string `json:"helmPackageName"`
184185
HelmReleaseInstallStatus string `json:"-"`
185186
DeploymentConfig *bean.DeploymentConfig `json:"-"`
187+
IsPipelineTriggered bool `json:"isPipelineTriggered"`
188+
ReleaseMode string `json:"releaseMode"`
186189
}
187190

188191
type AppDetailContainer struct {

api/helm-app/gRPC/applist.pb.go

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

api/helm-app/gRPC/applist.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ service ApplicationService {
4444
rpc ValidateOCIRegistry(RegistryCredential) returns(OCIRegistryResponse) {}
4545
rpc GetResourceTreeForExternalResources(ExternalResourceTreeRequest) returns(ResourceTreeResponse){}
4646
rpc GetFluxAppDetail(FluxAppDetailRequest)returns(FluxAppDetail){}
47+
rpc GetReleaseDetails(ReleaseIdentifier)returns(DeployedAppDetail){}
4748

4849
}
4950

api/helm-app/gRPC/applist_grpc.pb.go

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

api/helm-app/service/HelmAppService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *gRPC.D
11361136
// do not add app in the list which are created using cd_pipelines (check combination of clusterId, namespace, releaseName)
11371137
var toExcludeFromList bool
11381138
for _, helmCdPipeline := range helmCdPipelines {
1139-
helmAppReleaseName := util2.BuildDeployedAppName(helmCdPipeline.App.AppName, helmCdPipeline.Environment.Name)
1139+
helmAppReleaseName := helmCdPipeline.DeploymentAppName
11401140
if deployedapp.AppName == helmAppReleaseName && int(deployedapp.EnvironmentDetail.ClusterId) == helmCdPipeline.Environment.ClusterId && deployedapp.EnvironmentDetail.Namespace == helmCdPipeline.Environment.Namespace {
11411141
toExcludeFromList = true
11421142
break

api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ func (handler *PipelineConfigRestHandlerImpl) CreateCdPipeline(w http.ResponseWr
207207
handler.Logger.Infow("request payload, CreateCdPipeline", "payload", cdPipeline)
208208
userUploaded, err := handler.chartService.CheckIfChartRefUserUploadedByAppId(cdPipeline.AppId)
209209
if !userUploaded {
210+
for i, p := range cdPipeline.Pipelines {
211+
if len(p.ReleaseMode) == 0 {
212+
cdPipeline.Pipelines[i].ReleaseMode = util.PIPELINE_RELEASE_MODE_CREATE
213+
}
214+
}
210215
err = handler.validator.Struct(cdPipeline)
211216
if err != nil {
212217
handler.Logger.Errorw("validation err, CreateCdPipeline", "err", err, "payload", cdPipeline)

internal/sql/repository/AppListingRepository.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/devtron-labs/devtron/internal/middleware"
2828
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
2929
"github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig"
30+
"github.com/devtron-labs/devtron/internal/util"
3031
repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository"
3132
"go.opentelemetry.io/otel"
3233
"strings"
@@ -365,10 +366,10 @@ func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx contex
365366
" p.ci_pipeline_id," +
366367
" p.trigger_type" +
367368
" FROM pipeline p" +
368-
" INNER JOIN pipeline_config_override pco on pco.pipeline_id=p.id" +
369+
" LEFT JOIN pipeline_config_override pco on pco.pipeline_id=p.id" +
369370
" INNER JOIN environment env ON env.id=p.environment_id" +
370371
" INNER JOIN cluster cl on cl.id=env.cluster_id" +
371-
" INNER JOIN ci_artifact cia on cia.id = pco.ci_artifact_id" +
372+
" LEFT JOIN ci_artifact cia on cia.id = pco.ci_artifact_id" +
372373
" INNER JOIN app a ON a.id=p.app_id" +
373374
" WHERE a.app_type = 0 AND a.id=? AND env.id=? AND p.deleted = FALSE AND env.active = TRUE" +
374375
" ORDER BY pco.created_on DESC LIMIT 1;"
@@ -378,13 +379,18 @@ func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx contex
378379
return deploymentDetail, err
379380
}
380381
deploymentDetail.EnvironmentId = envId
381-
if len(deploymentDetail.DeploymentAppType) == 0 {
382-
dc, err := impl.deploymentConfigRepository.GetByAppIdAndEnvId(appId, envId)
383-
if err != nil {
384-
impl.Logger.Errorw("error in getting deployment config by appId and envId", "appId", appId, "envId", envId, "err", err)
385-
return deploymentDetail, err
386-
}
382+
383+
deploymentDetail.EnvironmentId = envId
384+
dc, err := impl.deploymentConfigRepository.GetByAppIdAndEnvId(appId, envId)
385+
if err != nil && err != pg.ErrNoRows {
386+
impl.Logger.Errorw("error in getting deployment config by appId and envId", "appId", appId, "envId", envId, "err", err)
387+
return deploymentDetail, err
388+
}
389+
if err == pg.ErrNoRows {
390+
deploymentDetail.ReleaseMode = util.PIPELINE_RELEASE_MODE_CREATE
391+
} else {
387392
deploymentDetail.DeploymentAppType = dc.DeploymentAppType
393+
deploymentDetail.ReleaseMode = dc.ReleaseMode
388394
}
389395

390396
return deploymentDetail, nil
@@ -455,6 +461,9 @@ func (impl AppListingRepositoryImpl) FetchAppDetail(ctx context.Context, appId i
455461
if err != nil {
456462
impl.Logger.Warn("unable to fetch deployment detail for app")
457463
}
464+
if deploymentDetail.PcoId > 0 {
465+
deploymentDetail.IsPipelineTriggered = true
466+
}
458467
appWfMapping, _ := impl.appWorkflowRepository.FindWFCDMappingByCDPipelineId(deploymentDetail.CdPipelineId)
459468
if appWfMapping.ParentType == appWorkflow2.CDPIPELINE {
460469
parentEnvironmentName, _ := impl.getEnvironmentNameFromPipelineId(appWfMapping.ParentId)

internal/sql/repository/deploymentConfig/repository.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type DeploymentConfig struct {
2929
ConfigType string `sql:"config_type"`
3030
RepoUrl string `sql:"repo_url"`
3131
RepoName string `sql:"repo_name"`
32+
ReleaseMode string `json:"release_mode"`
3233
Active bool `sql:"active,notnull"`
3334
sql.AuditLog
3435
}

internal/util/ChartTemplateService.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const (
4646
CHART_WORKING_DIR_PATH = "/tmp/charts/"
4747
)
4848

49+
const (
50+
PIPELINE_RELEASE_MODE_CREATE = "create"
51+
)
52+
4953
type ChartCreateRequest struct {
5054
ChartMetaData *chart.Metadata
5155
ChartPath string

pkg/bean/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ type CDPipelineConfigObject struct {
621621
ChildPipelineId int `json:"childPipelineId"`
622622
IsDigestEnforcedForPipeline bool `json:"isDigestEnforcedForPipeline"`
623623
IsDigestEnforcedForEnv bool `json:"isDigestEnforcedForEnv"`
624+
ReleaseMode string `json:"releaseMode" validate:"oneof=create"`
624625
}
625626

626627
type CDPipelineAddType string

pkg/bulkAction/BulkUpdateService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ func (impl BulkUpdateServiceImpl) buildHibernateUnHibernateRequestForHelmPipelin
10801080
return nil, nil, err
10811081
}
10821082
var group, kind, version, name string
1083-
name = fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
1083+
name = pipeline.DeploymentAppName
10841084
if chartInfo.Name == bean3.RolloutChartType && chartInfo.UserUploaded == false {
10851085
// rollout type chart
10861086
group = "argoproj.io"

pkg/deployment/common/adapter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func ConvertDeploymentConfigDTOToDbObj(config *bean.DeploymentConfig) *deploymen
1414
ConfigType: config.ConfigType,
1515
RepoUrl: config.RepoURL,
1616
Active: config.Active,
17+
ReleaseMode: config.ReleaseMode,
1718
}
1819
}
1920

@@ -26,5 +27,6 @@ func ConvertDeploymentConfigDbObjToDTO(dbObj *deploymentConfig.DeploymentConfig)
2627
ConfigType: dbObj.ConfigType,
2728
RepoURL: dbObj.RepoUrl,
2829
Active: dbObj.Active,
30+
ReleaseMode: dbObj.ReleaseMode,
2931
}
3032
}

pkg/deployment/common/bean/bean.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type DeploymentConfig struct {
1414
DeploymentAppType string
1515
RepoURL string
1616
RepoName string
17+
ReleaseMode string
1718
Active bool
1819
}
1920

pkg/deployment/common/deploymentConfigService.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app"
77
"github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig"
88
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
9+
util2 "github.com/devtron-labs/devtron/internal/util"
910
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
1011
bean3 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
1112
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
@@ -101,6 +102,20 @@ func (impl *DeploymentConfigServiceImpl) GetConfigForDevtronApps(appId, envId in
101102
impl.logger.Errorw("error in parsing config from charts and pipeline repository", "appId", appId, "envId", envId, "err", err)
102103
return nil, err
103104
}
105+
if envId > 0 {
106+
// add columns added after migration (of deployment app type and repo url) here
107+
appAndEnvLevelConfig, err := impl.deploymentConfigRepository.GetByAppIdAndEnvId(appId, envId)
108+
if err != nil && err != pg.ErrNoRows {
109+
impl.logger.Errorw("error in getting deployment config db object by appId and envId", "appId", appId, "envId", envId, "err", err)
110+
return nil, err
111+
}
112+
if err == pg.ErrNoRows {
113+
// deployment config is not done
114+
configFromOldData.ReleaseMode = util2.PIPELINE_RELEASE_MODE_CREATE
115+
} else {
116+
configFromOldData.ReleaseMode = appAndEnvLevelConfig.ReleaseMode
117+
}
118+
}
104119
return configFromOldData, nil
105120
}
106121

@@ -190,6 +205,9 @@ func (impl *DeploymentConfigServiceImpl) GetAndMigrateConfigIfAbsentForDevtronAp
190205
impl.logger.Errorw("error in parsing config from charts and pipeline repository", "appId", appId, "envId", envId, "err", err)
191206
return nil, err
192207
}
208+
if envId > 0 {
209+
configFromOldData.ReleaseMode = envLevelConfig.ReleaseMode
210+
}
193211
return configFromOldData, nil
194212
}
195213

@@ -256,6 +274,7 @@ func (impl *DeploymentConfigServiceImpl) parseEnvLevelConfigForDevtronApps(appLe
256274
EnvironmentId: envId,
257275
ConfigType: appLevelConfig.ConfigType,
258276
RepoUrl: appLevelConfig.RepoUrl,
277+
ReleaseMode: util2.PIPELINE_RELEASE_MODE_CREATE, //for migration it is always equal to create as migration is happening for old cd pipelines
259278
Active: true,
260279
}
261280

pkg/deployment/manifest/ManifestCreationService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (impl *ManifestCreationServiceImpl) GetValuesOverrideForTrigger(overrideReq
265265
appLabelJsonByte = nil
266266
}
267267
mergedValues, err := impl.mergeOverrideValues(envOverride, releaseOverrideJson, configMapJson.MergedJson, appLabelJsonByte, strategy)
268-
appName := fmt.Sprintf("%s-%s", overrideRequest.AppName, envOverride.Environment.Name)
268+
appName := pipeline.DeploymentAppName
269269
var k8sErr error
270270
mergedValues, k8sErr = impl.updatedExternalCmCsHashForTrigger(newCtx, overrideRequest.ClusterId,
271271
envOverride.Namespace, mergedValues, configMapJson.ExternalCmList, configMapJson.ExternalCsList)

pkg/deployment/trigger/devtronApps/TriggerService.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -956,20 +956,6 @@ func (impl *TriggerServiceImpl) buildManifestPushTemplate(overrideRequest *bean3
956956
return manifestPushTemplate, err
957957
}
958958

959-
// getAcdAppGitOpsRepoName returns the GitOps repository name, configured for the argoCd app
960-
func (impl *TriggerServiceImpl) getAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) {
961-
//this method should only call in case of argo-integration and gitops configured
962-
acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken()
963-
if err != nil {
964-
impl.logger.Errorw("error in getting acd token", "err", err)
965-
return "", err
966-
}
967-
ctx := context.Background()
968-
ctx = context.WithValue(ctx, "token", acdToken)
969-
acdAppName := fmt.Sprintf("%s-%s", appName, environmentName)
970-
return impl.argoClientWrapperService.GetGitOpsRepoName(ctx, acdAppName)
971-
}
972-
973959
func (impl *TriggerServiceImpl) getManifestPushService(triggerEvent bean.TriggerEvent) publish.ManifestPushService {
974960
var manifestPushService publish.ManifestPushService
975961
if triggerEvent.ManifestStorageType == bean2.ManifestStorageGit {

pkg/generateManifest/DeploymentTemplateService.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,18 @@ func (impl DeploymentTemplateServiceImpl) GetRestartWorkloadData(ctx context.Con
501501
impl.Logger.Errorw("error in fetching environment", "envId", envId, "err", err)
502502
return nil, err
503503
}
504-
installReleaseRequests, err := impl.constructInstallReleaseBulkReq(apps, environment)
504+
505+
pipelineMap := make(map[string]*pipelineConfig.Pipeline)
506+
pipelines, err := impl.pipelineRepository.FindActiveByInFilter(envId, appIds)
507+
if err != nil {
508+
impl.Logger.Errorw("error in getting pipelines by appIds and envId", "appIds", appIds, "envId", envId, "err", err)
509+
return nil, err
510+
}
511+
for _, p := range pipelines {
512+
pipelineMap[fmt.Sprintf("%d-%d", p.AppId, p.EnvironmentId)] = p
513+
}
514+
515+
installReleaseRequests, err := impl.constructInstallReleaseBulkReq(apps, environment, pipelineMap)
505516
if err != nil {
506517
impl.Logger.Errorw("error in fetching installReleaseRequests", "appIds", appIds, "envId", envId, "err", err)
507518
return nil, err

pkg/generateManifest/helper.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/devtron-labs/devtron/api/helm-app/bean"
2424
"github.com/devtron-labs/devtron/api/helm-app/gRPC"
2525
"github.com/devtron-labs/devtron/internal/sql/repository/app"
26+
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
2627
"github.com/devtron-labs/devtron/pkg/cluster/repository"
2728
"go.opentelemetry.io/otel"
2829
"golang.org/x/exp/maps"
@@ -67,7 +68,7 @@ func (impl DeploymentTemplateServiceImpl) constructRotatePodResponse(templateCha
6768
return podResp, nil
6869
}
6970

70-
func (impl DeploymentTemplateServiceImpl) constructInstallReleaseBulkReq(apps []*app.App, environment *repository.Environment) ([]*gRPC.InstallReleaseRequest, error) {
71+
func (impl DeploymentTemplateServiceImpl) constructInstallReleaseBulkReq(apps []*app.App, environment *repository.Environment, pipelineMap map[string]*pipelineConfig.Pipeline) ([]*gRPC.InstallReleaseRequest, error) {
7172
appIdToInstallReleaseRequest := make(map[int]*gRPC.InstallReleaseRequest)
7273
installReleaseRequests := make([]*gRPC.InstallReleaseRequest, 0)
7374
var applicationIds []int
@@ -104,9 +105,10 @@ func (impl DeploymentTemplateServiceImpl) constructInstallReleaseBulkReq(apps []
104105
impl.Logger.Errorw("error in fetching cluster detail", "clusterId", 1, "err", err)
105106
return nil, err
106107
}
108+
107109
for _, app := range apps {
108110
if _, ok := appIdToInstallReleaseRequest[app.Id]; ok {
109-
appIdToInstallReleaseRequest[app.Id].ReleaseIdentifier = impl.getReleaseIdentifier(config, app, environment)
111+
appIdToInstallReleaseRequest[app.Id].ReleaseIdentifier = impl.getReleaseIdentifier(config, app, environment, pipelineMap)
110112
appIdToInstallReleaseRequest[app.Id].K8SVersion = k8sServerVersion.String()
111113
}
112114
}
@@ -140,10 +142,11 @@ func (impl DeploymentTemplateServiceImpl) setChartContent(ctx context.Context, i
140142
return err
141143
}
142144

143-
func (impl DeploymentTemplateServiceImpl) getReleaseIdentifier(config *gRPC.ClusterConfig, app *app.App, env *repository.Environment) *gRPC.ReleaseIdentifier {
145+
func (impl DeploymentTemplateServiceImpl) getReleaseIdentifier(config *gRPC.ClusterConfig, app *app.App, env *repository.Environment, pipelineMap map[string]*pipelineConfig.Pipeline) *gRPC.ReleaseIdentifier {
146+
pipeline := pipelineMap[fmt.Sprintf("%d-%d", app.Id, env.Id)]
144147
return &gRPC.ReleaseIdentifier{
145148
ClusterConfig: config,
146-
ReleaseName: fmt.Sprintf("%s-%s", app.AppName, env.Name),
149+
ReleaseName: pipeline.DeploymentAppName,
147150
ReleaseNamespace: env.Namespace,
148151
}
149152
}

pkg/pipeline/AppDeploymentTypeChangeManager.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) ChangePipelineDeploymentType(ctx
242242
TriggeredPipelines: make([]*bean.CdPipelineTrigger, 0),
243243
}
244244

245-
var deleteDeploymentType bean3.DeploymentType
245+
var deleteDeploymentType string
246246

247247
if request.DesiredDeploymentType == bean3.ArgoCd {
248248
deleteDeploymentType = bean3.Helm
@@ -251,12 +251,12 @@ func (impl *AppDeploymentTypeChangeManagerImpl) ChangePipelineDeploymentType(ctx
251251
}
252252

253253
pipelines, err := impl.pipelineRepository.FindActiveByEnvIdAndDeploymentType(request.EnvId,
254-
string(deleteDeploymentType), request.ExcludeApps, request.IncludeApps)
254+
deleteDeploymentType, request.ExcludeApps, request.IncludeApps)
255255

256256
if err != nil {
257257
impl.logger.Errorw("Error fetching cd pipelines",
258258
"environmentId", request.EnvId,
259-
"currentDeploymentAppType", string(deleteDeploymentType),
259+
"currentDeploymentAppTypes", deleteDeploymentType,
260260
"err", err)
261261
return response, err
262262
}
@@ -334,7 +334,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) TriggerDeploymentAfterTypeChange
334334
var err error
335335

336336
cdPipelines, err := impl.pipelineRepository.FindActiveByEnvIdAndDeploymentType(request.EnvId,
337-
string(request.DesiredDeploymentType), request.ExcludeApps, request.IncludeApps)
337+
request.DesiredDeploymentType, request.ExcludeApps, request.IncludeApps)
338338

339339
if err != nil {
340340
impl.logger.Errorw("Error fetching cd pipelines",
@@ -475,11 +475,10 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context
475475
continue
476476
}
477477

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

484483
} else {
485484

@@ -552,7 +551,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context
552551
}
553552
if err != nil {
554553
impl.logger.Errorw("error registering app on ACD with error: "+err.Error(),
555-
"deploymentAppName", deploymentAppName,
554+
"deploymentAppName", pipeline.DeploymentAppName,
556555
"envId", pipeline.EnvironmentId,
557556
"appId", pipeline.AppId,
558557
"err", err)
@@ -568,7 +567,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context
568567

569568
if err != nil {
570569
impl.logger.Errorw("error deleting app on "+envDeploymentConfig.DeploymentAppType,
571-
"deployment app name", deploymentAppName,
570+
"deployment app name", pipeline.DeploymentAppName,
572571
"err", err)
573572

574573
// deletion failed, append to the list of failed pipelines
@@ -597,7 +596,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentAppsForEnvironme
597596

598597
// fetch active pipelines from database for the given environment id and current deployment app type
599598
pipelines, err := impl.pipelineRepository.FindActiveByEnvIdAndDeploymentType(environmentId,
600-
string(currentDeploymentAppType), exclusionList, includeApps)
599+
currentDeploymentAppType, exclusionList, includeApps)
601600

602601
deploymentConfigs := make([]*bean4.DeploymentConfig, 0)
603602
for _, p := range pipelines {
@@ -728,7 +727,6 @@ func (impl *AppDeploymentTypeChangeManagerImpl) fetchDeletedApp(ctx context.Cont
728727
if err != nil {
729728
impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", pipeline.AppId, "envId", pipeline.EnvironmentId, "err", err)
730729
}
731-
deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name)
732730
if envDeploymentConfig.DeploymentAppType == bean3.ArgoCd {
733731
appIdentifier := &helmBean.AppIdentifier{
734732
ClusterId: pipeline.Environment.ClusterId,
@@ -738,12 +736,12 @@ func (impl *AppDeploymentTypeChangeManagerImpl) fetchDeletedApp(ctx context.Cont
738736
_, err = impl.helmAppService.GetApplicationDetail(ctx, appIdentifier)
739737
} else {
740738
req := &application.ApplicationQuery{
741-
Name: &deploymentAppName,
739+
Name: &pipeline.DeploymentAppName,
742740
}
743741
_, err = impl.application.Get(ctx, req)
744742
}
745743
if err != nil {
746-
impl.logger.Errorw("error in getting application detail", "err", err, "deploymentAppName", deploymentAppName)
744+
impl.logger.Errorw("error in getting application detail", "err", err, "deploymentAppName", pipeline.DeploymentAppName)
747745
}
748746

749747
if err != nil && checkAppReleaseNotExist(err) {

0 commit comments

Comments
 (0)