-
Notifications
You must be signed in to change notification settings - Fork 7
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
[PF-1681] Add discoverer policy when creating SAM workspace resource #755
Conversation
@@ -71,7 +72,11 @@ public StepResult doStep(FlightContext flightContext) | |||
newBindings.addAll(currentPolicy.getBindings()); | |||
// Add appropriate project-level roles for each WSM IAM role. | |||
workspaceRoleGroupsMap.forEach( | |||
(role, email) -> newBindings.add(bindingForRole(role, email, gcpProjectId))); | |||
(wsmRole, email) -> { | |||
if (CUSTOM_GCP_PROJECT_IAM_ROLES.containsKey(wsmRole)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: now that CUSTOM_GCP_PROJECT_IAM_ROLES
is imported, also update line 110?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
@Test | ||
public void getWorkspace_doesNotReturnWorkspaceWithOnlyDiscovererRole() throws Exception { | ||
ApiCreatedWorkspace workspace = createWorkspace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since these are talking to real Sam, these tests will leave workspaces. could you delete them from these tests as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks. I always forget when to have tests delete workspaces, so I added a section to README, PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is incorrect and we don't need to sync the discoverer role
@@ -316,3 +316,14 @@ The integration tests live in the `integration` project. Consult the integration | |||
|
|||
In the early days of the project, there were JUnit-based integration tests. We are in | |||
process of migrating them to Test Runner. | |||
|
|||
#### Cleaning up workspaces in tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is incorrect. Please double check my understanding @zloery
Janitor just deletes projects, it does not do anything to clean up Sam, so we should never skip in-test cleanup.
Connected tests also use RBS and Janitor. It doesn't have anything to do with WSM being ephemeral, since Janitor is just deleting projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use Janitor in two ways:
- the
tools
RBS instance registers every project it hands out with Janitor to be cleaned up after some time. Since all our connected tests talk to this instance, the GCP projects get cleaned up eventually - After PF-886, you also can register a workspace with Janitor. After some time, Janitor will call WSM to delete the workspaces, which will clean up all of the WSM DB + Sam workspace + GCP project. The CLI tests use this when they run against real WSM environments, like dev.
We can't use the second pattern for WSM connected tests because the instance is ephemeral (so there's nothing for Janitor to call later), but we can and do use the first pattern to make sure the GCP projects get cleaned up. the Sam workspaces will still be around if the test doesn't clean them up, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated:
This has @zloery 's stamp of approval.
if (highestRole.isPresent()) { | ||
// TODO(PF-1875): Support requesting discoverer workspaces in ListWorkspaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just filter in ListWorkspaces, so you don't have to remember to come back to this code?
You need the filtering there anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next PR, I updated both here and ListWorkspaces.
@@ -47,6 +47,9 @@ public StepResult doStep(FlightContext flightContext) | |||
workspaceRoleGroupMap.put( | |||
WsmIamRole.READER, | |||
samService.syncWorkspacePolicy(workspaceUuid, WsmIamRole.READER, userRequest)); | |||
workspaceRoleGroupMap.put( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to sync the discoverer role. That will create Google groups for discoverers. We only need that when we are going to apply that group to a cloud resource ACL; like granting a READER actual read access to a GCS bucket.
I think we only ever enforce discoverer by checking with Sam - never the cloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, good point.
README.md
Outdated
|
||
#### Cleaning up workspaces in tests | ||
|
||
For integration tests, don't need to delete workspaces because it's taken care of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestRunner isn't integrated with Janitor so it isn't doing this cleanup (though it could if we were testing against live environments and we built that integration). The cleanup is currently part of the tests (though since it's included in the WorkspaceAllocateTestScriptBase
base class, developers don't need to think about it while writing tests)
This PR:
Future PRs will modify ListWorkspaces/GetWorkspace to add a request permission for returning discoverer workspaces. For now, ListWorkspaces does not return a workspace if caller is only discoverer.
Manually tested:
WorkspaceApiControllerTest.java uses mock bio.terra.workspace.service.iam.SamService. I wanted my tests to use real bio.terra.workspace.service.iam.SamService, so I created WorkspaceApiControllerConnectedTest.java.