Skip to content

Commit

Permalink
Issue #1711 Pipeline Runs shall not be deleted with parent Pipeline -…
Browse files Browse the repository at this point in the history
… fix pipelineName for pause/resume operations
  • Loading branch information
mzueva committed Apr 22, 2021
1 parent c3c8012 commit 280db60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package com.epam.pipeline.manager.notification;

import com.epam.pipeline.entity.pipeline.Pipeline;
import com.epam.pipeline.entity.pipeline.PipelineRun;
import com.epam.pipeline.entity.pipeline.run.RunStatus;
import com.epam.pipeline.entity.utils.DateUtils;
import com.epam.pipeline.manager.pipeline.PipelineManager;
import com.epam.pipeline.manager.pipeline.RunStatusManager;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
Expand All @@ -40,9 +38,6 @@ public class NotificationAspect {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificationAspect.class);
public static final String RESUME_RUN_FAILED = "Resume run failed.";

@Autowired
private PipelineManager pipelineManager;

@Autowired
private NotificationManager notificationManager;

Expand Down Expand Up @@ -78,20 +73,9 @@ public void notifyRunStatusChanged(JoinPoint joinPoint, PipelineRun run) {
run.getVersion(), run.getStatus());
return;
}

if (run.getPipelineName() == null) {
if (run.getPipelineId() != null) {
Pipeline pipeline = pipelineManager.load(run.getPipelineId());
run.setPipelineName(pipeline.getName());
} else {
run.setPipelineName("pipeline");
}
}

LOGGER.debug("Notify all about pipelineRun status changed {} {} {}: {}",
run.getPodId(), run.getPipelineName(), run.getVersion(), run.getStatus());
notificationManager.notifyRunStatusChanged(run);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.epam.pipeline.config.JsonMapper;
import com.epam.pipeline.entity.pipeline.PipelineRun;
import com.epam.pipeline.entity.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;

public final class PipelineRunMapper {
private static final int SECONDS_IN_MINUTE = 60;
Expand All @@ -41,6 +42,10 @@ public static Map<String, Object> map(PipelineRun run, Long threshold, Long dura
Map<String, Object> params = mapper.convertValue(run, mapper.getTypeFactory()
.constructParametricType(Map.class, String.class, Object.class));

if (StringUtils.isBlank(run.getPipelineName())) {
params.put("pipelineName", PipelineRun.DEFAULT_PIPELINE_NAME);
}

if (threshold != null) {
params.put("timeThreshold", threshold / SECONDS_IN_MINUTE);
}
Expand Down

0 comments on commit 280db60

Please sign in to comment.