From 7ca96490c41ad7b807aada2b95bf70aebc148792 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Fri, 16 Oct 2026 14:50:23 +0200 Subject: [PATCH] refactor(gcs): drop the credentials write mutex The WriteFileAtomic function of machinery v0.6.1 names its temporary file with a random suffix, so concurrent writes of the same file no longer collide. This was the condition to remove the mutex, see cloudnative-pg/machinery#325. Signed-off-by: Marco Nenciarini --- pkg/credentials/env.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/credentials/env.go b/pkg/credentials/env.go index cdbe3203..365604d6 100644 --- a/pkg/credentials/env.go +++ b/pkg/credentials/env.go @@ -23,7 +23,6 @@ import ( "context" "fmt" "path" - "sync" machineryapi "github.com/cloudnative-pg/machinery/pkg/api" "github.com/cloudnative-pg/machinery/pkg/fileutils" @@ -328,11 +327,6 @@ func envSetAzureCredentials( // so tests can change it. var googleCredentialsDirectory = path.Join(ScratchDataDirectory, ".google-credentials") -// googleCredentialsMutex serializes the writes, because WriteFileAtomic -// names its temporary file after the current second. Remove it once -// cloudnative-pg/machinery#325 is released. -var googleCredentialsMutex sync.Mutex - func envSetGoogleCredentials( ctx context.Context, c client.Client, @@ -363,8 +357,6 @@ func envSetGoogleCredentials( googleCredentials.ApplicationCredentials.Key, ) - googleCredentialsMutex.Lock() - defer googleCredentialsMutex.Unlock() if _, err := fileutils.WriteFileAtomic(credentialsPath, applicationCredentialsContent, 0o600); err != nil { return nil, err }