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

[WOR-1348] Fix GCP Enhanced Bucket Monitoring on Clone #2654

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -1128,8 +1128,8 @@ class WorkspaceService(protected val ctx: RawlsRequestContext,
newAttrs = sourceWorkspaceContext.attributes ++ destWorkspaceRequest.attributes
destWorkspaceContext <- traceDBIOWithParent("createNewWorkspaceContext (cloneWorkspace)", ctx) { s =>
val forceEnhancedBucketMonitoring =
destWorkspaceRequest.enhancedBucketLogging.exists(identity) || sourceBucketNameOption.exists(
_.startsWith(s"${config.workspaceBucketNamePrefix}-secure")
destWorkspaceRequest.enhancedBucketLogging.exists(identity) || sourceWorkspace.bucketName.startsWith(
s"${config.workspaceBucketNamePrefix}-secure"
)
createNewWorkspaceContext(
destWorkspaceRequest.copy(authorizationDomain = Option(newAuthDomain),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,32 @@ class WorkspaceServiceSpec
workspace.bucketName should startWith(s"${services.workspaceServiceConfig.workspaceBucketNamePrefix}-secure")
}

it should "clone a workspace with an enhanced bucket monitoring, resulting in the child workspace having enhanced logging even if the destination bucket location is defined" in withTestDataServices {
services =>
val baseWorkspaceName = "secure_space_for_workin"
val baseWorkspaceRequest = WorkspaceRequest(
testData.testProject1Name.value,
baseWorkspaceName,
Map.empty,
authorizationDomain = Option(Set(testData.dbGapAuthorizedUsersGroup))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the auth domain case worked before, and what failed was when the original workspace had "enahncedBucketLogging" set to true but no auth domains.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intersting, I got a test failure when I removed my fix, and a pass when I included it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, the bug we are seeing from terra-ui is specific to not checking "enhancedBucketLogging" but that's probably because we force "enhancedBucketLogging" to be true for workspaces that have an auth domain. So if we didn't send the option in the clone request I guess we would see the bug then also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the test case to be even clearer

)
val baseWorkspace = Await.result(services.workspaceService.createWorkspace(baseWorkspaceRequest), Duration.Inf)

val newWorkspaceName = "cloned_space"
val workspaceRequest =
WorkspaceRequest(testData.testProject1Name.value, newWorkspaceName, Map.empty, bucketLocation = Some("US"))

val workspace =
Await.result(services.mcWorkspaceService.cloneMultiCloudWorkspace(services.workspaceService,
baseWorkspace.toWorkspaceName,
workspaceRequest
),
Duration.Inf
)

workspace.bucketName should startWith(s"${services.workspaceServiceConfig.workspaceBucketNamePrefix}-secure")
}

it should "create a bucket with enhanced logging when told to, even if the parent workspace doesn't have it" in withTestDataServices {
services =>
val baseWorkspaceName = "secure_space_for_workin"
Expand Down
Loading