Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,14 @@ public FormValidation doCheckCleanfreq(@QueryParameter String value) {

try {
long parsedCleanFreq = Long.parseLong(value);
if (parsedCleanFreq == 0) {
NumberFormatException nfe =
new NumberFormatException("cleanfreq should be strictly greater than 0");
// Keep server-side validation consistent with the bounds in config.jelly.
if (parsedCleanFreq < 10 || parsedCleanFreq > 1200) {
NumberFormatException nfe = new NumberFormatException("cleanfreq must be between 10 and 1200");
throw nfe;
}
} catch (NumberFormatException ex) {
return FormValidation.error(ex, "Clean frequency must be an integer strictly greater than 0 (>=1)");
return FormValidation.error(
ex, "Cleanup frequency must be a whole number between 10 and 1200 seconds.");
}
return FormValidation.ok();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>
Clean frequency of pending VM (seconds)
<p>Interval in seconds between background cleanup checks for this cloud, including instances awaiting deletion and leftover floating IPs. For example, 60 schedules checks roughly once a minute. This setting does not control the agent idle timeout.</p>
<p><strong>Minimum:</strong> 10 seconds &middot; <strong>Maximum:</strong> 1200 seconds &middot; <strong>Default:</strong> 10 seconds</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ public class JCloudsCloudTest {
@Rule
public PluginTestRule j = new PluginTestRule();

@Test
public void validateCleanupFrequency() {
DescriptorImpl desc = j.getCloudDescriptor();

for (String value : new String[] {
"-1",
"-10",
"-9223372036854775808",
"0",
"1",
"9",
"1201",
"3600",
"9223372036854775807",
"",
" ",
"abc",
"1.5",
"9223372036854775808"
}) {
assertEquals(value, FormValidation.Kind.ERROR, desc.doCheckCleanfreq(value).kind);
}
for (String value : new String[] {"10", "11", "60", "1199", "1200"}) {
assertEquals(value, FormValidation.Kind.OK, desc.doCheckCleanfreq(value).kind);
}
}

@Test
public void failToTestConnection() {
DescriptorImpl desc = j.getCloudDescriptor();
Expand Down
Loading