@@ -1442,14 +1442,16 @@ func (impl CiCdPipelineOrchestratorImpl) CreateMaterials(createMaterialRequest *
1442
1442
}
1443
1443
materials = append (materials , inputMaterial )
1444
1444
}
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 )
1446
1448
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 )
1448
1450
return nil , err
1449
1451
}
1450
- err = impl .transactionManager . CommitTx ( tx )
1452
+ err = impl .addRepositoryToGitSensor ( materials , "" )
1451
1453
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 )
1453
1455
return nil , err
1454
1456
}
1455
1457
impl .logger .Debugw ("all materials are " , "materials" , materials )
@@ -1467,18 +1469,18 @@ func (impl CiCdPipelineOrchestratorImpl) UpdateMaterial(updateMaterialDTO *bean.
1467
1469
impl .logger .Errorw ("err" , "err" , err )
1468
1470
return nil , err
1469
1471
}
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
+ }
1470
1477
1471
1478
err = impl .updateRepositoryToGitSensor (updatedMaterial , "" ,
1472
1479
updateMaterialDTO .Material .CreateBackup )
1473
1480
if err != nil {
1474
1481
impl .logger .Errorw ("error in updating to git-sensor" , "err" , err )
1475
1482
return nil , err
1476
1483
}
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
- }
1482
1484
return updateMaterialDTO , nil
1483
1485
}
1484
1486
0 commit comments