From e388d5e4928a6dd7f6988fd41fb879431a451fce Mon Sep 17 00:00:00 2001 From: Bria Morgan Date: Tue, 8 Oct 2024 09:46:59 -0400 Subject: [PATCH 1/3] use new sam client to cascade --- .../dsde/rawls/dataaccess/HttpSamDAO.scala | 14 +++++++++++++- .../dsde/rawls/dataaccess/SamDAO.scala | 2 ++ .../dsde/rawls/workspace/WorkspaceService.scala | 2 +- project/Dependencies.scala | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala index 071fbe1c58..2abbd15e02 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala @@ -322,7 +322,19 @@ class HttpSamDAO(baseSamServiceURL: String, rawlsCredential: RawlsCredential, ti retry(when401or5xx) { () => val callback = new SamApiCallback[Void]("deleteResourceV2") - resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, callback) + resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, false, callback) + + callback.future.map(_ => ()) + } + + override def deleteResourceCascade(resourceTypeName: SamResourceTypeName, + resourceId: String, + ctx: RawlsRequestContext + ): Future[Unit] = + retry(when401or5xx) { () => + val callback = new SamApiCallback[Void]("deleteResourceV2") + + resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, true, callback) callback.future.map(_ => ()) } diff --git a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/SamDAO.scala b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/SamDAO.scala index cc95dd32dc..a466739ad9 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/SamDAO.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/SamDAO.scala @@ -56,6 +56,8 @@ trait SamDAO { def deleteResource(resourceTypeName: SamResourceTypeName, resourceId: String, ctx: RawlsRequestContext): Future[Unit] + def deleteResourceCascade(resourceTypeName: SamResourceTypeName, resourceId: String, ctx: RawlsRequestContext): Future[Unit] + def userHasAction(resourceTypeName: SamResourceTypeName, resourceId: String, action: SamResourceAction, diff --git a/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala b/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala index 2442b0b3d3..a0ac798b68 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala @@ -521,7 +521,7 @@ class WorkspaceService( } ) _ <- traceFutureWithParent("deleteWorkspaceSamResource", ctx)(_ => - samDAO.deleteResource(SamResourceTypeNames.workspace, workspace.workspaceId, ctx) recover { + samDAO.deleteResourceCascade(SamResourceTypeNames.workspace, workspace.workspaceId, ctx) recover { case t: RawlsExceptionWithErrorReport if t.errorReport.statusCode.contains(StatusCodes.NotFound) => logger.warn( s"Received 404 from delete workspace resource in Sam (while deleting workspace) for workspace `${workspace.toWorkspaceName}`: [${t.errorReport.message}]" diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 0a4926ae85..e006198b8d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -134,7 +134,7 @@ object Dependencies { val resourceBufferService = clientLibExclusions("bio.terra" % "terra-resource-buffer-client" % "0.198.42-SNAPSHOT") val billingProfileManager = clientLibExclusions("bio.terra" % "billing-profile-manager-client" % "0.1.566-SNAPSHOT") val terraCommonLib = tclExclusions(clientLibExclusions("bio.terra" % "terra-common-lib" % "0.1.23-SNAPSHOT" classifier "plain")) - val sam: ModuleID = clientLibExclusions("org.broadinstitute.dsde.workbench" %% "sam-client" % "v0.0.278") + val sam: ModuleID = clientLibExclusions("org.broadinstitute.dsde.workbench" %% "sam-client" % "v0.0.286-fd9b6b1-SNAP") val leonardo: ModuleID = "org.broadinstitute.dsde.workbench" % "leonardo-client_2.13" % "1.3.6-2e87300" // OpenTelemetry From 8659d7ad07e5f502c5e81ce0a7d2d18885daa0ff Mon Sep 17 00:00:00 2001 From: Bria Morgan Date: Wed, 9 Oct 2024 10:42:59 -0400 Subject: [PATCH 2/3] add logging --- .../rawls/workspace/WorkspaceService.scala | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala b/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala index a0ac798b68..44e3b7e508 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/rawls/workspace/WorkspaceService.scala @@ -495,16 +495,21 @@ class WorkspaceService( // Delete Google Project _ <- traceFutureWithParent("deleteGoogleProject", ctx)(_ => deleteGoogleProject(workspace.googleProjectId)) // attempt to delete workspace in WSM, in case thsi is a TDR snapshot - but don't fail on it - _ = Try(workspaceManagerDAO.deleteWorkspace(workspace.workspaceIdAsUUID, ctx)).recover { + _ = Try { + logger.warn(s"Deleting workspace in WSM") + workspaceManagerDAO.deleteWorkspace(workspace.workspaceIdAsUUID, ctx) + }.recover { case e: ApiException if e.getCode != StatusCodes.NotFound.intValue => logger.warn(s"Unexpected failure deleting workspace in WSM for workspace `${workspace.toWorkspaceName}]", e) } // Delete the workspace records in Rawls. Do this after deleting the google project to prevent service perimeter leaks. - _ <- traceFutureWithParent("deleteWorkspaceTransaction", ctx)(_ => + _ <- traceFutureWithParent("deleteWorkspaceTransaction", ctx) { _ => + logger.warn("deleting rawlsworkspace in ws repo") workspaceRepository.deleteRawlsWorkspace(workspace) - ) + } // Delete workflowCollection resource in sam outside of DB transaction - _ <- traceFutureWithParent("deleteWorkflowCollectionSamResource", ctx)(_ => + _ <- traceFutureWithParent("deleteWorkflowCollectionSamResource", ctx) { _ => + logger.warn("deleting workflow collection in sam") workspace.workflowCollectionName .map(cn => samDAO.deleteResource(SamResourceTypeNames.workflowCollection, cn, ctx)) .getOrElse(Future.successful(())) recover { @@ -519,8 +524,9 @@ class WorkspaceService( ) throw t } - ) - _ <- traceFutureWithParent("deleteWorkspaceSamResource", ctx)(_ => + } + _ <- traceFutureWithParent("deleteWorkspaceSamResource", ctx) { _ => + logger.warn("deleting sam workspace resource with cascade") samDAO.deleteResourceCascade(SamResourceTypeNames.workspace, workspace.workspaceId, ctx) recover { case t: RawlsExceptionWithErrorReport if t.errorReport.statusCode.contains(StatusCodes.NotFound) => logger.warn( @@ -534,7 +540,7 @@ class WorkspaceService( ) throw t } - ) + } } yield { aborts.onComplete { case Failure(t) => From d0ce6ddd05daed77d8943dfc85e026626068f8ae Mon Sep 17 00:00:00 2001 From: Bria Morgan Date: Tue, 15 Oct 2024 13:49:56 -0400 Subject: [PATCH 3/3] try other sam client --- .../broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala | 6 +++--- project/Dependencies.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala index 2abbd15e02..6b8ebb3c02 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/rawls/dataaccess/HttpSamDAO.scala @@ -322,7 +322,7 @@ class HttpSamDAO(baseSamServiceURL: String, rawlsCredential: RawlsCredential, ti retry(when401or5xx) { () => val callback = new SamApiCallback[Void]("deleteResourceV2") - resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, false, callback) + resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, callback) callback.future.map(_ => ()) } @@ -332,9 +332,9 @@ class HttpSamDAO(baseSamServiceURL: String, rawlsCredential: RawlsCredential, ti ctx: RawlsRequestContext ): Future[Unit] = retry(when401or5xx) { () => - val callback = new SamApiCallback[Void]("deleteResourceV2") + val callback = new SamApiCallback[Void]("deleteResourceCascadeV2") - resourcesApi(ctx).deleteResourceV2Async(resourceTypeName.value, resourceId, true, callback) + resourcesApi(ctx).deleteResourceCascadeV2Async(resourceTypeName.value, resourceId, callback) callback.future.map(_ => ()) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e006198b8d..4476f1612f 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -134,7 +134,7 @@ object Dependencies { val resourceBufferService = clientLibExclusions("bio.terra" % "terra-resource-buffer-client" % "0.198.42-SNAPSHOT") val billingProfileManager = clientLibExclusions("bio.terra" % "billing-profile-manager-client" % "0.1.566-SNAPSHOT") val terraCommonLib = tclExclusions(clientLibExclusions("bio.terra" % "terra-common-lib" % "0.1.23-SNAPSHOT" classifier "plain")) - val sam: ModuleID = clientLibExclusions("org.broadinstitute.dsde.workbench" %% "sam-client" % "v0.0.286-fd9b6b1-SNAP") + val sam: ModuleID = clientLibExclusions("org.broadinstitute.dsde.workbench" %% "sam-client" % "v0.0.289-3368aae-SNAP") val leonardo: ModuleID = "org.broadinstitute.dsde.workbench" % "leonardo-client_2.13" % "1.3.6-2e87300" // OpenTelemetry