Skip to content

Commit 8ab82be

Browse files
authored
misc: remove environment null check while getting chart via repo url (#6061)
* remove environment null check * remove UpdateDeploymentStatusAndCheckIsSucceeded in favour of impl.appService.UpdateDeploymentStatusForGitOpsPipelines * update test file * Revert "remove environment null check" This reverts commit 9d4dc6a. * revert test change of environment is null * Revert "revert test change of environment is null" This reverts commit 9e9a45d.
1 parent 127203b commit 8ab82be

File tree

3 files changed

+2
-61
lines changed

3 files changed

+2
-61
lines changed

pkg/app/AppService.go

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ type AppServiceImpl struct {
129129

130130
type AppService interface {
131131
UpdateReleaseStatus(request *bean.ReleaseStatusUpdateRequest) (bool, error)
132-
UpdateDeploymentStatusAndCheckIsSucceeded(app *v1alpha1.Application, statusTime time.Time, isAppStore bool) (bool, *chartConfig.PipelineOverride, error)
133132
GetConfigMapAndSecretJson(appId int, envId int, pipelineId int) ([]byte, error)
134133
UpdateCdWorkflowRunnerByACDObject(app *v1alpha1.Application, cdWfrId int, updateTimedOutStatus bool) error
135134
GetCmSecretNew(appId int, envId int, isJob bool, scope resourceQualifiers.Scope) (*bean.ConfigMapJson, *bean.ConfigSecretJson, error)
@@ -211,64 +210,6 @@ func (impl *AppServiceImpl) UpdateReleaseStatus(updateStatusRequest *bean.Releas
211210
return count == 1, nil
212211
}
213212

214-
func (impl *AppServiceImpl) UpdateDeploymentStatusAndCheckIsSucceeded(app *v1alpha1.Application, statusTime time.Time, isAppStore bool) (bool, *chartConfig.PipelineOverride, error) {
215-
isSucceeded := false
216-
var err error
217-
var pipelineOverride *chartConfig.PipelineOverride
218-
if isAppStore {
219-
var installAppDeleteRequest repository4.InstallAppDeleteRequest
220-
var gitHash string
221-
if app.Operation != nil && app.Operation.Sync != nil {
222-
gitHash = app.Operation.Sync.Revision
223-
} else if app.Status.OperationState != nil && app.Status.OperationState.Operation.Sync != nil {
224-
gitHash = app.Status.OperationState.Operation.Sync.Revision
225-
}
226-
installAppDeleteRequest, err = impl.installedAppRepository.GetInstalledAppByGitHash(gitHash)
227-
if err != nil {
228-
impl.logger.Errorw("error in fetching installed app by git hash from installed app repository", "err", err)
229-
return isSucceeded, pipelineOverride, err
230-
}
231-
if installAppDeleteRequest.EnvironmentId > 0 {
232-
err = impl.appStatusService.UpdateStatusWithAppIdEnvId(installAppDeleteRequest.AppId, installAppDeleteRequest.EnvironmentId, string(app.Status.Health.Status))
233-
if err != nil {
234-
impl.logger.Errorw("error occurred while updating app status in app_status table", "error", err, "appId", installAppDeleteRequest.AppId, "envId", installAppDeleteRequest.EnvironmentId)
235-
}
236-
impl.logger.Debugw("skipping application status update as this app is chart", "appId", installAppDeleteRequest.AppId, "envId", installAppDeleteRequest.EnvironmentId)
237-
}
238-
} else {
239-
repoUrl := app.Spec.Source.RepoURL
240-
// backward compatibility for updating application status - if unable to find app check it in charts
241-
chart, err := impl.chartRepository.FindChartByGitRepoUrl(repoUrl)
242-
if err != nil {
243-
impl.logger.Errorw("error in fetching chart", "repoUrl", repoUrl, "err", err)
244-
return isSucceeded, pipelineOverride, err
245-
}
246-
if chart == nil {
247-
impl.logger.Errorw("no git repo found for url", "repoUrl", repoUrl)
248-
return isSucceeded, pipelineOverride, fmt.Errorf("no git repo found for url %s", repoUrl)
249-
}
250-
envId, err := impl.appRepository.FindEnvironmentIdForInstalledApp(chart.AppId)
251-
if err != nil {
252-
impl.logger.Errorw("error in fetching app", "err", err, "app", chart.AppId)
253-
return isSucceeded, pipelineOverride, err
254-
}
255-
if envId > 0 {
256-
err = impl.appStatusService.UpdateStatusWithAppIdEnvId(chart.AppId, envId, string(app.Status.Health.Status))
257-
if err != nil {
258-
impl.logger.Errorw("error occurred while updating app status in app_status table", "error", err, "appId", chart.AppId, "envId", envId)
259-
}
260-
impl.logger.Debugw("skipping application status update as this app is chart", "appId", chart.AppId, "envId", envId)
261-
}
262-
}
263-
264-
isSucceeded, _, pipelineOverride, err = impl.UpdateDeploymentStatusForGitOpsPipelines(app, statusTime, isAppStore)
265-
if err != nil {
266-
impl.logger.Errorw("error in updating deployment status", "argoAppName", app.Name)
267-
return isSucceeded, pipelineOverride, err
268-
}
269-
return isSucceeded, pipelineOverride, nil
270-
}
271-
272213
func (impl *AppServiceImpl) ComputeAppstatus(appId, envId int, status health2.HealthStatusCode) (string, error) {
273214
appStatusInternal := string(status)
274215

pkg/app/integrationTest/AppService_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestAppServiceImpl_UpdateDeploymentStatusAndCheckIsSucceeded(t *testing.T)
104104
wantErr: wantErr,
105105
}
106106
t.Run(tt.name, func(t *testing.T) {
107-
got, _, err := appService.UpdateDeploymentStatusAndCheckIsSucceeded(tt.args.app, tt.args.statusTime, false)
107+
got, _, _, err := appService.UpdateDeploymentStatusForGitOpsPipelines(tt.args.app, tt.args.statusTime, false)
108108
if (err != nil) != tt.wantErr {
109109
t.Errorf("UpdateDeploymentStatusAndCheckIsSucceeded() error = %v, wantErr %v", err, tt.wantErr)
110110
return

pkg/eventProcessor/in/DeployedApplicationEventProcessorService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (impl *DeployedApplicationEventProcessorImpl) SubscribeArgoAppUpdate() erro
124124
return
125125
}
126126
}
127-
isSucceeded, pipelineOverride, err := impl.appService.UpdateDeploymentStatusAndCheckIsSucceeded(app, applicationDetail.StatusTime, isAppStoreApplication)
127+
isSucceeded, _, pipelineOverride, err := impl.appService.UpdateDeploymentStatusForGitOpsPipelines(app, applicationDetail.StatusTime, isAppStoreApplication)
128128
if err != nil {
129129
impl.logger.Errorw("error on application status update", "err", err, "msg", string(msg.Data))
130130
// TODO - check update for charts - fix this call

0 commit comments

Comments
 (0)