Skip to content

Commit 58976fb

Browse files
Fix: Chart update failed in case missing gitops repo, just added logs to make (devtron-labs#1600)
* there no bug inside the code for this issue, just added logs to make debuging easy * review change
1 parent a2a491e commit 58976fb

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type AppStoreDeploymentFullModeService interface {
5959
SyncACD(acdAppName string, ctx context.Context)
6060
UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error)
6161
UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error
62-
GetGitOpsRepoName(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) string
62+
GetGitOpsRepoName(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, error)
6363
}
6464

6565
type AppStoreDeploymentFullModeServiceImpl struct {
@@ -307,30 +307,33 @@ func (impl AppStoreDeploymentFullModeServiceImpl) createInArgo(chartGitAttribute
307307
return nil
308308
}
309309

310-
func (impl AppStoreDeploymentFullModeServiceImpl) GetGitOpsRepoName(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) string {
310+
func (impl AppStoreDeploymentFullModeServiceImpl) GetGitOpsRepoName(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, error) {
311+
gitOpsRepoName := ""
311312
ctx, err := impl.tokenCache.BuildACDSynchContext()
312313
if err != nil {
313-
impl.logger.Errorw("error in creating acd synch context", "err", err)
314-
return ""
314+
impl.logger.Errorw("error in creating acd sync context", "err", err)
315+
return "", err
315316
}
316317
acdAppName := fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName)
317-
gitOpsRepoName := ""
318318
application, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName})
319319
if err != nil {
320-
impl.logger.Errorw("no argo app exists", "app", acdAppName)
321-
return ""
320+
impl.logger.Errorw("no argo app exists", "acdAppName", acdAppName, "err", err)
321+
return "", err
322322
}
323323
if application != nil {
324324
gitOpsRepoUrl := application.Spec.Source.RepoURL
325325
gitOpsRepoName = impl.chartTemplateService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl)
326326
}
327-
return gitOpsRepoName
327+
return gitOpsRepoName, nil
328328
}
329329

330330
func (impl AppStoreDeploymentFullModeServiceImpl) UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) {
331331
acdAppName := fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName)
332332
if len(installAppVersionRequest.GitOpsRepoName) == 0 {
333-
gitOpsRepoName := impl.GetGitOpsRepoName(installAppVersionRequest)
333+
gitOpsRepoName, err := impl.GetGitOpsRepoName(installAppVersionRequest)
334+
if err != nil {
335+
return installAppVersionRequest, err
336+
}
334337
installAppVersionRequest.GitOpsRepoName = gitOpsRepoName
335338
}
336339
valuesOverrideByte, err := yaml.YAMLToJSON([]byte(installAppVersionRequest.ValuesOverrideYaml))

pkg/appStore/deployment/service/InstalledAppService.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ func (impl InstalledAppServiceImpl) UpdateInstalledApp(ctx context.Context, inst
184184
argocdAppName := installedApp.App.AppName + "-" + installedApp.Environment.Name
185185
gitOpsRepoName := installedApp.GitOpsRepoName
186186
if len(gitOpsRepoName) == 0 {
187-
gitOpsRepoName = impl.appStoreDeploymentFullModeService.GetGitOpsRepoName(installAppVersionRequest)
187+
gitOpsRepoName, err = impl.appStoreDeploymentFullModeService.GetGitOpsRepoName(installAppVersionRequest)
188+
if err != nil {
189+
return nil, err
190+
}
188191
}
189192
installAppVersionRequest.GitOpsRepoName = gitOpsRepoName
190193
var installedAppVersion *repository2.InstalledAppVersions

pkg/util/TokenCache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func NewTokenCache(logger *zap.SugaredLogger, aCDAuthConfig *ACDAuthConfig, user
4646
}
4747
func (impl *TokenCache) BuildACDSynchContext() (acdContext context.Context, err error) {
4848
token, found := impl.cache.Get("token")
49+
impl.logger.Debugw("building acd context", "token", token, "found", found)
4950
if !found {
5051
token, err := impl.userAuthService.HandleLogin(impl.aCDAuthConfig.ACDUsername, impl.aCDAuthConfig.ACDPassword)
5152
if err != nil {

0 commit comments

Comments
 (0)