Merge pull request #123856 from aramase/aramase/t/reload_int_test_fix

fix test flake in TestStructuredAuthenticationConfigReload
This commit is contained in:
Kubernetes Prow Robot 2024-03-11 02:22:32 -07:00 committed by GitHub
commit 05ccec23aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1332,7 +1332,19 @@ jwt:
_, err = client.CoreV1().Pods(defaultNamespace).List(ctx, metav1.ListOptions{})
tt.assertErrFn(t, err)
err = os.WriteFile(apiServer.ServerOpts.Authentication.AuthenticationConfigFile, []byte(tt.newAuthConfigFn(t, oidcServer.URL(), string(caCert))), 0600)
// Create a temporary file
tempFile, err := os.CreateTemp("", "tempfile")
require.NoError(t, err)
defer func() {
_ = tempFile.Close()
}()
// Write the new content to the temporary file
_, err = tempFile.Write([]byte(tt.newAuthConfigFn(t, oidcServer.URL(), string(caCert))))
require.NoError(t, err)
// Atomically replace the original file with the temporary file
err = os.Rename(tempFile.Name(), apiServer.ServerOpts.Authentication.AuthenticationConfigFile)
require.NoError(t, err)
if tt.waitAfterConfigSwap {