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

remove eager pet service account creation #3036

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 @@ -6,28 +6,41 @@ import org.broadinstitute.dsde.rawls.NoSuchWorkspaceException
import org.broadinstitute.dsde.rawls.dataaccess._
import org.broadinstitute.dsde.rawls.dataaccess.slick._
import org.broadinstitute.dsde.rawls.metrics.RawlsInstrumented
import org.broadinstitute.dsde.rawls.model.{AttributeName, AttributeValue,WorkspaceAttributeSpecs, ErrorReportSource, ManagedGroupRef, RawlsGroupName, RawlsRequestContext, SamResourceTypeName, SamResourceTypeNames, Workspace, WorkspaceDetails, WorkspaceFeatureFlag, WorkspaceName}
import org.broadinstitute.dsde.rawls.model.{
AttributeName,
AttributeValue,
ErrorReportSource,
ManagedGroupRef,
RawlsGroupName,
RawlsRequestContext,
SamResourceTypeName,
SamResourceTypeNames,
Workspace,
WorkspaceAttributeSpecs,
WorkspaceDetails,
WorkspaceFeatureFlag,
WorkspaceName
}
import org.broadinstitute.dsde.rawls.util._

import scala.concurrent.{ExecutionContext, Future}
import scala.language.postfixOps

object WorkspaceAdminService {
def constructor(dataSource: SlickDataSource,

gcsDAO: GoogleServicesDAO,
samDAO: SamDAO,
workbenchMetricBaseName: String,
)(
ctx: RawlsRequestContext
)(implicit materializer: Materializer, executionContext: ExecutionContext): WorkspaceAdminService =
workbenchMetricBaseName: String
)(
ctx: RawlsRequestContext
)(implicit materializer: Materializer, executionContext: ExecutionContext): WorkspaceAdminService =
new WorkspaceAdminService(
ctx,
dataSource,
gcsDAO,
samDAO,
workbenchMetricBaseName,
new WorkspaceRepository(dataSource),
new WorkspaceRepository(dataSource)
)
}

Expand All @@ -37,14 +50,14 @@ class WorkspaceAdminService(
protected val gcsDAO: GoogleServicesDAO,
val samDAO: SamDAO,
override val workbenchMetricBaseName: String,
val workspaceRepository: WorkspaceRepository,
) (implicit protected val executionContext: ExecutionContext)
extends LazyLogging
with RawlsInstrumented
with RoleSupport
with WorkspaceSupport {
val workspaceRepository: WorkspaceRepository
)(implicit protected val executionContext: ExecutionContext)
extends LazyLogging
with RawlsInstrumented
with RoleSupport
with WorkspaceSupport {

implicit val errorReportSource: ErrorReportSource = ErrorReportSource ("rawls")
implicit val errorReportSource: ErrorReportSource = ErrorReportSource("rawls")

// Admin endpoint, not limited to V2 workspaces
def listAllWorkspaces(): Future[Seq[WorkspaceDetails]] =
Expand All @@ -57,7 +70,7 @@ extends LazyLogging
// Admin endpoint, not limited to V2 workspaces
def adminListWorkspacesWithAttribute(attributeName: AttributeName,
attributeValue: AttributeValue
): Future[Seq[WorkspaceDetails]] =
): Future[Seq[WorkspaceDetails]] =
asFCAdmin {
for {
workspaces <- dataSource.inTransaction { dataAccess =>
Expand All @@ -84,7 +97,7 @@ extends LazyLogging
// Admin endpoint, not limited to V2 workspaces
def adminOverwriteWorkspaceFeatureFlags(workspaceName: WorkspaceName,
flagNames: List[String]
): Future[Seq[WorkspaceFeatureFlag]] =
): Future[Seq[WorkspaceFeatureFlag]] =
asFCAdmin {
val flags = flagNames.map(WorkspaceFeatureFlag)

Expand All @@ -103,18 +116,17 @@ extends LazyLogging
private def withWorkspaceContext[T](workspaceName: WorkspaceName,
dataAccess: DataAccess,
attributeSpecs: Option[WorkspaceAttributeSpecs] = None
)(op: Workspace => ReadWriteAction[T]) =
)(op: Workspace => ReadWriteAction[T]) =
dataAccess.workspaceQuery.findByName(workspaceName, attributeSpecs) flatMap {
case None => throw NoSuchWorkspaceException(workspaceName)
case None => throw NoSuchWorkspaceException(workspaceName)
case Some(workspace) => op(workspace)
}

private def loadResourceAuthDomain(resourceTypeName: SamResourceTypeName,
resourceId: String
): Future[Set[ManagedGroupRef]] =
): Future[Set[ManagedGroupRef]] =
samDAO
.getResourceAuthDomain(resourceTypeName, resourceId, ctx)
.map(_.map(g => ManagedGroupRef(RawlsGroupName(g))).toSet)


}
Original file line number Diff line number Diff line change
Expand Up @@ -2213,11 +2213,12 @@ class WorkspaceService(
)

// proactively create pet service account for user to start propagation of IAM
_ <- traceDBIOWithParent("samDAO.getPetServiceAccountKeyForUser", parentContext)(_ =>
DBIO.from(
samDAO.getPetServiceAccountKeyForUser(savedWorkspace.googleProjectId, ctx.userInfo.userEmail)
)
)
// _ <- traceDBIOWithParent("samDAO.getPetServiceAccountKeyForUser", parentContext)(_ =>
// DBIO.from(
// samDAO.getPetServiceAccountKeyForUser(savedWorkspace.googleProjectId, ctx.userInfo.userEmail)
// )
// )

} yield savedWorkspace
}

Expand Down
Loading