Skip to content

Commit 9f3e64c

Browse files
committed
fix: Add a sleep for the service account to propagate.
I suspect that sometimes this method fails because there is a race condition when creating the new servie account. Adding a service account is not a LRO, but it's also no atomic. The information about the new account needs a moment to propagate through the system. Closes #6894
1 parent 4e8bbf4 commit 9f3e64c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compute/oslogin/service_account_ssh_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# Copyright 2019, Google, Inc.
1+
# Copyright 2019 Google LLC
2+
#
23
# Licensed under the Apache License, Version 2.0 (the "License");
34
# you may not use this file except in compliance with the License.
45
# You may obtain a copy of the License at
56
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
78
#
89
# Unless required by applicable law or agreed to in writing, software
910
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -112,6 +113,10 @@ def setup_resources(
112113
'accountId': test_id
113114
}).execute()
114115

116+
# Wait for the creation to propagate through the system, so the
117+
# following calls don't fail sometimes.
118+
time.sleep(5)
119+
115120
# Grant the service account access to itself.
116121
iam.projects().serviceAccounts().setIamPolicy(
117122
resource='projects/' + project + '/serviceAccounts/' + account_email,

0 commit comments

Comments
 (0)