-
Notifications
You must be signed in to change notification settings - Fork 84
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
Update constructor to follow CasC best practices #406
Update constructor to follow CasC best practices #406
Conversation
b4d73ca
to
fa8ec22
Compare
fa8ec22
to
1e0efaa
Compare
627e2a4
to
9ad8ead
Compare
|
||
static final int DEFAULT_IDLE_MINUTES = 0; | ||
|
||
static final int DEFAULT_MIN_SIZE = 1; |
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 will always leave 1 instance running unless maxTotalUses is set and met i.e. customer might pay for an idle instance due to this default. Was there a reason to change the default from 0 to 1?
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.
Per our offline sync, I understand jelly has a defualt of 1. Can we just make the 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.
Yup, I'll also change the Jelly to reflect this default. I think it makes more sense to not have idle instances.
@@ -0,0 +1,33 @@ | |||
package com.amazon.jenkins.ec2fleet; | |||
|
|||
class CloudConstants { |
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.
Nice 🌟
|
||
@DataBoundSetter | ||
public void setIdleMinutes(Integer idleMinutes) { | ||
this.idleMinutes = (idleMinutes != null) ? idleMinutes : 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.
since the default is already set for this.idleMinutes
if (idleMinutes != null) {
this.idleMinutes = idleMInutes;
}
@DataBoundSetter | ||
public void setMaxSize(int maxSize) { | ||
if (maxSize < minSize) { | ||
int newMaxSize = minSize > 0 ? minSize : 1; |
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.
int newMaxSize = Math.max(1, minSize);
?
public int getMaxTotalUses() { | ||
return maxTotalUses; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setMaxTotalUses(String maxTotalUses) { | ||
this.maxTotalUses = StringUtils.isBlank(maxTotalUses) ? DEFAULT_MAX_TOTAL_USES : Integer.parseInt(maxTotalUses); |
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.
Since the default is already set.
if (StringUtils.isNotBlank(maxtotalUses)) {
this.maxTotalUses = Integer.parseInt(maxTotalUses);
}
94b9d28
to
54c9ce4
Compare
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.
LGTM. Thanks for making the changes! 🚀
…ples, and include EC2FleetLabelCloud examples
54c9ce4
to
273a031
Compare
This reverts commit ae77bfa.
Created a new constructor and getter and setter methods for non-required values as defined here. This is based on best practices for the CasC plugin as defined here. Added sanity check to ensure
maxSize >= minSize
. Created fileCloudConstants.java
to define default values forEC2FleetCloud
andEC2FleetLabelCloud
.Updated Configuration-as-Code docs to reflect new default values, define min and max config examples, and fix typos and incorrect defaults in previous values.
Testing done
Defining new Clouds in UI and CasC is identical to previous behavior. This has no new tests added because the new functionality is covered by existing tests. Tested in UI and CasC that
maxSize
when set to be lower thanminSize
updates tominSize
with a warning.Updated CasC unit tests to handle new defaults. New CasC unit test that checks backwards compatibility with deprecated field
credentialsId
.Submitter checklist