Introduce error.capacity states_key for InsufficientInstanceCapacity error

We want to handle the "InsufficientInstanceCapacity" error different than
other "error.unknown" errors in our monitoring/alerting system. With this
change, it would produce a "error.capacity" instead of "error.unknown".

Change-Id: Id3a49d4b2d4b4733f801e65df69b505e913985a7
This commit is contained in:
Dong Zhang 2024-01-04 09:42:21 +01:00
parent 42f9100d82
commit aa113be19f
2 changed files with 10 additions and 0 deletions

View File

@ -1120,6 +1120,12 @@ class AwsAdapter(statemachine.Adapter):
# Re-raise as a quota exception so that the
# statemachine driver resets quota.
raise exceptions.QuotaException(str(error))
if (error.response['Error']['Code'] ==
'InsufficientInstanceCapacity'):
# Re-raise as CapacityException so it would have
# "error.capacity" statsd_key, which can be handled
# differently than "error.unknown"
raise exceptions.CapacityException(str(error))
raise
def _createInstance(self, label, image_external_id,

View File

@ -31,6 +31,10 @@ class LaunchKeyscanException(Exception):
statsd_key = 'error.keyscan'
class CapacityException(Exception):
statsd_key = 'error.capacity'
class BuilderError(RuntimeError):
pass