Skip to content

Commit

Permalink
fix: deployment timelines fix for helm apps (#3794)
Browse files Browse the repository at this point in the history
* deployment timeline fix for helm apps

* refactored to startedOn
  • Loading branch information
Shivam-nagar23 authored Aug 23, 2023
1 parent fe45d34 commit f1cf1ba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/app/AppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func (impl *AppServiceImpl) UpdateDeploymentStatusForGitOpsPipelines(app *v1alph
// new revision is not reconciled yet, thus status will not be changes and will remain in progress
}
} else {
isValid, installedAppVersionHistory, appId, envId, err := impl.CheckIfPipelineUpdateEventIsValidForAppStore(app.ObjectMeta.Name)
isValid, installedAppVersionHistory, appId, envId, err := impl.CheckIfPipelineUpdateEventIsValidForAppStore(app.ObjectMeta.Name, gitHash)
if err != nil {
impl.logger.Errorw("service err, CheckIfPipelineUpdateEventIsValidForAppStore", "err", err)
return isSucceeded, isTimelineUpdated, err
Expand Down Expand Up @@ -581,7 +581,7 @@ func (impl *AppServiceImpl) UpdateDeploymentStatusForGitOpsPipelines(app *v1alph
return isSucceeded, isTimelineUpdated, nil
}

func (impl *AppServiceImpl) CheckIfPipelineUpdateEventIsValidForAppStore(gitOpsAppName string) (bool, *repository4.InstalledAppVersionHistory, int, int, error) {
func (impl *AppServiceImpl) CheckIfPipelineUpdateEventIsValidForAppStore(gitOpsAppName string, gitHash string) (bool, *repository4.InstalledAppVersionHistory, int, int, error) {
isValid := false
var err error
installedAppVersionHistory := &repository4.InstalledAppVersionHistory{}
Expand Down Expand Up @@ -617,6 +617,18 @@ func (impl *AppServiceImpl) CheckIfPipelineUpdateEventIsValidForAppStore(gitOpsA
impl.logger.Errorw("error in getting appId and environmentId using installedAppVersionId", "err", err, "installedAppVersionId", installedAppVersionHistory.InstalledAppVersionId)
return isValid, installedAppVersionHistory, 0, 0, err
}
if gitHash != "" && installedAppVersionHistory.GitHash != gitHash {
installedAppVersionHistoryByHash, err := impl.installedAppVersionHistoryRepository.GetLatestInstalledAppVersionHistoryByGitHash(gitHash)
if err != nil {
impl.logger.Errorw("error on update application status", "gitHash", gitHash, "installedAppVersionHistory", installedAppVersionHistory, "err", err)
return isValid, installedAppVersionHistory, appId, envId, err
}
if installedAppVersionHistoryByHash.StartedOn.Before(installedAppVersionHistory.StartedOn) {
//we have received trigger hash which is committed before this apps actual gitHash stored by us
// this means that the hash stored by us will be synced later, so we will drop this event
return isValid, installedAppVersionHistory, appId, envId, nil
}
}
if util2.IsTerminalStatus(installedAppVersionHistory.Status) {
//drop event
return isValid, installedAppVersionHistory, appId, envId, nil
Expand Down

0 comments on commit f1cf1ba

Please sign in to comment.