Repository navigation
fix(auth): align mTLS transport and bound token certificate startup polling and well-known discovery - #14748
Merged
macastelaz merged 8 commits intoOct 30, 2026
Conversation
…olling and well-known discovery
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces container startup polling in MtlsUtils to wait for credential file readiness when configuration or certificate files reside in the well-known SPIFFE directory, and unifies startup state tracking across mTLS transport initialization and Agent Identity token binding. The feedback suggests minor code simplifications by removing redundant checks in MtlsUtils (specifically in isExistingNonFileOrUnreadable and the exception handling block) and proposes a concurrency optimization to check the startup completion flag inside the polling loop to prevent unnecessary sleep cycles.
nbayati
reviewed
Oct 28, 2026
nbayati
reviewed
Oct 29, 2026
nbayati
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two certificate discovery asymmetries between mTLS transport initialization (
MtlsUtils/X509Provider) and Agent Identity bound-token acquisition (AgentIdentityUtils):Add 30-second initial startup polling to
MtlsUtilsfor the well-known SPIFFE directory:GOOGLE_API_CERTIFICATE_CONFIG(orcertConfigPathOverride) and its referencedcert_path/key_pathreside in/var/run/secrets/workload-spiffe-credentials/(or/run/secrets/workload-spiffe-credentials/),MtlsUtilspolls for up to 30 seconds (50 × 100ms+50 × 500ms) until the configuration file,cert_path, andkey_pathare non-empty readable regular files and the JSON configuration parses cleanly.MtlsUtils.waitForWorkloadConfigStartupIfNeeded(...)consolidates startup config polling across bothMtlsUtils(X509Provider) andAgentIdentityUtils.cert_path/key_path) fail immediately with 0 sleeps.Remove unconfigured legacy
credentialbundle.pemandcertificates.pem+private_key.pemfallbacks inAgentIdentityUtils:GOOGLE_API_CERTIFICATE_CONFIGis unset,AgentIdentityUtils.getWellKnownCertificatePathWithRetry()now checks only the GKE Pod Certificate bundle (/var/run/secrets/workload-spiffe-credentials/x509.credential-bundle.private-key.pem), matchingMtlsUtils.getWorkloadCertPath()andX509Provider1:1 soAgentIdentityUtilsnever mints a certificate-bound token for a certificate that the transport ignores.Testing
MtlsUtilsTest,X509ProviderTest, andAgentIdentityUtilsTestcovering:/var/run/secrets/workload-spiffe-credentials/credentialbundle.pemandcertificates.pem+private_key.pemwhenGOOGLE_API_CERTIFICATE_CONFIGis unset--functional-type=agent --identity-type=agent-identity) execution logs (agent-bound-token-java-test-4mrbz): https://paste.googleplex.com/6755399436524544