Errors while trying to use Google Compute Engine plugin to dynamically provision VMs

Hi All,

I am getting the below error while try to launch VMs using the GCE plugin. Any help on this will be highly appreciated.

Provisioning node from configs [com.google.jenkins.plugins.computeengine.InstanceConfiguration@5974b6be] for excess workload of 1 units of label 'gx-delta-cov-agent'
Nov 21, 2024 9:03:02 PM WARNING com.google.jenkins.plugins.computeengine.ComputeEngineCloud availableNodeCapacity
An error occurred counting the number of existing instances in cloud gx-cloud: 400 Bad Request
POST https://oauth2.googleapis.com/token
{
  "error" : "invalid_grant",
  "error_description" : "Invalid grant: account not found"
}
Nov 21, 2024 9:03:02 PM WARNING com.google.jenkins.plugins.computeengine.ComputeEngineCloud provision
Error provisioning node
com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
POST https://oauth2.googleapis.com/token
{
  "error" : "invalid_grant",
  "error_description" : "Invalid grant: account not found"
}
              at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:103)
              at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:308)
              at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:324)
              at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:378)
              at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:470)
              at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:201)
              at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:880)
              at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:525)
              at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:466)
              at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:576)
              at com.google.cloud.graphite.platforms.plugin.client.ComputeWrapper.aggregatedListInstances(ComputeWrapper.java:130)
              at com.google.cloud.graphite.platforms.plugin.client.ComputeClient.listInstancesWithLabel(ComputeClient.java:387)
              at com.google.jenkins.plugins.computeengine.ComputeEngineCloud.availableNodeCapacity(ComputeEngineCloud.java:335)
              at com.google.jenkins.plugins.computeengine.ComputeEngineCloud.provision(ComputeEngineCloud.java:251)
              at hudson.slaves.Cloud.provision(Cloud.java:227)
              at hudson.slaves.NodeProvisioner$StandardStrategyImpl.apply(NodeProvisioner.java:726)
              at hudson.slaves.NodeProvisioner.update(NodeProvisioner.java:325)
              at hudson.slaves.NodeProvisioner$NodeProvisionerInvoker.doRun(NodeProvisioner.java:823)
              at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:92)
              at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:67)
              at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
              at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
              at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
              at java.base/java.lang.Thread.run(Thread.java:840)

Jenkins version: 2.452.3
Plugin version: [Google Compute EngineVersion4.575.v6969b_7c435eb_]

Thanks,
Mohan

Hello and welcome to the community, @mkjkec2005! :wave:

Looks like you’re running into the invalid_grant: account not found error. This typically pops up when there’s a hiccup with the OAuth2 credentials that the Google Compute Engine (GCE) plugin uses to connect with Google Cloud. Here are some steps you might want to follow to sort this out:

  1. Verify Service Account Credentials: Double-check that the JSON key file for your service account is set up correctly and that Jenkins can access it.
  2. Check Service Account Permissions: Confirm that your service account has all the necessary permissions to create and manage instances on Google Cloud.
  3. Re-authenticate the Service Account: Occasionally, a fresh authentication for your service account does the trick in clearing up issues like this.

Also, I noticed that the Jenkins version you’re using (2.452.3) is a bit on the older side. When you have a moment, you might want to consider upgrading to a more recent LTS version to keep things smooth and secure.