Skip to content

Commit

Permalink
fix(concourse): Fix caching of concourse build events (#525)
Browse files Browse the repository at this point in the history
Builds should be added to cache correctly now and the admin fastforward command should work
spinnaker/spinnaker#5047
  • Loading branch information
donnyyung authored and mergify[bot] committed Oct 23, 2019
1 parent 2f44740 commit 9430260
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ private JobDelta jobDelta(ConcourseProperties.Host host, Job job) {
List<GenericBuild> genericBuilds =
builds.stream()
.map(build -> concourseService.getGenericBuild(jobPath, build, false))
.filter(b -> !cache.getEventPosted(host, job, cursor, b.getNumber()))
.collect(Collectors.toList());

if (genericBuilds.size() == 0) {
cache.setLastPollCycleTimestamp(host, job, cursor);
return null;
}

return new JobDelta(host, job, cursor, lowerBound, upperBound, genericBuilds);
}

Expand All @@ -152,17 +158,26 @@ protected void commitDelta(JobPollingDelta delta, boolean sendEvents) {
jobDelta.getHost(), jobDelta.getJob(), jobDelta.getCursor(), build.getNumber());
if (!eventPosted && sendEvents) {
sendEventForBuild(jobDelta.getHost(), jobDelta.getJob(), build);
cache.setEventPosted(
jobDelta.getHost(), jobDelta.getJob(), jobDelta.getCursor(), build.getNumber());
}
log.info(
"({}) caching build {} for : {}",
jobDelta.getHost().getName(),
build.getNumber(),
build.getFullDisplayName());
cache.setEventPosted(
jobDelta.getHost(), jobDelta.getJob(), jobDelta.getCursor(), build.getNumber());
}
cache.setLastPollCycleTimestamp(jobDelta.getHost(), jobDelta.getJob(), jobDelta.getCursor());
}
}

private void sendEventForBuild(ConcourseProperties.Host host, Job job, GenericBuild build) {
if (echoService.isPresent()) {
log.info("({}) pushing event for : {}", host.getName(), build.getFullDisplayName());
log.info(
"({}) pushing build {} for : {}",
host.getName(),
build.getNumber(),
build.getFullDisplayName());

GenericProject project =
new GenericProject(
Expand Down

0 comments on commit 9430260

Please sign in to comment.