Skip to content

Commit b0fa3f3

Browse files
committed
Don't quit loop before having deleted all leftover credentials
Signed-off-by: Matthias Büchse <[email protected]>
1 parent c6e57d1 commit b0fa3f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Tests/iaas/mandatory-services/mandatory-iaas-services.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,22 @@ def s3_from_ostack(creds, conn, endpoint):
127127
project_id = conn.identity.get_project_id()
128128
ec2_creds = [cred for cred in conn.identity.credentials()
129129
if cred.type == "ec2" and cred.project_id == project_id]
130+
found_ec2 = None
130131
for cred in ec2_creds:
131132
try:
132133
ec2_dict = json.loads(cred.blob)
133134
except Exception:
134135
logger.warning(f"unable to parse credential {cred!r}", exc_info=True)
135136
continue
136-
# print(f"DEBUG: Cred: {ec2_dict}")
137-
creds["AK"] = ec2_dict["access"]
138-
creds["SK"] = ec2_dict["secret"]
139137
# Clean up old EC2 creds and jump over
140138
if ec2_dict.get("owner") == EC2MARKER:
139+
logger.debug(f"Removing leftover credential {ec2_dict['access']}}")
141140
conn.identity.delete_credential(cred)
142141
continue
142+
found_ec2 = ec2_dict
143+
if found_ec2:
144+
creds["AK"] = found_ec2["access"]
145+
creds["SK"] = found_ec2["secret"]
143146
return None
144147
# Generate keyid and secret
145148
ak = uuid.uuid4().hex

0 commit comments

Comments
 (0)