From cc0811dff0d05c3cc58697a3b0db6d3fc8fa49d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yavercovski?= Date: Mon, 19 Dec 2022 16:21:10 -0500 Subject: [PATCH] fix(pruneOrphan): convert nomad expirtyTime from ns to ms --- src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java b/src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java index ea8a4e38..38934e44 100644 --- a/src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java +++ b/src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java @@ -7,6 +7,7 @@ import static com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -177,8 +178,9 @@ private void pruneOrphanedWorkers(NomadWorkerTemplate template) { String jobNamespace = worker.getJobSummary().getNamespace(); JSONObject job = this.nomad.getRunningWorker(jobSummary.getJobID(), jobNamespace); String jobRegion = job.getString("Region"); - Instant expiryTime = Instant.ofEpochMilli(job.getLong("SubmitTime")); - expiryTime.plusSeconds(this.workerTimeout * 60); + Instant expiryTime = Instant.EPOCH + .plusNanos(job.getLong("SubmitTime")) + .plus(workerTimeout, ChronoUnit.MINUTES); Instant now = Instant.now(); if (now.isAfter(expiryTime)) { LOGGER.log(Level.FINE, "Found Orphaned Node: " + worker.getID() + " in namespace " + jobNamespace + " in region " + jobRegion);