Repository navigation
fix(gke): wait for existing JobSet webhook instead of re-applying manifests - #6554
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 enhances the reliability of the JobSet installation process within the GKE orchestrator. By implementing a wait-for-ready strategy instead of re-applying manifests, it prevents potential conflicts and service disruptions caused by re-installing over existing deployments. The changes include improved diagnostic reporting for partial installations, better handling of RBAC permissions, and more robust endpoint readiness checks, ensuring a smoother experience when managing JobSet on GKE clusters. 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 significantly refactors and hardens the JobSet installation and verification process in the GKE orchestrator. It introduces robust checks to prevent modifying existing or partial JobSet installations, implements detailed webhook endpoint polling with a 5-minute timeout, and adds comprehensive diagnostic reporting (including pod status and container waiting reasons) when timeouts occur. Additionally, it consolidates permission and endpoint checks across both JobSet and Kueue, and introduces a helper to format copy-pasteable kubectl commands. Feedback on the changes suggests extending the podProblem diagnostic helper to also inspect p.Status.InitContainerStatuses so that failures in init containers are not missed.
db6a6eb to
c72d54a
Compare
…ifests Classify cluster JobSet state using both the JobSet CRD and Service jobset-system/jobset-webhook-service. When both exist, wait up to 5 minutes for a ready webhook endpoint with pod diagnostics (including InitContainerStatuses) on timeout and never re-apply manifests over an existing installation. When only one exists or cannot be read, fail fast with recovery instructions. On the fresh-install path, verify cluster-scoped RBAC permissions and confirm that Deployment/jobset-controller-manager, Deployment/jobset-controller, Service/jobset-webhook-service, and Service/jobset-controller-manager-metrics-service are all NotFound in jobset-system before writing or applying the JobSet manifest, aborting fail-closed with remediation instructions if any object already exists or cannot be read.
c72d54a to
f64d614
Compare
…JobSet rollout wait
6dbbbed
into
GoogleCloudPlatform:develop
Summary
Prevents
gcluster job submitfrom re-applyingmanifests.yamlover an existing or partial JobSet installation when the webhook temporarily has 0 ready endpoints (for example during a controller pod restart or node preemption), and guards the fresh-install path against leftover or concurrently created controller/Service objects injobset-system.Changes Included
4-State JobSet Classification & Fast Path (
pkg/orchestrator/gke/infra_manager.go):CRD jobsets.jobset.x-k8s.ioandService jobset-system/jobset-webhook-service(checkAndInstallJobSetCRD,checkResourceExists). Treats403 Forbiddenas existing so restricted users on shared clusters never trigger an install.verifyOrWaitForJobSetWithCRD): When the JobSet CRD is confirmed present, checksEndpointSlicereadiness ofjobset-system/jobset-webhook-servicefirst so healthy clusters require only 2kubectlreads (CRD+EndpointSlice) and skip the separateServiceexistence read.crdExists && serviceExists): Never re-applies or modifies an existing JobSet installation. PollsEndpointSlicereadiness (waitForJobSetWebhookEndpoints/pollJobSetWebhookEndpoints) for up to 5 minutes (jobSetWebhookWaitTimeout, 3s poll interval, 100-attempt cap) using--request-timeout=10sper read and logging periodic progress every 30s.partialJobSetInstallError): When only one of the CRD or webhookServiceexists (or one returns403 Forbiddenwhile the other isNotFound), fails fast without modifying the cluster and prints--context-pinned investigation and recovery commands (kubectl delete namespace jobset-system, Helm reinstall /gcluster deploy, orkubectl apply --server-side --force-conflictswith version guidance).Fresh-Install Guards & Per-Context Manifests (
pkg/orchestrator/gke/infra_manager.go):installJobSetOnFreshCluster,missingPermissions): Verifiescreatepermissions onnamespaces,customresourcedefinitions.apiextensions.k8s.io,clusterroles.rbac.authorization.k8s.io,clusterrolebindings.rbac.authorization.k8s.io,mutatingwebhookconfigurations.admissionregistration.k8s.io, andvalidatingwebhookconfigurations.admissionregistration.k8s.ioviakubectl auth can-i <verb> <resource> --all-namespacesbefore attempting installation.checkNoLiveJobSetObjects): Queriesjobset-systemviag.kubeClient.GetResourcefor all four selector-bearing JobSet objects (Deployment/jobset-controller-manager,Deployment/jobset-controller,Service/jobset-webhook-service, andService/jobset-controller-manager-metrics-service) and requires every object to returnNotFoundbefore downloading, writing, or applying manifests. Aborts fail-closed with remediation instructions if any object already exists or if any read/client initialization fails.jobSetManifestFile,writeGeneratedManifest,applyManifestFile): Writes cleaned JobSet manifests to~/.gcluster/generated/jobset-<context>.yaml(orjobset.yamlwhen context is empty) so runs against other clusters do not overwrite the manifest file referenced in recovery instructions ifkubectl applyor rollout waiting fails.Webhook Timeout & Controller Pod Diagnostics (
pkg/orchestrator/gke/infra_manager.go):!everRead) from an unready webhook (jobSetWebhookTimeoutError).Service/jobset-webhook-service.spec.selectorand pods injobset-system(diagnoseJobSetWebhook,describeJobSetPods,podProblem,waitingContainerProblem), reporting selector match counts, pod phases/labels, the first waiting container inInitContainerStatusesorContainerStatuses(Reason, container name, image, message), orPodScheduled=False(Unschedulable) reasons, plus--context-pinnedkubectldiagnostic commands.Shared
EndpointSliceReadiness & Kueue Integration (pkg/orchestrator/gke/types.go,pkg/orchestrator/gke/kueue.go):k8sEndpointSliceList.HasReadyEndpoint()intypes.gosoConditions.Readyis a*bool, treatingnil(omitted) as ready alongsidetruewhenAddressesis non-empty per thediscovery.k8s.io/v1EndpointConditionsspecification.serviceGVR(v1/services) andpermissionChecktotypes.go.checkKueueInstallPermissionsinkueue.goto useg.missingPermissions(--all-namespaces) and updatescheckKueueEndpointsto reuseg.checkServiceEndpointsReady("kueue-system", "kueue-webhook-service")whenuseEndpointSliceis enabled.Context-Pinned
kubectlCommand Formatting & Docs (pkg/orchestrator/gke/kube_auth.go,docs/gcluster_job_guide.md):kubectlCommandLine(kubeContext, args...)inkube_auth.goto render copy-pasteablekubectlcommands pinned with--contextand quoting whitespace-containing arguments.docs/gcluster_job_guide.mdto document the JobSet readiness wait and non-destructive install behavior duringgcluster job submit.Testing
pkg/orchestrator/gke/infra_manager_test.go,pkg/orchestrator/gke/kube_auth_test.go, andpkg/orchestrator/gke/kueue_test.go(KUBECONFIG=/dev/null go test -race -count=1 ./pkg/orchestrator/gke/...) covering:EndpointSlicepolling,Ready == nilhandling, timeout diagnostics, andInitContainerStatuses/ContainerStatuses/UnschedulablereportingcheckNoLiveJobSetObjectsacross all four controllerDeploymentandServiceresources (present,403 Forbidden, timeout, transport error, dynamic client init error)--all-namespacesRBAC permission checks for both JobSet and KueuekubectlCommandLineargument quotingkindcluster across fresh admin/non-admin clusters,v0.10.1controller pod restarts, Helm0.12.0scaled-to-zero deployments, and partial uninstall states.