@@ -463,22 +463,22 @@ func convertUrlToHttpsIfSshType(url string) string {
463
463
}
464
464
465
465
// getAppAndProjectForAppIdentifier, returns app db model for an app unique identifier or from display_name if both exists else it throws pg.ErrNoRows
466
- func (impl AppCrudOperationServiceImpl ) getAppAndProjectForAppIdentifier (appIdentifier * helmBean.AppIdentifier ) (* appRepository.App , error ) {
466
+ func (impl AppCrudOperationServiceImpl ) getAppAndProjectForAppIdentifier (appIdentifier * helmBean.AppIdentifier ) (* appRepository.App , bool , error ) {
467
467
app := & appRepository.App {}
468
468
var err error
469
469
appNameUniqueIdentifier := appIdentifier .GetUniqueAppNameIdentifier ()
470
470
app , err = impl .appRepository .FindAppAndProjectByAppName (appNameUniqueIdentifier )
471
471
if err != nil && err != pg .ErrNoRows && err != pg .ErrMultiRows {
472
472
impl .logger .Errorw ("error in fetching app meta data by unique app identifier" , "appNameUniqueIdentifier" , appNameUniqueIdentifier , "err" , err )
473
- return app , err
473
+ return app , false , err
474
474
}
475
475
if err == pg .ErrMultiRows {
476
476
validApp , err := impl .dbMigration .FixMultipleAppsForInstalledApp (appNameUniqueIdentifier )
477
477
if err != nil {
478
478
impl .logger .Errorw ("error in fixing multiple installed app entries" , "appName" , appNameUniqueIdentifier , "err" , err )
479
- return app , err
479
+ return app , false , err
480
480
}
481
- return validApp , err
481
+ return validApp , false , err
482
482
}
483
483
if util .IsErrNoRows (err ) {
484
484
//find app by display name if not found by unique identifier
@@ -487,16 +487,28 @@ func (impl AppCrudOperationServiceImpl) getAppAndProjectForAppIdentifier(appIden
487
487
validApp , err := impl .dbMigration .FixMultipleAppsForInstalledApp (appNameUniqueIdentifier )
488
488
if err != nil {
489
489
impl .logger .Errorw ("error in fixing multiple installed app entries" , "appName" , appNameUniqueIdentifier , "err" , err )
490
- return app , err
490
+ return app , false , err
491
491
}
492
- return validApp , err
492
+ return validApp , false , err
493
493
}
494
494
if err != nil {
495
495
impl .logger .Errorw ("error in fetching app meta data by display name" , "displayName" , appIdentifier .ReleaseName , "err" , err )
496
- return app , err
496
+ return app , false , err
497
+ }
498
+ // there can be a case when an app whose installed_app is deployed via argocd and same appName is also deployed externally
499
+ // via helm then we need to check if app model found is not deployed by argocd.
500
+ isManagedByArgocd , err := impl .installedAppDbService .IsChartStoreAppManagedByArgoCd (app .Id )
501
+ if err != nil {
502
+ impl .logger .Errorw ("error in checking if installed app linked to this app is managed via argocd or not " , "appId" , app .Id , "err" , err )
503
+ return app , false , err
504
+ }
505
+ if isManagedByArgocd {
506
+ // if this helm app is managed by argocd then we don't want to process this req. any further.
507
+ return app , true , nil
497
508
}
498
509
}
499
- return app , nil
510
+
511
+ return app , false , nil
500
512
}
501
513
502
514
// updateAppNameToUniqueAppIdentifierInApp, migrates values of app_name col. in app table to unique identifier and also updates display_name with releaseName
@@ -540,18 +552,25 @@ func (impl AppCrudOperationServiceImpl) GetHelmAppMetaInfo(appId string) (*bean.
540
552
app := & appRepository.App {}
541
553
var err error
542
554
var displayName string
555
+ var isManagedByArgocd bool
543
556
impl .logger .Info ("request payload, appId" , appId )
544
557
if len (appIdSplitted ) > 1 {
545
558
appIdDecoded , err := client .DecodeExternalAppAppId (appId )
546
559
if err != nil {
547
560
impl .logger .Errorw ("error in decoding app id for external app" , "appId" , appId , "err" , err )
548
561
return nil , err
549
562
}
550
- app , err = impl .getAppAndProjectForAppIdentifier (appIdDecoded )
563
+ app , isManagedByArgocd , err = impl .getAppAndProjectForAppIdentifier (appIdDecoded )
551
564
if err != nil && ! util .IsErrNoRows (err ) {
552
565
impl .logger .Errorw ("GetHelmAppMetaInfo, error in getAppAndProjectForAppIdentifier for external apps" , "appIdentifier" , appIdDecoded , "err" , err )
553
566
return nil , err
554
567
}
568
+ if isManagedByArgocd {
569
+ info := & bean.AppMetaInfoDto {
570
+ AppName : appIdDecoded .ReleaseName ,
571
+ }
572
+ return info , nil
573
+ }
555
574
// if app.DisplayName is empty then that app_name is not yet migrated to app name unique identifier
556
575
if app .Id > 0 && len (app .DisplayName ) == 0 {
557
576
appNameUniqueIdentifier := appIdDecoded .GetUniqueAppNameIdentifier ()
0 commit comments