Repository navigation
fix(auth): align mTLS transport and bound token certificate startup polling and well-known discovery - #14748
Open
macastelaz wants to merge 2 commits into
Open
fix(auth): align mTLS transport and bound token certificate startup polling and well-known discovery#14748macastelaz wants to merge 2 commits into
macastelaz wants to merge 2 commits into
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.
This branch has not been deployed
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) or its referencedcert_path/key_pathresides in/var/run/secrets/workload-spiffe-credentials/(resolving ancestor symlinks viaresolveRealPathAllowingMissing),MtlsUtilsnow polls for up to 30 seconds (50 × 100ms+50 × 500ms) on initial container startup (!isInitialStartupCompleted()) until the configuration file,cert_path, andkey_pathare non-empty readable regular files and the JSON configuration parses cleanly.MtlsUtilsandAgentIdentityUtilsshare theinitialStartupCompletedstate so the JVM performs the 30-second cold-start poll at most once across both transport and token initialization.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/cert_path/key_pathinside the well-known SPIFFE directoryinitialStartupCompletedstate acrossMtlsUtilsandAgentIdentityUtils(0 sleeps on subsequent calls)credentialbundle.pemandcertificates.pem+private_key.pemwhenGOOGLE_API_CERTIFICATE_CONFIGis unset