Repository navigation
fix(job): check Artifact Registry and Docker credentials only for Crane builds - #6488
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the prerequisite validation logic for 'gcluster job submit'. It ensures that build-specific checks, such as Artifact Registry API enablement and Docker credential configuration, are only executed when a build is actually triggered. By decoupling these checks from standard job submissions and making the Docker credential validation region-aware, the changes improve reliability and reduce friction for users deploying pre-built images. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the prerequisite checks for gcluster job submit so that Docker credential and Artifact Registry API checks are only executed during Crane builds (when --build-context is specified). It simplifies the registry credential verification by checking the specific regional registry directly, removes the caching of this check since it is region-dependent, and updates the associated unit tests and documentation. I have no feedback to provide as the changes are clean, well-tested, and properly documented.
45e90cf to
6751497
Compare
6751497 to
adeef83
Compare
adeef83 to
e19a264
Compare
…ne builds A pre-built --image is pulled by the cluster nodes, yet `gcluster job submit` refused to start until the workstation had Docker credentials for the cluster's region and the Artifact Registry API was enabled in the cluster's project. Both only matter when gcluster builds the image itself with Crane (--base-image/--build-context) and pushes it to <cluster-region>-docker.pkg.dev in that project. - Run the Artifact Registry API and Docker credential checks only for a Crane build (ensureBuildPrerequisites). The basic checks are unchanged. - Require a gcloud credential helper for the regional Artifact Registry host only; a build never touches gcr.io. The remediation names that host. - Read the Docker config on every build instead of caching the result per project for 24h: the registry depends on the cluster's region, so a result cached in one region let a build in another region fail at push time. docker_creds_configured is dropped from the state file; older files parse.
e19a264 to
86e5e61
Compare
a05eddd
into
GoogleCloudPlatform:develop
Problem
gcluster job submitrefused to start until the workstation had Docker credentials and the Artifact Registry API was enabled in the cluster's project, even when--imagenamed an image that was already pushed. The Docker check was also keyed on the cluster's region: a cluster inus-west4running an image fromus-south1-docker.pkg.devwas told to rungcloud auth configure-docker us-west4-docker.pkg.dev,gcr.io.Neither check has anything to do with a pre-built image, which the cluster nodes pull. They only matter when gcluster builds the image itself with Crane (
--base-image+--build-context) and pushes it to<cluster-region>-docker.pkg.devin the cluster's project (imagebuilder.GenerateImageName).Changes
ensurePrerequisitesis nowensureBuildPrerequisitesand runs only when--build-contextis set. The basic checks (gcloud, auth, ADC, kubectl,gke-gcloud-auth-plugin) still run for every job fromJobCmd.PersistentPreRunE.isDockerCredsConfiguredno longer requires agcr.iocredential helper; a build never touchesgcr.io. Crane authenticates throughauthn.DefaultKeychain, so thecredHelpers["<region>-docker.pkg.dev"] = "gcloud"entry (orcredsStore: gcloud) is the one that matters. The remediation names exactly that host.~/.gcluster/job_prereq_state.json, but the required host is per region: a build inus-central1followed within 24h by a build inus-west4skipped the check and failed at push time with a rawUNAUTHORIZED. Reading the Docker config is a local, sub-millisecond operation, so it is now evaluated on every build; only the network-backed Artifact Registry API lookup stays cached.docker_creds_configuredis removed from the state file (older files still parse; unknown JSON fields are ignored).User-visible behaviour change
A user whose Docker config only has
gcr.ioconfigured and who runs a Crane build is now asked to configure<region>-docker.pkg.devinstead — the only host the push touches.Testing
go test ./cmd/job/ ./pkg/imagebuilder/, all pre-commit hooks.TestSubmitCmd_BuildPrerequisitesOnlyForCraneBuild: end-to-end through cobra —--imagereaches the orchestrator without Docker credentials and without agcloud services listcall;--base-image/--build-contextruns both checks and asks forus-west4-docker.pkg.devonly.TestEnsureBuildPrerequisites_FreshState: with a fresh state, credentials for the cluster's region skip the checks; credentials for another region only, or none, do not.TestEnsureBuildPrerequisites_MissingDockerCreds,TestIsDockerCredsConfiguredupdated for the regional-host semantics.recordingPrereqStore; the existingMockPrereqStoreforce-sets every flag once a timestamp exists, which would have hidden this regression.gcr.iorequirement, per-project cache) fails exactly the test written for it.Submission Checklist