Skip to content

LRO do not work as expected for Cloud Build #606

@bcoe

Description

@bcoe

Bug

When using the Cloud Build API, I initially attempted to await builds as a long running operation:

  const [resp] = await cb.runBuildTrigger({
    projectId: project,
    triggerId: args.trigger,
    source: {
      projectId: project,
      branchName: 'master', // TODO: It might fail if we change the default branch.
      substitutions: {
        _GITHUB_TOKEN: token.token,
        _PR: args.pr.toString(),
        _PR_BRANCH: prData.head.ref,
        _PR_OWNER: prOwner,
        _REPOSITORY: prRepo,
        // _CONTAINER must contain the image digest. For example:
        // gcr.io/repo-automation-tools/nodejs-post-processor**@1234abcd**
        // TODO: read this from OwlBot.yaml.
        _CONTAINER: args.image,
        _DEFAULT_BRANCH: args.defaultBranch ?? 'master',
      },
    },
  });
const [build] = await resp.promise();

This code did not successfully wait for a build to complete and return a build object.

As a workaround we implemented our own polling behavior (see here).

Expected Behavior

const [build] = await resp.promise(); waits for build to complete and returns the build object.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions