@@ -32,13 +32,15 @@ import (
32
32
"github.com/devtron-labs/devtron/client/argocdServer"
33
33
"github.com/devtron-labs/devtron/internal/constants"
34
34
repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
35
+ cdWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
35
36
"github.com/devtron-labs/devtron/internal/util"
36
37
"github.com/devtron-labs/devtron/pkg/appStatus"
37
38
"github.com/devtron-labs/devtron/pkg/appStore/bean"
38
39
appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
39
40
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
40
41
"github.com/devtron-labs/devtron/pkg/argoApplication"
41
42
bean3 "github.com/devtron-labs/devtron/pkg/argoApplication/bean"
43
+ bean4 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
42
44
"github.com/devtron-labs/devtron/pkg/deployment/common"
43
45
bean2 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
44
46
"github.com/devtron-labs/devtron/pkg/fluxApplication"
@@ -188,6 +190,29 @@ func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Cont
188
190
impl .logger .Errorw ("error in fetching app detail" , "payload" , req , "err" , err )
189
191
}
190
192
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
+ }
191
216
resourceTree = util2 .InterfaceToMapAdapter (detail .ResourceTreeResponse )
192
217
applicationStatus := detail .AppHealthStatus
193
218
if detail .ResourceTreeResponse != nil && len (detail .ResourceTreeResponse .Nodes ) == 0 {
0 commit comments