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

use new sam client to cascade #3075

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}]"
Expand All @@ -534,7 +540,7 @@ class WorkspaceService(
)
throw t
}
)
}
} yield {
aborts.onComplete {
case Failure(t) =>
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading