Skip to content

Commit

Permalink
[uss_qualifier] scd subscrptions: stop considering 404 a success, add…
Browse files Browse the repository at this point in the history
… was_not_found (interuss#785)
  • Loading branch information
Shastick authored and punamverma committed Oct 16, 2024
1 parent ef35ed1 commit ea2b1bc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion monitoring/mock_uss/tracer/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def unsubscribe_rid(
def unsubscribe_scd(subscription_id: str, scd_client: UTMClientSession) -> None:
logger = context.tracer_logger
get_result = fetch.scd.get_subscription(scd_client, subscription_id)
if not get_result.success:
if not (get_result.success or get_result.was_not_found):
logfile = logger.log_new(
SCDUnsubscribe(
existing_subscription=get_result,
Expand Down
11 changes: 10 additions & 1 deletion monitoring/monitorlib/fetch/scd.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,21 @@ def constraints(
class FetchedSubscription(fetch.Query):
@property
def success(self) -> bool:
"""Returns true if a subscription could be successfully fetched."""
return not self.errors

@property
def was_not_found(self) -> bool:
"""
Returns true if the subscription was not found.
Any http return code different from 404 will cause this to be False.
"""
return self.status_code == 404

@property
def errors(self) -> List[str]:
if self.status_code == 404:
return []
return ["Subscription not found"]
if self.status_code != 200:
return ["Request to get Subscription failed ({})".format(self.status_code)]
if self.json_result is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _steps_create_subs_at_each_dss(self):
"Get Subscription by ID",
other_dss.participant_id,
) as check:
if not other_dss_sub.success:
if not (other_dss_sub.success or other_dss_sub.was_not_found):
check.record_failed(
summary="Get subscription query failed",
details=f"Failed to retrieved a subscription from DSS with code {other_dss_sub.status_code}: {other_dss_sub.error_message}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _case_subs_deletion(self):
) as check:
other_dss_sub = other_dss.get_subscription(sub_id)
self.record_query(other_dss_sub)
if not other_dss_sub.success:
if not (other_dss_sub.success or other_dss_sub.was_not_found):
check.record_failed(
summary="Get subscription query failed",
details=f"Failed to retrieved a subscription from DSS with code {other_dss_sub.status_code}: {other_dss_sub.error_message}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def _test_get_sub(self):
fetched_sub = self._dss.get_subscription(sub_id)
self.record_query(fetched_sub)
with self.check("Get subscription query succeeds", self._pid) as check:
if not fetched_sub.success:
if not (fetched_sub.success or fetched_sub.was_not_found):
check.record_failed(
"Get subscription by ID failed",
details=f"Get subscription by ID failed with status code {fetched_sub.status_code}",
Expand Down

0 comments on commit ea2b1bc

Please sign in to comment.