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

AJ-1438: disable most entity APIs for Azure workspaces #2641

Merged
merged 6 commits into from
Dec 10, 2023

Conversation

davidangb
Copy link
Contributor

@davidangb davidangb commented Nov 29, 2023

Ticket: https://broadworkbench.atlassian.net/browse/AJ-1438

This PR disables all writable entity APIs and most read-only entity APIs for Azure workspaces. Azure workspaces use WDS instead of Rawls for data tables; the APIs in Rawls are misleading and should not be used for Azure workspaces.

This check is implemented by using EntityManager as a bottleneck. Inside EntityManager.resolveProvider(), we check the target workspace and throw an error if it is not a GCP (non-MC) workspace. As part of this, I needed to move the copyEntities implementation inside the EntityManager/EntityProvider structure, instead of its previous implementation directly in EntityService.

There are still a few read-only APIs that are implemented directly in EntityService and won't throw an error for Azure workspaces. However, all write APIs are now protected, so there's no way to get data IN to the system for those read APIs to return. I think this satisfies the intent of the Jira ticket, without blowing up scope too much.

Update 8-Dec: I tested this in a BEE with the latest UI code, and all works as expected.


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

if (!WorkspaceType.RawlsWorkspace.equals(requestArguments.workspace.workspaceType)) {
throw new DataEntityException(s"This functionality only available to ${CloudPlatform.GCP} workspaces.")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the heart of the PR: throw an error for non-RawlsWorkspace workspaces.

ctx
)
.recover(bigQueryRecover)
} yield entityCopyResponse
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While moving the important implementation inside the LocalEntityProvider, I took the opportunity to refactor and simplify this method. It is now one big for-yield instead of a mix of flatMaps and for-yields, AND it removes outbound REST calls from Rawls to Sam from being inside a database transaction.

else {
val missingGroups = sourceWorkspaceADs -- destWorkspaceADs
val errorMsg =
s"Source workspace has an Authorization Domain containing the groups ${missingGroups.mkString(", ")}, which are missing on the destination workspace"
DBIO.failed(new RawlsExceptionWithErrorReport(ErrorReport(StatusCodes.UnprocessableEntity, errorMsg)))
throw new RawlsExceptionWithErrorReport(ErrorReport(StatusCodes.UnprocessableEntity, errorMsg))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This authDomainCheck method has only one usage - inside copyEntities, which I rewrote above. There was no need for authDomainCheck to return its result wrapped in a ReadWriteAction.

@@ -317,7 +317,7 @@ trait EntityApiService extends UserInfoDirectives {
entity(as[EntityCopyDefinition]) { copyDefinition =>
complete {
entityServiceConstructor(ctx)
.copyEntities(copyDefinition, request.uri, linkExistingEntitiesBool)
.copyEntities(copyDefinition, linkExistingEntitiesBool)
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 have no idea why the request URI was passed into copyEntities. It was never used, and I removed it from the argument list for copyEntities.

@davidangb
Copy link
Contributor Author

two service timeouts in integration tests. Jenkins retest.

@@ -62,6 +63,9 @@ object RawlsApiService extends LazyLogging {
Sentry.captureException(wsmApiException)
}
complete(wsmApiException.getCode -> ErrorReport(wsmApiException).copy(stackTrace = Seq()))
case dataEntityException: DataEntityException =>
// propagate only the message; don't include the stack trace
complete(dataEntityException.code -> ErrorReport(dataEntityException.getMessage))
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 thought about removing stack traces from the response in the catch-all case just below this … but that seemed like it could impact use cases I didn't want to think through. So, I'm adding a case just for DataEntityException, which is only thrown by data tables. There's no need to send the stack trace to the end user for these exceptions.

@davidangb
Copy link
Contributor Author

Jenkins retest, trying to get the TSPS fix in

@davidangb
Copy link
Contributor Author

a few 503s from jenkins. Jenkins retest.

@davidangb
Copy link
Contributor Author

One error on "Billing Project tmp-billing-project-1f5db88701 does not exist in Rawls". Jenkins retest.

@davidangb
Copy link
Contributor Author

well this is frustrating. More 503s. Jenkins retest.

@davidangb davidangb merged commit c6dff0e into develop Dec 10, 2023
12 checks passed
@davidangb davidangb deleted the da_AJ-1438_disableEntitiesInAzure branch December 10, 2023 19:35
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