Merge "Include Fleet ID in error exception logs"

This commit is contained in:
Zuul
2025-06-23 09:26:39 +00:00
committed by Gerrit Code Review

View File

@@ -1863,20 +1863,22 @@ class AwsAdapter(statemachine.Adapter):
with self.rate_limiter(log.debug, "Created fleet"):
resp = self.ec2_client.create_fleet(**args)
fleet_id = resp.get("FleetId")
if resp['Instances']:
instance_id = resp['Instances'][0]['InstanceIds'][0]
else:
if resp['Errors']:
error = resp['Errors'][0]
raise Exception("Couldn't create fleet instance because "
"of %s: %s", error["ErrorCode"],
error["ErrorMessage"])
raise Exception("Couldn't create fleet instance because "
"empty instance list was returned")
raise Exception("Couldn't create fleet %s instance "
"because of %s: %s", fleet_id,
error["ErrorCode"], error["ErrorMessage"])
raise Exception("Couldn't create fleet %s instance because "
"empty instance list was returned",
fleet_id)
log.debug("Created VM %s as instance %s using EC2 Fleet API",
hostname, instance_id)
log.debug("Created VM %s as instance %s using EC2 Fleet API: %s",
hostname, instance_id, fleet_id)
# Only return instance id in creating state, the state machine will
# refresh until the instance object is returned otherwise it can