Skip to content

Commit 18772fd

Browse files
authored
wip: making tx independent of git sensor call (#6519)
1 parent 1815677 commit 18772fd

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pkg/pipeline/CiCdPipelineOrchestrator.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,16 @@ func (impl CiCdPipelineOrchestratorImpl) CreateMaterials(createMaterialRequest *
14421442
}
14431443
materials = append(materials, inputMaterial)
14441444
}
1445-
err = impl.addRepositoryToGitSensor(materials, "")
1445+
// moving transaction before addRepositoryToGitSensor as commiting transaction after addRepositoryToGitSensor was causing problems
1446+
// in case request was cancelled data was getting saved in git sensor but not getting saved in orchestrator db. Same is done in update flow.
1447+
err = impl.transactionManager.CommitTx(tx)
14461448
if err != nil {
1447-
impl.logger.Errorw("error in updating to sensor", "err", err)
1449+
impl.logger.Errorw("error in committing tx Create material", "err", err, "materials", materials)
14481450
return nil, err
14491451
}
1450-
err = impl.transactionManager.CommitTx(tx)
1452+
err = impl.addRepositoryToGitSensor(materials, "")
14511453
if err != nil {
1452-
impl.logger.Errorw("error in committing tx Create material", "err", err, "materials", materials)
1454+
impl.logger.Errorw("error in updating to sensor", "err", err)
14531455
return nil, err
14541456
}
14551457
impl.logger.Debugw("all materials are ", "materials", materials)
@@ -1467,18 +1469,18 @@ func (impl CiCdPipelineOrchestratorImpl) UpdateMaterial(updateMaterialDTO *bean.
14671469
impl.logger.Errorw("err", "err", err)
14681470
return nil, err
14691471
}
1472+
err = impl.transactionManager.CommitTx(tx)
1473+
if err != nil {
1474+
impl.logger.Errorw("error in committing tx Create material", "err", err)
1475+
return nil, err
1476+
}
14701477

14711478
err = impl.updateRepositoryToGitSensor(updatedMaterial, "",
14721479
updateMaterialDTO.Material.CreateBackup)
14731480
if err != nil {
14741481
impl.logger.Errorw("error in updating to git-sensor", "err", err)
14751482
return nil, err
14761483
}
1477-
err = impl.transactionManager.CommitTx(tx)
1478-
if err != nil {
1479-
impl.logger.Errorw("error in committing tx Update material", "err", err)
1480-
return nil, err
1481-
}
14821484
return updateMaterialDTO, nil
14831485
}
14841486

wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)