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..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 @@ -327,6 +327,18 @@ class HttpSamDAO(baseSamServiceURL: String, rawlsCredential: RawlsCredential, ti callback.future.map(_ => ()) } + override def deleteResourceCascade(resourceTypeName: SamResourceTypeName, + resourceId: String, + ctx: RawlsRequestContext + ): Future[Unit] = + retry(when401or5xx) { () => + val callback = new SamApiCallback[Void]("deleteResourceCascadeV2") + + resourcesApi(ctx).deleteResourceCascadeV2Async(resourceTypeName.value, resourceId, callback) + + callback.future.map(_ => ()) + } + override def userHasAction(resourceTypeName: SamResourceTypeName, resourceId: String, action: SamResourceAction, 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..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,9 +524,10 @@ class WorkspaceService( ) throw t } - ) - _ <- traceFutureWithParent("deleteWorkspaceSamResource", ctx)(_ => - samDAO.deleteResource(SamResourceTypeNames.workspace, workspace.workspaceId, ctx) recover { + } + _ <- 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( s"Received 404 from delete workspace resource in Sam (while deleting workspace) for workspace `${workspace.toWorkspaceName}`: [${t.errorReport.message}]" @@ -534,7 +540,7 @@ class WorkspaceService( ) throw t } - ) + } } yield { aborts.onComplete { case Failure(t) => diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 0a4926ae85..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.278") + 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