Skip to content

Commit

Permalink
fix(plugins): Only trigger off new releases (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert authored May 12, 2020
1 parent 11561ec commit bdb77d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected void commitDelta(PluginPollingDelta delta, boolean sendEvents) {
});

delta.items.stream()
.map(it -> Instant.parse(it.pluginRelease.getTimestamp()))
.map(it -> Instant.parse(it.pluginRelease.getReleaseDate()))
.max(Comparator.naturalOrder())
.ifPresent(cache::setLastPollCycleTimestamp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -45,12 +44,12 @@ public List<PluginRelease> getPluginReleasesSince(Instant timestamp) {
.filter(
r -> {
try {
return Instant.parse(r.getTimestamp()).isAfter(timestamp);
return Instant.parse(r.getReleaseDate()).isAfter(timestamp);
} catch (DateTimeParseException e) {
log.error(
"Failed parsing plugin timestamp for '{}': '{}', cannot index plugin",
r.getPluginId(),
getTimestamp(r));
r.getReleaseDate());
return false;
}
})
Expand All @@ -76,8 +75,4 @@ private List<PluginRelease> getPluginReleases() {
release.lastModified)))
.collect(Collectors.toList()));
}

private String getTimestamp(PluginRelease release) {
return Optional.ofNullable(release.getLastModified()).orElse(release.getReleaseDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
*/
package com.netflix.spinnaker.igor.plugins.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
import java.util.Optional;

public class PluginRelease {
private final String pluginId;
Expand Down Expand Up @@ -74,11 +72,6 @@ public String getLastModified() {
return lastModified;
}

@JsonIgnore
public String getTimestamp() {
return Optional.ofNullable(lastModified).orElse(releaseDate);
}

public static class ServiceRequirement {
private final String service;
private final String operator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class PluginReleaseServiceSpec extends Specification {
clock.instant().plus(2, ChronoUnit.DAYS) || []
}

private PluginInfo.Release release(String version, Instant lastModified) {
private PluginInfo.Release release(String version, Instant releaseDate) {
return new PluginInfo.Release(
version,
clock.instant().toString(),
releaseDate.toString(),
"orca>=0.0.0",
"http://example.com/file.zip",
true,
lastModified.toString(),
clock.instant().toString(),
)
}
}

0 comments on commit bdb77d0

Please sign in to comment.