Skip to content
Merged
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
49 changes: 0 additions & 49 deletions pkg/workflow/dag/WorkflowDagExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,6 @@ func (impl *WorkflowDagExecutorImpl) HandlePreStageSuccessEvent(triggerContext t
}
util4.MergeMaps(pluginArtifacts, cdStageCompleteEvent.PluginRegistryArtifactDetails)

err = impl.deactivateUnusedPaths(wfRunner.ImagePathReservationIds, pluginArtifacts)
if err != nil {
impl.logger.Errorw("error in deactiving unusedImagePaths", "err", err)
return err
}

pipeline, err := impl.pipelineRepository.FindById(cdStageCompleteEvent.CdPipelineId)
if err != nil {
return err
Expand Down Expand Up @@ -657,13 +651,6 @@ func (impl *WorkflowDagExecutorImpl) HandlePostStageSuccessEvent(triggerContext
return err
}
if len(pluginRegistryImageDetails) > 0 {
if wfr != nil {
err = impl.deactivateUnusedPaths(wfr.ImagePathReservationIds, pluginRegistryImageDetails)
if err != nil {
impl.logger.Errorw("error in deactivation images", "err", err)
return err
}
}
PostCDArtifacts, err := impl.commonArtifactService.SavePluginArtifacts(ciArtifact, pluginRegistryImageDetails, cdPipelineId, repository.POST_CD, triggeredBy)
if err != nil {
impl.logger.Errorw("error in saving plugin artifacts", "err", err)
Expand Down Expand Up @@ -719,11 +706,6 @@ func (impl *WorkflowDagExecutorImpl) UpdateCiWorkflowForCiSuccess(request *bean2
return err
}

err = impl.deactivateUnusedPaths(savedWorkflow.ImagePathReservationIds, request.PluginRegistryArtifactDetails)
if err != nil {
impl.logger.Errorw("error in deactivation images", "err", err)
return err
}
return nil
}

Expand Down Expand Up @@ -894,37 +876,6 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger
return buildArtifact.Id, err
}

func (impl *WorkflowDagExecutorImpl) deactivateUnusedPaths(reserveImagePathIds []int, pluginRegistryArtifactDetails map[string][]string) error {
// for copy container image plugin if images reserved are not equal to actual copird
reservedImagePaths, err := impl.customTagService.GetImagePathsByIds(reserveImagePathIds)
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("error in getting imagePaths by ids", "ImagePathReservationIds", reserveImagePathIds, "err", err)
return err
}

copiedImagesMapping := make(map[string]bool)
for _, savedImages := range pluginRegistryArtifactDetails {
for _, image := range savedImages {
copiedImagesMapping[image] = true
}
}

unusedPaths := make([]string, 0, len(reservedImagePaths))
for _, reservedImage := range reservedImagePaths {
if _, ok := copiedImagesMapping[reservedImage.ImagePath]; !ok {
unusedPaths = append(unusedPaths, reservedImage.ImagePath)
}
}

err = impl.customTagService.DeactivateImagePathReservationByImagePath(unusedPaths)
if err != nil {
impl.logger.Errorw("error in deactivating unused image paths", "imagePathReservationIds", reserveImagePathIds, "err", err)
return err
}

return nil
}

func (impl *WorkflowDagExecutorImpl) WriteCiSuccessEvent(request *bean2.CiArtifactWebhookRequest, pipeline *pipelineConfig.CiPipeline, artifact *repository.CiArtifact) {
event, _ := impl.eventFactory.Build(util2.Success, &pipeline.Id, pipeline.AppId, nil, util2.CI)
event.CiArtifactId = artifact.Id
Expand Down