Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/router/pubsub/ApplicationStatusHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (impl *ApplicationStatusHandlerImpl) updateArgoAppDeleteStatus(app *v1alpha
}
} else {
// devtron app
err = impl.pipelineBuilder.DeleteCdPipeline(&pipeline, context.Background(), true, false, 0)
err = impl.pipelineBuilder.DeleteCdPipeline(&pipeline, context.Background(), true, false, 1)
if err != nil {
impl.logger.Errorw("error in deleting cd pipeline", "err", err)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type PipelineRepository interface {
Save(pipeline []*Pipeline, tx *pg.Tx) error
Update(pipeline *Pipeline, tx *pg.Tx) error
FindActiveByAppId(appId int) (pipelines []*Pipeline, err error)
Delete(id int, tx *pg.Tx) error
Delete(id int, userId int32, tx *pg.Tx) error
FindByName(pipelineName string) (pipeline *Pipeline, err error)
PipelineExists(pipelineName string) (bool, error)
FindById(id int) (pipeline *Pipeline, err error)
Expand Down Expand Up @@ -248,9 +248,10 @@ func (impl PipelineRepositoryImpl) FindActiveByAppIdAndEnvironmentIdV2() (pipeli
return pipelines, err
}

func (impl PipelineRepositoryImpl) Delete(id int, tx *pg.Tx) error {
func (impl PipelineRepositoryImpl) Delete(id int, userId int32, tx *pg.Tx) error {
pipeline := &Pipeline{}
r, err := tx.Model(pipeline).Set("deleted =?", true).Set("deployment_app_created =?", false).Where("id =?", id).Update()
r, err := tx.Model(pipeline).Set("deleted =?", true).Set("deployment_app_created =?", false).
Set("updated_on = ?", time.Now()).Set("updated_by = ?", userId).Where("id =?", id).Update()
impl.logger.Debugw("update result", "r-affected", r.RowsAffected(), "r-return", r.RowsReturned(), "model", r.Model())
return err
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pkg/pipeline/CiCdPipelineOrchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type CiCdPipelineOrchestrator interface {
CreateCDPipelines(pipelineRequest *bean.CDPipelineConfigObject, appId int, userId int32, tx *pg.Tx, appName string) (pipelineId int, err error)
UpdateCDPipeline(pipelineRequest *bean.CDPipelineConfigObject, userId int32, tx *pg.Tx) (err error)
DeleteCiPipeline(pipeline *pipelineConfig.CiPipeline, request *bean.CiPatchRequest, tx *pg.Tx) error
DeleteCdPipeline(pipelineId int, tx *pg.Tx) error
DeleteCdPipeline(pipelineId int, userId int32, tx *pg.Tx) error
PatchMaterialValue(createRequest *bean.CiPipeline, userId int32, oldPipeline *pipelineConfig.CiPipeline) (*bean.CiPipeline, error)
PipelineExists(name string) (bool, error)
GetCdPipelinesForApp(appId int) (cdPipelines *bean.CdPipelines, err error)
Expand Down Expand Up @@ -1175,6 +1175,9 @@ func (impl CiCdPipelineOrchestratorImpl) CreateCDPipelines(pipelineRequest *bean
impl.logger.Error(err)
return 0, err
}



env, err := impl.envRepository.FindById(pipelineRequest.EnvironmentId)
if err != nil {
impl.logger.Errorw("error in getting environment by id", "err", err)
Expand Down Expand Up @@ -1290,8 +1293,8 @@ func (impl CiCdPipelineOrchestratorImpl) UpdateCDPipeline(pipelineRequest *bean.
return err
}

func (impl CiCdPipelineOrchestratorImpl) DeleteCdPipeline(pipelineId int, tx *pg.Tx) error {
return impl.pipelineRepository.Delete(pipelineId, tx)
func (impl CiCdPipelineOrchestratorImpl) DeleteCdPipeline(pipelineId int, userId int32, tx *pg.Tx) error {
return impl.pipelineRepository.Delete(pipelineId, userId, tx)
}

func (impl CiCdPipelineOrchestratorImpl) PipelineExists(name string) (bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pipeline/PipelineBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ func (impl PipelineBuilderImpl) DeleteCdPipeline(pipeline *pipelineConfig.Pipeli
}
// Rollback tx on error.
defer tx.Rollback()
if err = impl.ciCdPipelineOrchestrator.DeleteCdPipeline(pipeline.Id, tx); err != nil {
if err = impl.ciCdPipelineOrchestrator.DeleteCdPipeline(pipeline.Id, userId, tx); err != nil {
impl.logger.Errorw("err in deleting pipeline from db", "id", pipeline, "err", err)
return err
}
Expand Down Expand Up @@ -3843,7 +3843,7 @@ func (impl PipelineBuilderImpl) MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDelete
}
impl.logger.Warnw("app not found in argo, deleting from db ", "err", err)
//make call to delete it from pipeline DB because it's ACD counterpart is deleted
err = impl.DeleteCdPipeline(pipeline, context.Background(), true, false, 0)
err = impl.DeleteCdPipeline(pipeline, context.Background(), true, false, 1)
if err != nil {
impl.logger.Errorw("error in deleting cd pipeline", "err", err)
return acdAppFound, err
Expand Down