Use only name based check for VM existence during deletion - remove label based filtering#534
Merged
Conversation
Contributor
Author
|
The only theoretical risk (far from being practical) with
|
Member
|
Is this related to #504? |
Member
|
BTW use permalinks to the conversations, not files, tab: #489 (comment) |
jglick
approved these changes
Apr 1, 2026
jglick
left a comment
Member
There was a problem hiding this comment.
Sounds OK. Do not really understand the implications.
Contributor
Author
yes, it is related. |
Contributor
Author
Nothing concrete as far as I can tell. The only theoretical implication is the one I put above #534 (comment) — which is far from practical imo. |
Contributor
Author
|
IMPORTANT: |
gbhat618
commented
Apr 1, 2026
| try { | ||
| return cloud.getClient().getInstance(cloud.getProjectId(), zone, name) != null; | ||
| } catch (GoogleJsonResponseException gjre) { | ||
| if (gjre.getStatusCode() == 404) { |
Contributor
Author
There was a problem hiding this comment.
example exception trace
exception
GET https://compute.googleapis.com/compute/v1/projects/tiger-team-testing/zones/us-east1-b/instances/name
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "The resource 'projects/tiger-team-testing/zones/us-east1-b/instances/name' was not found",
"reason" : "notFound"
} ],
"message" : "The resource 'projects/tiger-team-testing/zones/us-east1-b/instances/name' was not found"
}
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:439)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:525)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:466)
at PluginClassLoader for google-oauth-plugin//com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:576)
at PluginClassLoader for google-compute-engine//com.google.cloud.graphite.platforms.plugin.client.ComputeWrapper.getInstance(ComputeWrapper.java:125)
at PluginClassLoader for google-compute-engine//com.google.cloud.graphite.platforms.plugin.client.ComputeClient.getInstance(ComputeClient.java:371)
at PluginClassLoader for google-compute-engine//com.google.jenkins.plugins.computeengine.ComputeEngineInstance.instanceExistsInCloud(ComputeEngineInstance.java:174)
at PluginClassLoader for google-compute-engine//com.google.jenkins.plugins.computeengine.ComputeEngineInstance._terminate(ComputeEngineInstance.java:137)
at hudson.slaves.AbstractCloudSlave.terminate(AbstractCloudSlave.java:88)
at PluginClassLoader for durable-task//org.jenkinsci.plugins.durabletask.executors.OnceRetentionStrategy.lambda$done$5(OnceRetentionStrategy.java:141)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In CasC based controller, if the
instanceIdis not put in configuration, will get recomputed upon reapplying CasC (such as on restart) -google-compute-engine-plugin/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineCloud.java
Lines 179 to 186 in 3634530
Post such re-computation of instanceId, the VMs provisioned prior will not be deleted from the
_terminateas the filter won't find them -google-compute-engine-plugin/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineInstance.java
Lines 140 to 143 in 3634530
Those VMs are assumed to be non-existing in GCP and Jenkins node is removed, the VMs will continue to run in the cloud.
I have considered completely removing the VM existence check entirely but noticed this discussion https://github.com/jenkinsci/google-compute-engine-plugin/pull/489/changes#r1871950758
This PR propose to use
getInstance(projectId, zone, name)to filter a VM which should also get a unique VM. When multiple Jenkins controllers are pointing to a GCP project, and if one controller is having an agent with a particular name, other controllers would not have had chance to provision that VM, would have failed during provisioning even if they had computed the same agent name.Investigation
This was able to prove by adding more logs
diff
logs were,
Instance had label as,
Jenkins
config.xmlshowed the id as,Testing done
Automated Testing
ComputeEngineCloudOneShotInstanceIT- which has some VM deletion related assertions.Manual Testing
Submitter checklist