Conversation
This involves wiring up all the crawlers to have a workspace client, needed to locate the workspace administrator when an owner for the object cannot be found.
| Iterable[User]: The active workspace administrators, if any. | ||
| """ | ||
| all_users = ws.users.list(attributes="id,active,userName,roles") | ||
| return (user for user in all_users if user.active and _has_role(user, "workspace_admin")) |
There was a problem hiding this comment.
do we have that role and it's no longer the admins group membership?
There was a problem hiding this comment.
No, this was just a guess while I figured out how it's supposed to be done. (And indeed, it now uses membership of the admins workspace group.)
| found. | ||
| """ | ||
| first_user = functools.partial(min, default=None, key=lambda user: user.name) | ||
| return first_user(find_workspace_admins(ws)) or first_user(find_account_admins(ws)) |
There was a problem hiding this comment.
don't forget to sort, because each invocation first user will be different.
…ace and account users.
…if a user directly associated with the resource cannot be located.
nfx
left a comment
There was a problem hiding this comment.
rewrite assert "@" in ownership.owner_of(grant_record) to check for concrete usernames as much as possible, as these tests don't test enough - e.g. hiding the problem
| # Verify ownership is as expected. | ||
| ownership = ClusterOwnership(runtime_ctx.administrator_locator) | ||
| assert ownership.owner_of(cluster_record_with_owner) == ws.current_user.me().user_name | ||
| assert "@" in ownership.owner_of(cluster_record_without_owner) |
There was a problem hiding this comment.
exact user name match is preferred
| def test_pipeline_ownership(ws, runtime_ctx, make_pipeline, inventory_schema, sql_backend) -> None: | ||
| """Verify the ownership can be determined for crawled pipelines.""" |
There was a problem hiding this comment.
| def test_pipeline_ownership(ws, runtime_ctx, make_pipeline, inventory_schema, sql_backend) -> None: | |
| """Verify the ownership can be determined for crawled pipelines.""" | |
| def test_verify_ownership_determined_for_crawled_pipelines(ws, runtime_ctx, make_pipeline, inventory_schema, sql_backend) -> None: |
|
|
||
| # Verify ownership can be made. | ||
| ownership = GrantOwnership(runtime_ctx.administrator_locator) | ||
| assert "@" in ownership.owner_of(grant_record) |
There was a problem hiding this comment.
rewrite assert "@" in ownership.owner_of(grant_record) to check for concrete usernames as much as possible, as these tests don't test enough - e.g. hiding the problem
For some reason deleting the owner of a cluster doesn't clear the creator field, even though the documentation says it should. Instead we just check that the creator is actually returned.
## Changes This updates an integration test to more thoroughly verify that we can locate the user-name of an administrator. ### Linked issues Follows: #2774 ### Tests - updated integration test
Changes
As part of #2761 we need to have a way for determining the user responsible for some of our inventory types. This PR updates the crawler framework so that:
Linked issues
Progresses #2761.
Functionality
A component for locating an administrator user.
Ownership information for the following inventory types:
ClusterInfoDirectFsAccess(stubbed)GrantJobInfoPipelineInfoPolicyInfoTableTableMigrationStatusUDFTests