Skip to content

Fix transient webhook timeouts on kueue job submission - #6252

Open
sudheer-quad wants to merge 1 commit into
GoogleCloudPlatform:developfrom
sudheer-quad:fix/kubectl-apply-retry
Open

Fix transient webhook timeouts on kueue job submission#6252
sudheer-quad wants to merge 1 commit into
GoogleCloudPlatform:developfrom
sudheer-quad:fix/kubectl-apply-retry

Conversation

@sudheer-quad

Copy link
Copy Markdown
Contributor

This PR prevents the Cloud Build pipeline from terminating immediately during kueue job submission due to set -e when the GKE control plane or Kueue mutating webhook (mjob.kb.io) experiences temporary latency.

Submission Checklist

NOTE: Community submissions can take up to 2 weeks to be reviewed.

Please take the following actions before submitting this pull request.

  • Fork your PR branch from the Toolkit "develop" branch (not main)
  • Test all changes with pre-commit in a local branch #
  • Confirm that "make tests" passes all tests
  • Add or modify unit tests to cover code changes
  • Ensure that unit test coverage remains above 80%
  • Update all applicable documentation
  • Follow Cluster Toolkit Contribution guidelines #

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the robustness of the Cloud Build pipeline by introducing retry logic for Kueue job submissions. By handling transient network or webhook latency, the pipeline is now less likely to fail due to temporary GKE control plane issues, ensuring more reliable job execution.

Highlights

  • Retry Logic Implementation: Added a retry mechanism for the kubectl apply command to handle transient failures during Kueue job submission.
  • Resilience Improvement: Configured the script to attempt submission up to 5 times with a 10-second delay between failures, preventing premature pipeline termination.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the external PR from external contributor label Sep 2, 2026
@sudheer-quad sudheer-quad self-assigned this Sep 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a retry mechanism for the kubectl apply command in submit_and_monitor_kueue_job.sh to handle transient failures during Kueue job submission. The review feedback recommends replacing the double-parentheses post-increment (( SUBMIT_ATTEMPT++ )) with standard arithmetic expansion SUBMIT_ATTEMPT=$((SUBMIT_ATTEMPT + 1)) to avoid potential script termination under set -e and to maintain consistency with the rest of the script.

Comment thread tools/cloud-build/submit_and_monitor_kueue_job.sh Outdated
@sudheer-quad
sudheer-quad force-pushed the fix/kubectl-apply-retry branch from a6f99e3 to 512df21 Compare September 2, 2026 10:26
@sudheer-quad sudheer-quad added the release-chore To not include into release notes label Sep 2, 2026
@sudheer-quad
sudheer-quad force-pushed the fix/kubectl-apply-retry branch 4 times, most recently from efc9857 to 53404c7 Compare September 2, 2026 12:23
@sudheer-quad
sudheer-quad marked this pull request as ready for review September 3, 2026 11:01
@sudheer-quad
sudheer-quad requested a review from a team as a code owner September 3, 2026 11:01
Comment thread tools/cloud-build/submit_and_monitor_kueue_job.sh Outdated
Comment thread tools/cloud-build/submit_and_monitor_kueue_job.sh Outdated
@Neelabh94 Neelabh94 assigned sudheer-quad and unassigned Neelabh94 Sep 3, 2026
while true; do
echo "Executing job submission (attempt ${SUBMIT_ATTEMPT}/${SUBMIT_RETRIES})..."

if kubectl apply -f /workspace/job.yaml; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, this retries on any non-zero exit code from kubectl apply. If there is an invalid field or syntax error in /workspace/job.yaml, kubectl apply fails with a permanent schema error, but the loop will still sleep and retry across all attempts before failing—unnecessarily stalling CI feedback.

Consider capturing the output so we fail fast on permanent errors and only retry on transient webhook/connection timeouts:

		if APPLY_OUT=$(kubectl apply -f /workspace/job.yaml 2>&1); then
			echo "$APPLY_OUT"
			break
		fi
		echo "$APPLY_OUT"

		if ((SUBMIT_ATTEMPT >= SUBMIT_RETRIES)); then
			echo "ERROR: Failed to apply job manifest after ${SUBMIT_RETRIES} attempts." >&2
			exit 1
		fi

		# Fail fast on non-transient schema or validation errors
		if ! echo "$APPLY_OUT" | grep -iqE "(webhook|timeout|context deadline exceeded|connection refused)"; then
			echo "ERROR: Non-retriable apply failure detected. Failing immediately." >&2
			exit 1
		fi

@sudheer-quad
sudheer-quad force-pushed the fix/kubectl-apply-retry branch from 53404c7 to 5be9811 Compare September 4, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from external contributor release-chore To not include into release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants