Skip to content

Commit ea27b33

Browse files
committed
wip
1 parent 869270f commit ea27b33

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ import (
3232
"github.com/devtron-labs/devtron/client/argocdServer"
3333
"github.com/devtron-labs/devtron/internal/constants"
3434
repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
35+
cdWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
3536
"github.com/devtron-labs/devtron/internal/util"
3637
"github.com/devtron-labs/devtron/pkg/appStatus"
3738
"github.com/devtron-labs/devtron/pkg/appStore/bean"
3839
appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
3940
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
4041
"github.com/devtron-labs/devtron/pkg/argoApplication"
4142
bean3 "github.com/devtron-labs/devtron/pkg/argoApplication/bean"
43+
bean4 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
4244
"github.com/devtron-labs/devtron/pkg/deployment/common"
4345
bean2 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
4446
"github.com/devtron-labs/devtron/pkg/fluxApplication"
@@ -188,6 +190,29 @@ func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Cont
188190
impl.logger.Errorw("error in fetching app detail", "payload", req, "err", err)
189191
}
190192
if detail != nil {
193+
iaVersion, err := impl.installedAppRepositoryHistory.GetLatestInstalledAppVersionHistoryByInstalledAppId(installedApp.Id)
194+
if err != nil {
195+
impl.logger.Errorw("error in fetching latest installed app version history", "err", err)
196+
} else if iaVersion != nil {
197+
switch detail.FluxAppStatusDetail.Reason {
198+
case bean5.InstallSucceededReason, bean5.UpgradeSucceededReason, bean5.TestSucceededReason, bean5.RollbackSucceededReason:
199+
if detail.AppHealthStatus == commonBean.HealthStatusHealthy {
200+
iaVersion.Status = cdWorkflow2.WorkflowSucceeded
201+
}
202+
case bean5.UpgradeFailedReason,
203+
bean5.TestFailedReason,
204+
bean5.RollbackFailedReason,
205+
bean5.UninstallFailedReason,
206+
bean5.ArtifactFailedReason,
207+
bean5.InstallFailedReason:
208+
iaVersion.Status = cdWorkflow2.WorkflowFailed
209+
}
210+
iaVersion.UpdateAuditLog(bean4.SYSTEM_USER_ID)
211+
_, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(iaVersion, nil)
212+
if err != nil {
213+
impl.logger.Errorw("error in updating app version history", "err", err)
214+
}
215+
}
191216
resourceTree = util2.InterfaceToMapAdapter(detail.ResourceTreeResponse)
192217
applicationStatus := detail.AppHealthStatus
193218
if detail.ResourceTreeResponse != nil && len(detail.ResourceTreeResponse.Nodes) == 0 {

0 commit comments

Comments
 (0)