Skip to content

Commit 6262056

Browse files
fix: panic fix on concurrent deletion request (#6644)
* fix on concurrent request * add logging for missing pipeline objects in workflow and deployment services
1 parent 000d170 commit 6262056

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

pkg/appWorkflow/AppWorkflowService.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ func (impl AppWorkflowServiceImpl) FindAppWorkflowsByEnvironmentId(request resou
616616
}
617617
appResults, envResults := request.CheckAuthBatch(token, appObjectArr, envObjectArr)
618618
for _, pipeline := range pipelines {
619+
if _, ok := objects[pipeline.Id]; !ok {
620+
impl.Logger.Warnw("pipeline not found in objects map", "pipelineId", pipeline.Id)
621+
continue
622+
}
619623
appObject := objects[pipeline.Id][0]
620624
envObject := objects[pipeline.Id][1]
621625
if !(appResults[appObject] && envResults[envObject]) {

pkg/bulkAction/service/BulkUpdateService.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,13 @@ func (impl BulkUpdateServiceImpl) BulkDeploy(request *bean4.BulkApplicationForEn
13361336
pResponse[pipelineKey] = false
13371337
response[appKey] = pResponse
13381338
}
1339+
if _, ok := objects[pipeline.Id]; !ok {
1340+
//if user unauthorized, skip items
1341+
pipelineResponse := response[appKey]
1342+
pipelineResponse[pipelineKey] = false
1343+
response[appKey] = pipelineResponse
1344+
continue
1345+
}
13391346
appObject := objects[pipeline.Id][0]
13401347
envObject := objects[pipeline.Id][1]
13411348
if !(appResults[appObject] && envResults[envObject]) {

pkg/pipeline/CdHandler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ func (impl *CdHandlerImpl) FetchAppWorkflowStatusForTriggerViewForEnvironment(re
735735
// filter out pipelines for unauthorized apps but not envs
736736
appResults, _ := request.CheckAuthBatch(token, appObjectArr, envObjectArr)
737737
for _, pipeline := range pipelines {
738+
if _, ok := objects[pipeline.Id]; !ok {
739+
impl.Logger.Warnw("skipping pipeline as no object found for it", "pipelineId", pipeline.Id)
740+
continue
741+
}
738742
appObject := objects[pipeline.Id][0]
739743
if !(appResults[appObject]) {
740744
// if user unauthorized, skip items
@@ -877,6 +881,10 @@ func (impl *CdHandlerImpl) FetchAppDeploymentStatusForEnvironments(request resou
877881
}
878882
appResults, envResults := request.CheckAuthBatch(token, appObjectArr, envObjectArr)
879883
for _, pipeline := range cdPipelines {
884+
if _, ok := objects[pipeline.Id]; !ok {
885+
impl.Logger.Warnw("skipping pipeline as no object found for it", "pipelineId", pipeline.Id)
886+
continue
887+
}
880888
appObject := objects[pipeline.Id][0]
881889
envObject := objects[pipeline.Id][1]
882890
if !(appResults[appObject] && envResults[envObject]) {

pkg/pipeline/DeploymentPipelineConfigService.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,10 @@ func (impl *CdPipelineConfigServiceImpl) GetCdPipelinesByEnvironmentMin(request
18971897
//authorization block ends here
18981898
span.End()
18991899
for _, dbPipeline := range pipelines {
1900+
if _, ok := objects[dbPipeline.Id]; !ok {
1901+
impl.logger.Warnw("no objects found for pipeline", "pipelineId", dbPipeline.Id)
1902+
continue
1903+
}
19001904
appObject := objects[dbPipeline.Id][0]
19011905
envObject := objects[dbPipeline.Id][1]
19021906
if !(appResults[appObject] && envResults[envObject]) {
@@ -2133,6 +2137,10 @@ func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter
21332137

21342138
pipelinesMap := make(map[int][]*pipelineConfig.Pipeline)
21352139
for _, pipeline := range cdPipelines {
2140+
if _, ok := objects[pipeline.Id]; !ok {
2141+
impl.logger.Warnw("skipping pipeline as no object found for it", "pipelineId", pipeline.Id)
2142+
continue
2143+
}
21362144
appObject := objects[pipeline.Id][0]
21372145
envObject := objects[pipeline.Id][1]
21382146
if !(appResults[appObject] && envResults[envObject]) {

pkg/pipeline/DevtronAppConfigService.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ func (impl *DevtronAppConfigServiceImpl) GetAppListForEnvironment(request resour
222222
}
223223
appResults, envResults := request.CheckAuthBatch(token, appObjectArr, envObjectArr)
224224
for _, pipeline := range cdPipelines {
225+
if _, ok := objects[pipeline.Id]; !ok {
226+
impl.logger.Warnw("skipping pipeline as no app and env object found", "pipelineId", pipeline.Id)
227+
continue
228+
}
225229
appObject := objects[pipeline.Id][0]
226230
envObject := objects[pipeline.Id][1]
227231
if !(appResults[appObject] && envResults[envObject]) {

0 commit comments

Comments
 (0)