Skip to content

Commit

Permalink
#1908 show hours
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Feb 28, 2024
1 parent 439c395 commit 6f4b30c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/rultor/agents/aws/PrunesInstances.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void execute(final Talks talks) throws IOException {
new DescribeInstancesRequest()
.withFilters(new Filter().withName("tag:rultor").withValues("yes"))
);
final long threshold = new Date().getTime() - TimeUnit.HOURS.toMillis(6L);
final Collection<String> seen = new LinkedList<>();
for (final Reservation rsrv : res.getReservations()) {
final Instance instance = rsrv.getInstances().get(0);
Expand All @@ -84,15 +83,17 @@ public void execute(final Talks talks) throws IOException {
.withIncludeAllInstances(true)
.withInstanceIds(instance.getInstanceId())
).getInstanceStatuses().get(0).getInstanceState().getName();
final double hours =
(double) (new Date().getTime() - instance.getLaunchTime().getTime())
/ TimeUnit.HOURS.toMillis(1L);
final String label = String.format(
"%s/%s/%s",
"%s/%s/%s/%.2fh",
instance.getInstanceId(),
instance.getInstanceType(),
status
status, hours
);
seen.add(label);
final Date time = instance.getLaunchTime();
if (time.getTime() > threshold) {
if (hours < 8.0d) {
continue;
}
if ("terminated".equals(status)) {
Expand Down

0 comments on commit 6f4b30c

Please sign in to comment.