Skip to content

Commit 9fc4140

Browse files
authored
Merge pull request #789 from uw-it-aca/task/handle-itbill-404-exception
Task/handle itbill 404 exception
2 parents 9dcd530 + 4d89719 commit 9fc4140

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

endorsement/dao/itbill.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ def load_itbill_subscription(record):
123123
"""
124124
Update the subscription record with the latest ITBill data
125125
"""
126-
record.update_subscription(
127-
get_subscription_by_key_remote(record.subscription.key_remote)
128-
)
126+
try:
127+
record.update_subscription(
128+
get_subscription_by_key_remote(record.subscription.key_remote)
129+
)
130+
except DataFailureException as ex:
131+
if ex.status == 404:
132+
raise ITBillSubscriptionNotFound(record.subscription.key_remote)
133+
134+
raise ex

endorsement/dao/shared_drive.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,19 @@ def load_or_update_subscription(sdr: SharedDriveRecord):
284284
"""
285285
# Do we already have an ITBillSubscription on file?
286286
if sdr.subscription is not None:
287-
load_itbill_subscription(sdr)
288-
sdr.subscription.save()
289-
return sdr.subscription
287+
try:
288+
load_itbill_subscription(sdr)
289+
sdr.subscription.save()
290+
return sdr.subscription
291+
except ITBillSubscriptionNotFound as ex:
292+
sub = sdr.subscription
293+
if sub.state == ITBillSubscription.SUBSCRIPTION_DEPLOYED:
294+
logger.error(f"Remote key not found in itbill: {ex} "
295+
"for drive in deployed state")
296+
else:
297+
logger.info("Remote key not found in itbill for drive "
298+
f"{ex} in {sub.get_state_display} state.")
299+
return None
290300

291301
# Does an ITBill subscription exist remotely and we just have to get it?
292302
key_remote = sdr.get_itbill_key_remote()

0 commit comments

Comments
 (0)