Skip to content

Commit

Permalink
fix(pruneOrphan): convert nomad expirtyTime from ns to ms
Browse files Browse the repository at this point in the history
  • Loading branch information
arsiesys committed Dec 20, 2022
1 parent 4451a19 commit 7ef8ac8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/jenkinsci/plugins/nomad/NomadCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,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);
long expiryTimeMilli = job.getLong("SubmitTime")/1000000;
Instant expiryTime = Instant.ofEpochMilli(expiryTimeMilli);
expiryTime = expiryTime.plusSeconds(this.workerTimeout * 60);
Instant now = Instant.now();
if (now.isAfter(expiryTime)) {
LOGGER.log(Level.FINE, "Found Orphaned Node: " + worker.getID() + " in namespace " + jobNamespace + " in region " + jobRegion);
Expand Down

0 comments on commit 7ef8ac8

Please sign in to comment.