Closed michaeleekk closed 2 years ago
Hi @michaeleekk and thanks for the issue. I tried to reproduce this myself but was unable to.
Can you paste a copy of your cloudbuild.json
file here so we can reproduce this? (If there are secrets there, please replace them with dummy values in your paste.)
Thanks!
good morning @ace-n - i actually have an open support case about this exact issue. Can i provide an example JS file that in my experience replicates this issue? I can replicate this with the following:
#!/usr/bin/env node
"use strict";
const CloudBuild = require("@google-cloud/cloudbuild");
const projectId = "<an-existent-project>";
const client = new CloudBuild.CloudBuildClient();
const privatePool = "<an-existent-private-pool>";
const build = {
options: {
pool: {
name: privatePool,
},
},
steps: [
{
args: ["/bin/echo", "hello"],
id: "example",
name: "ubuntu",
},],};
client.createBuild({ build, projectId });
I can provide the specific case number so that you can see the exact project name and resource name if that's necessary, please let me know.
To provide more context, when I comment out the following block:
pool: {
name: privatePool,
},
I can create a cloudbuild job successfully (in the global region). When I specify an existent private pool and uncomment that same block, I get the following complaint:
Error: 5 NOT_FOUND: workerpool not found: "<an-existent-private-pool>"
at Object.callErrorFromStatus (<path>/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
at Object.onReceiveStatus (<path>/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
at Object.onReceiveStatus (<path>/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
at Object.onReceiveStatus (<path>/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
at /<path>/node_modules/@grpc/grpc-js/build/src/call-stream.js:182:78
Please advise if we need to be passing additional options to enable this behavior.
Thanks! Matt
The client libraries are hitting the global api endpoint by default, so for regional resources like this, you'll need to provide additional clientOptions
when building the client.
NodeJS
// To build the client, use region + service path as an override api endpoint.
const opts = {apiEndpoint: "us-central1-cloudbuild.googleapis.com"}
const client = new CloudBuild.CloudBuildClient(opts);
Python
... previous imports
from google.api_core.client_options import ClientOptions
client_options = ClientOptions(api_endpoint="us-central1-cloudbuild.googleapis.com")
client = cloudbuild_v1.services.cloud_build.CloudBuildClient(client_options=client_options)
These types of options are described in the gax-nodejs README: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#service-options
for anyone else who stumbles across this, this 100% solves my problem - thank you @ok-devalias !
I used the sample code to try triggering a cloud build from a config file. Things worked when without the worker pool parameter. I got a worker pool not found error. I could send build to the worker pool with cli but just not nodejs. I actually tried the REST API and Python SDK but also didn't work.
Environment details
@google-cloud/cloudbuild
version: 2.6.0Steps to reproduce