fix(pruneOrphan): convert nomad expirtyTime from ns to ms#170
fix(pruneOrphan): convert nomad expirtyTime from ns to ms#170arsiesys wants to merge 1 commit intojenkinsci:masterfrom
Conversation
| String jobRegion = job.getString("Region"); | ||
| Instant expiryTime = Instant.ofEpochMilli(job.getLong("SubmitTime")); | ||
| expiryTime.plusSeconds(this.workerTimeout * 60); | ||
| Instant expiryTime = Instant.ofEpochMilli(Math.round(job.getLong("SubmitTime")/1000000)); |
There was a problem hiding this comment.
Thanks for the fix!
You have to fix the "SpotBugs-finding" first in order to get the build green. Suggestion, just remove Math.round like below:
Instant expiryTime = Instant.ofEpochMilli(job.getLong("SubmitTime") / 1000000);
expiryTime = expiryTime.plusSeconds(this.workerTimeout * 60L);
There was a problem hiding this comment.
I used math.Float because ofEpochMilli is expececting a long and the divide to convert to ns generate a number with decimals result of a BigDecimal type. The Math.Round solved both issues (remove the decimals + return a long).
I pushed a different way to do it (and tested it), hope it's a better way ! :D
groovy.lang.MissingMethodException: No signature of method: static java.time.Instant.toEpochMilli() is applicable for argument types: (java.math.BigDecimal) values: [1671487054166.230409]
Possible solutions: toEpochMilli(), ofEpochMilli(long)
There was a problem hiding this comment.
I adjusted the expiry time calculation so that it is more clear. Could you please check whether this is working for you?
33b20e2 to
7ef8ac8
Compare
|
Also, I think this fix should come with a warning.. As this feature wasn't working before. |
7ef8ac8 to
79a6c7d
Compare
Makes sense, we could add something like this to the release notes I guess.
tbh, I'm not familiar with the prune feature but I guess you are right, that could be the case. We should add a warning which is displayed right to the prune option so that the user is at least aware of the risk. Maybe we could also migrate the cloud configurations so that the prune feature is deactivated for all existing configurations and must be activated actively. |
|
Hi, |
|
I tested and running this patch in our environment its work well |
79a6c7d to
cc0811d
Compare
We are using Nomad 1.4.3 and jenkins 2.361.4.
I noticed that the pruneOrphan feature wasn't working on our side.
After digging, I noticed two anomalies:
I address the previous anomalies by converting the parsed values to milliseconds and update the expirtyTime variable with the added timeout.
I did a small fix that seems to work on our side based on my first tests:
I am far away of being an expert with Java. If this PR need some "touch up", please help! :)
Thanks !