-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added minimum uphours feature #377
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also write a test?
@@ -32,29 +32,29 @@ | |||
private static final Logger LOGGER = Logger.getLogger(EC2OndemandSlave.class.getName()); | |||
|
|||
@Deprecated | |||
public EC2OndemandSlave(String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType) | |||
public EC2OndemandSlave(String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType, String minUpHours) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not add the new option to deprecated constructors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me see if i can bypass them
|
||
public String getMinUpHours() { | ||
return minUpHours; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind the indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm , not sure why my eclipse is messing up formatting only for this line. Let me use text editor in next commit
@@ -33,23 +33,23 @@ | |||
private final String spotInstanceRequestId; | |||
|
|||
@Deprecated | |||
public EC2SpotSlave(String name, String spotInstanceRequestId, String description, String remoteFS, int numExecutors, Mode mode, String initScript, String tmpDir, String labelString, String remoteAdmin, String jvmopts, String idleTerminationMinutes, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType) | |||
public EC2SpotSlave(String name, String spotInstanceRequestId, String description, String remoteFS, int numExecutors, Mode mode, String initScript, String tmpDir, String labelString, String remoteAdmin, String jvmopts, String idleTerminationMinutes, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType, String minUpHours) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here on deprecated constructors
@@ -175,7 +177,7 @@ public SlaveTemplate(String ami, String zone, SpotConfiguration spotConfig, Stri | |||
String instanceCapStr, String iamInstanceProfile, boolean deleteRootOnTermination, | |||
boolean useEphemeralDevices, boolean useDedicatedTenancy, String launchTimeoutStr, boolean associatePublicIp, | |||
String customDeviceMapping, boolean connectBySSHProcess, boolean monitoring, | |||
boolean t2Unlimited, ConnectionStrategy connectionStrategy, int maxTotalUses) { | |||
boolean t2Unlimited, ConnectionStrategy connectionStrategy, int maxTotalUses, String minUpHours) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the ctor this way also breaks backwards compat with groovy scripts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to add one more overloaded constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another and deprecate the older one, is how it usually is handled. The older constructors should not take in new params and should provide a safe default. i.e the old behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the constructor. Same comment about the type (use int
or Integer
).
For some odd reason, I am not able to comment on review for minuphours=0 inline. Adding comment here. If minuphours=0 then code evaluates other rule like idle termination time. See code @ |
Thanks for review. I updated code as per review comments. Adding notes here as well.
Need clarification
Let me know if you want me to add an overloaded constructor or modify groovy scripts.
|
A good start to tests is an old testcase that would otherwise timeout should not timeout any longer. |
2. Reverted previous changes in test cases and also removed minuphours in deprecated constructors. 3. Corrected logic in retention strategy. 4. Added test case for minuphours. Not all cases are covered sine idlemilliseconds method is final in computer onject
@@ -1 +0,0 @@ | |||
buildPlugin(configurations: buildPlugin.recommendedConfigurations()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this got deleted in my commit. let me submit a new commit
…that this turns our to me ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming along nicely, thanks for the contribution! I've left some feedback on areas we need to fix before merging.
@@ -73,7 +76,7 @@ | |||
String.valueOf(STARTUP_TIME_DEFAULT_VALUE)), STARTUP_TIME_DEFAULT_VALUE); | |||
|
|||
@DataBoundConstructor | |||
public EC2RetentionStrategy(String idleTerminationMinutes) { | |||
public EC2RetentionStrategy(String idleTerminationMinutes, String minUpHours) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to keep the old constructors and mark them @Deprecated
in order to preserve backward compatibility as this class is public.
Also, you should use an argument type of either int
(for a required value) or Integer
(for a nullable one). I'd suggest OptionalInt
as an argument type for the latter, though I'm not sure if that actually works with @DataBoundConstructor
.
} | ||
|
||
@DataBoundConstructor | ||
public EC2OndemandSlave(String name, String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, boolean useDedicatedTenancy, int launchTimeout, AMITypeData amiType, ConnectionStrategy connectionStrategy, int maxTotalUses) | ||
public EC2OndemandSlave(String name, String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, boolean useDedicatedTenancy, int launchTimeout, AMITypeData amiType, ConnectionStrategy connectionStrategy, int maxTotalUses, String minUpHours) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; you need to create a new constructor and mark the old one @Deprecated
.
I'll note that this sort of redundancy could be avoided by using a value object as the constructor argument rather than all of its attributes, but this would require a larger effort to fix at this point.
} | ||
|
||
@DataBoundConstructor | ||
public EC2SpotSlave(String name, String spotInstanceRequestId, String description, String remoteFS, int numExecutors, Mode mode, String initScript, String tmpDir, String labelString, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String jvmopts, String idleTerminationMinutes, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType, ConnectionStrategy connectionStrategy, int maxTotalUses) | ||
public EC2SpotSlave(String name, String spotInstanceRequestId, String description, String remoteFS, int numExecutors, Mode mode, String initScript, String tmpDir, String labelString, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String jvmopts, String idleTerminationMinutes, List<EC2Tag> tags, String cloudName, int launchTimeout, AMITypeData amiType, ConnectionStrategy connectionStrategy, int maxTotalUses, String minUpHours) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, need another constructor.
@@ -175,7 +177,7 @@ public SlaveTemplate(String ami, String zone, SpotConfiguration spotConfig, Stri | |||
String instanceCapStr, String iamInstanceProfile, boolean deleteRootOnTermination, | |||
boolean useEphemeralDevices, boolean useDedicatedTenancy, String launchTimeoutStr, boolean associatePublicIp, | |||
String customDeviceMapping, boolean connectBySSHProcess, boolean monitoring, | |||
boolean t2Unlimited, ConnectionStrategy connectionStrategy, int maxTotalUses) { | |||
boolean t2Unlimited, ConnectionStrategy connectionStrategy, int maxTotalUses, String minUpHours) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the constructor. Same comment about the type (use int
or Integer
).
@@ -140,6 +140,8 @@ | |||
|
|||
public int nextSubnet; | |||
|
|||
private String minUpHours; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Integer
for a nullable value, or int
for a non-null value. Type conversion is handled automatically for you at the point of @DataBoundConstructor
and @DataBoundSetter
, so you can maintain the real type throughout your code.
@@ -177,6 +177,10 @@ THE SOFTWARE. | |||
<f:entry title="${%Maximum Total Uses}" field="maxTotalUses"> | |||
<f:textbox default="-1"/> | |||
</f:entry> | |||
|
|||
<f:entry title="Minimum uptime in hours" field="minUpHours"> | |||
<f:textbox default="0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use <f:number>
instead. In fact, all the other textboxes in this form that are numeric should also use that.
@@ -0,0 +1,6 @@ | |||
<div> | |||
<p> Retains ephemeral agents for specified hours before applying "idle termination minutes" rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<p> Retains ephemeral agents for specified hours before applying "idle termination minutes" rules. | |
<p>Retains ephemeral agents for specified hours before applying "idle termination minutes" rules.</p> |
Added minimum uphours feature so that agent stays up for specified minimum hours before considering for termination. Once agent stayed for minimum number of hours other rules (like idle termination time) will get evaluated.
Why this feature is important?
Main use cases.
Avoid agent spin up time. Windows agents in AWS takes somewhere around 10 to 20 minutes to spin up and without minimum uptime feature we see that builds are waiting longer for agent to be available. Linus agents spin up time is faster though compared to windows.
Warm up ephemeral agents with caches(maven or npm or any other) so that actual developer builds can be faster and with the help of minimum uphours we can retain agent for 8 to 10 hours which helps in faster builds during development hours or working hours.
Reserve capacity upfront for pre planned work.
No need to depend on static agent for cache warmup.
And this is optional feature