Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uss_qualifier] scd subscrptions: stop considering 404 a success, add was_not_found #785

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading