Skip to content

Commit

Permalink
fix: 28feb packet common bug fix (#4724)
Browse files Browse the repository at this point in the history
* fix: shortened git commit hash returned from git cli

* handle permission error when getting argocd app in case of trigger of migrated helm apps from helm to argocd

* permission denied changed to failed status

---------

Co-authored-by: Prakash Kumar <prakash.kumar@devtron.ai>
  • Loading branch information
Ash-exp and prakash100198 committed Feb 29, 2024
1 parent 97d11cf commit 9e7e9c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,13 @@ func (impl *InstalledAppDeploymentTypeChangeServiceImpl) fetchDeletedInstalledAp
if err != nil && util2.CheckAppReleaseNotExist(err) {
successfulInstalledApps = appendToDeploymentChangeStatusList(successfulInstalledApps, installedApp, "", bean.Success)
} else {
failedInstalledApps = appendToDeploymentChangeStatusList(failedInstalledApps, installedApp, appStoreBean.APP_NOT_DELETED_YET_ERROR, bean.NOT_YET_DELETED)
failError := appStoreBean.APP_NOT_DELETED_YET_ERROR
failStatus := bean.NOT_YET_DELETED
if util2.CheckPermissionErrorForArgoCd(err) {
failError = string(bean.PermissionDenied)
failStatus = bean.Failed
}
failedInstalledApps = appendToDeploymentChangeStatusList(failedInstalledApps, installedApp, failError, failStatus)
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/appStore/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

const RELEASE_NOT_EXIST = "release not exist"
const NOT_FOUND = "not found"
const PermissionDenied = "permission denied"

func MoveFileToDestination(filePath, destinationPath string) error {
err := os.Rename(filePath, destinationPath)
Expand Down Expand Up @@ -42,3 +43,7 @@ func CheckAppReleaseNotExist(err error) bool {
// RELEASE_NOT_EXIST check for helm App and NOT_FOUND check for argo app
return strings.Contains(err.Error(), NOT_FOUND) || strings.Contains(err.Error(), RELEASE_NOT_EXIST)
}

func CheckPermissionErrorForArgoCd(err error) bool {
return strings.Contains(err.Error(), PermissionDenied)
}
9 changes: 5 additions & 4 deletions pkg/bean/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,11 @@ func IsHelmApp(deploymentType string) bool {
type Status string

const (
Success Status = "Success"
Failed Status = "Failed"
INITIATED Status = "Migration initiated"
NOT_YET_DELETED Status = "Not yet deleted"
Success Status = "Success"
Failed Status = "Failed"
INITIATED Status = "Migration initiated"
NOT_YET_DELETED Status = "Not yet deleted"
PermissionDenied Status = "permission denied"
)

const RELEASE_NOT_EXIST = "release not exist"
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/gitOps/git/commandManager/GitCliManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (impl *GitCliManagerImpl) commit(ctx GitContext, rootDir string, commitMsg

func (impl *GitCliManagerImpl) lastCommitHash(ctx GitContext, rootDir string) (response, errMsg string, err error) {
impl.logger.Debugw("git log ", "location", rootDir)
cmd, cancel := impl.createCmdWithContext(ctx, "git", "-C", rootDir, "log", "--pretty=format:'%h'", "-n", "1")
cmd, cancel := impl.createCmdWithContext(ctx, "git", "-C", rootDir, "log", "--format=format:%H", "-n", "1")
defer cancel()
output, errMsg, err := impl.runCommandWithCred(cmd, ctx.auth)
impl.logger.Debugw("git commit output", "root", rootDir, "opt", output, "errMsg", errMsg, "error", err)
Expand Down

0 comments on commit 9e7e9c3

Please sign in to comment.