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

WOR-1403: add error handling for missing billing profile and for missing landing zone #2669

Merged
merged 5 commits into from
Dec 20, 2023

Conversation

blakery
Copy link
Contributor

@blakery blakery commented Dec 14, 2023

Ticket: https://broadworkbench.atlassian.net/browse/WOR-1403

Continue deletion if either the landing zone or billing profile is missing.


PR checklist

  • Include the JIRA issue number in the PR description and title
  • Make sure Swagger is updated if API changes
    • ...and Orchestration's Swagger too!
  • If you changed anything in model/, then you should publish a new official rawls-model and update rawls-model in Orchestration's dependencies.
  • Get two thumbsworth of PR review
  • Verify all tests go green, including CI tests
  • Squash commits and merge to develop (branches are automatically deleted after merging)
  • Inform other teams of any substantial changes via Slack and/or email

@@ -864,7 +862,29 @@ class BpmBillingProjectLifecycleSpec extends AnyFlatSpec {
mock[WorkspaceManagerResourceMonitorRecordDao]
)

Await.result(bp.initiateDelete(billingProjectName, testContext), Duration.Inf)
Await.result(bp.initiateDelete(billingProjectName, testContext), Duration.Inf) shouldBe (Some(jobReportId))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of this is more meaningful now, so we really should verify it.

@@ -214,7 +216,10 @@ class BpmBillingProjectLifecycle(
private def cleanupLandingZone(
landingZoneId: UUID,
ctx: RawlsRequestContext
): DeleteAzureLandingZoneResult = Try(workspaceManagerDAO.deleteLandingZone(landingZoneId, ctx)) match {
): Option[DeleteAzureLandingZoneResult] = Try(workspaceManagerDAO.deleteLandingZone(landingZoneId, ctx)) match {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the return an optional value, so we could indicate a non-failure instance where we don't need to create the monitor job to wait for the result.
This matches up nicely with the result and return behavior of the initializeDelete method, and doesn't conflict with the usage in cleanup when creation fails.

@@ -214,7 +216,10 @@ class BpmBillingProjectLifecycle(
private def cleanupLandingZone(
landingZoneId: UUID,
ctx: RawlsRequestContext
): DeleteAzureLandingZoneResult = Try(workspaceManagerDAO.deleteLandingZone(landingZoneId, ctx)) match {
): Option[DeleteAzureLandingZoneResult] = Try(workspaceManagerDAO.deleteLandingZone(landingZoneId, ctx)) match {
case Failure(e: ApiException) if e.getCode == HttpStatus.SC_FORBIDDEN =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service returns a 403 instead of a 404 when there's no landing zone present.
It's fine to move on, because if this was a 403 for permission reasons, we won't be able to delete the billing profile anyway, and we don't have a valid instance of a user having access to the billing project but not the underlying resources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have this comment in the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we DO happen to get a 404 from the service (which seems more correct), I think we should also handle it and allow the deletion to proceed. Perhaps at some point the 403 will be corrected to a 404.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

@blakery blakery marked this pull request as ready for review December 14, 2023 20:51
@blakery blakery requested review from a team, marctalbott, aherbst-broad and cahrens and removed request for a team December 14, 2023 20:51
// The service returns a 403 instead of a 404 when there's no landing zone present.
// It's fine to move on here, because if this was a 403 for permission reasons, we won't be able to delete the billing profile anyway,
// and we don't have a valid instance of a user having access to the billing project but not the underlying resources.
case Failure(e: ApiException) if e.getCode == HttpStatus.SC_FORBIDDEN || e.getCode == HttpStatus.SC_NOT_FOUND =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've started pushing this sort of logic down into the DAO layer in the similar BPM error handling code. The motivation is to keep the HTTP level concerns in the DAO (i.e., StatusCodes.NOT_FOUND etc.) and just return Option[foo] and make the upper levels deal with that interface. What do you think about doing that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is a better method in the long term, with how we're looking to structure our code, and separate our testing concerns.

I'll give it a try, and see what kind of issues it creates in the immediate term.

@blakery blakery merged commit c2ac276 into develop Dec 20, 2023
12 checks passed
@blakery blakery deleted the WOR-1403 branch December 20, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants