-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add spotVM and maxRunDuration feature to VM provisioning #492
base: develop
Are you sure you want to change the base?
Add spotVM and maxRunDuration feature to VM provisioning #492
Conversation
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Outdated
Show resolved
Hide resolved
...es/com/google/jenkins/plugins/computeengine/InstanceConfiguration/help-provisioningType.html
Outdated
Show resolved
Hide resolved
src/main/resources/com/google/jenkins/plugins/computeengine/InstanceConfiguration/config.jelly
Outdated
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/SpotVm.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/SpotVm.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/Standard.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/Standard.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/Utils.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/Utils.java
Fixed
Show fixed
Hide fixed
recording and screenshots moved to the summary at the top ⬆️ |
I will work on the testing as,
Edit: all these points are completed ✔️ (automated tests are written both unittests and integration test). When maxRunDuration deletes the VM in GCP side, the controller also deletes the slave, which is correct no issues for builds ✅ (already covered in the integration test) |
src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeClientIT.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/jenkins/plugins/computeengine/integration/ITUtil.java
Outdated
Show resolved
Hide resolved
...n/resources/com/google/jenkins/plugins/computeengine/ui/helpers/Standard/config-detail.jelly
Outdated
Show resolved
Hide resolved
…plugin into add-max-run-duration-to-vm-provisioning
src/main/java/com/google/jenkins/plugins/computeengine/client/ClientUtil.java
Outdated
Show resolved
Hide resolved
👋 Completed the PR from draft to ready, plz help review @jglick , @Vlatombe , @nevingeorgesunny |
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/ProvisioningTypeValue.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/jenkins/plugins/computeengine/ConfigAsCodeTest.java
Outdated
Show resolved
Hide resolved
...m/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java
Outdated
Show resolved
Hide resolved
…eConfiguration.java Co-authored-by: Vincent Latombe <[email protected]>
…eConfiguration.java Co-authored-by: Vincent Latombe <[email protected]>
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/SpotVm.java
Outdated
Show resolved
Hide resolved
...m/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java
Outdated
Show resolved
Hide resolved
--> | ||
<div> | ||
The maximum duration (in seconds) after which the VM will be automatically deleted by GCP. | ||
See <a href="https://cloud.google.com/compute/docs/instances/limit-vm-runtime">Limit the run time of a VM</a> for more details. |
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.
FYI, links in help files for config forms automatically open in a new tab/window as per some magic in Jenkins core—there is no need to manually right-click and select Open in new tab or similar.
...le/jenkins/plugins/computeengine/integration/SpotVmProvisioningWithMaxRunDurationCasCIT.java
Outdated
Show resolved
Hide resolved
...le/jenkins/plugins/computeengine/integration/SpotVmProvisioningWithMaxRunDurationCasCIT.java
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/ui/helpers/PreemptibleVm.java
Outdated
Show resolved
Hide resolved
@@ -120,7 +124,7 @@ public class InstanceConfiguration implements Describable<InstanceConfiguration> | |||
private String machineType; | |||
private String numExecutorsStr; | |||
private String startupScript; | |||
private boolean preemptible; | |||
private ProvisioningType provisioningType; |
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.
Note for reviewers: this class is using Lombok (not a good idea!):
Lines 88 to 89 in 8d7f256
@Getter | |
@Setter(onMethod = @__(@DataBoundSetter)) |
src/main/java/com/google/jenkins/plugins/computeengine/configs/SpotVm.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/configs/SpotVm.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/configs/Standard.java
Fixed
Show fixed
Hide fixed
src/main/java/com/google/jenkins/plugins/computeengine/configs/Standard.java
Fixed
Show fixed
Hide fixed
} | ||
|
||
@SuppressWarnings("unused") // jelly | ||
public FormValidation doCheckMaxRunDurationSeconds(@QueryParameter String value) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing POST/RequirePOST annotation Warning
} | ||
|
||
@SuppressWarnings("unused") // jelly | ||
public FormValidation doCheckMaxRunDurationSeconds(@QueryParameter String value) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check Warning
} | ||
|
||
@SuppressWarnings("unused") // jelly | ||
public FormValidation doCheckMaxRunDurationSeconds(@QueryParameter String value) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing POST/RequirePOST annotation Warning
} | ||
|
||
@SuppressWarnings("unused") // jelly | ||
public FormValidation doCheckMaxRunDurationSeconds(@QueryParameter String value) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check Warning
…plugin into add-max-run-duration-to-vm-provisioning
public void setPreemptible(boolean preemptible) { | ||
if (preemptible) { | ||
this.provisioningType = new PreemptibleVm(); | ||
} |
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.
setPreemptible(false)
is noop?
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.
for JCasC compatibility purpose (as it was small effort)
as in #492 (comment)
Summary
This PR aims to enhance the VM provisioning capabilities of the
google-compute-engine-plugin
by introducing support for Spot VMs andmaxRunDuration
. This effort seeks to address the issues reported in #408, #473, and #358.Enhancements
maxRunDuration
feature, enabling the automatic deletion of VMs after a specified duration to optimize resource utilization and cost.Rationale
Although this plugin already has a background cleanup job for leftover orphan agent VMs, setting the
maxRunDuration
ensures that VMs deletion still happens even if the Jenkins controller itself has crashed. Besides this is an optional setting with no defaults enforced, so this feature is not trying to replace/interfere with the existing background job.Technical Background
The plugin now supports the following VM options:
maxRunDuration
.Why Maintain Support for Both Spot and Preemptible VMs?
Despite the similarities between Spot and Preemptible VMs, retaining support for both options is essential for the following reasons:
Testing Status
Manual Tests: Screen recording and screenshots
User experience configuration page
provisioning_type_impl_2.mov
VM Provisioned in GCP
→ Unit tests for the
scheduling()
method, ensuring the compatibility with the old and new configurations.New integration test for the Spot VM with Max Duration: logs
Submitter checklist