Skip to content

Support filtering by resource type, and more focused namespace retrieval. - #48

Closed
mnbbrown wants to merge 1 commit into
robusta-dev:mainfrom
mnbbrown:filter-by-namespace-by-resource
Closed

mnbbrown wants to merge 1 commit into
robusta-dev:mainfrom
mnbbrown:filter-by-namespace-by-resource

Conversation

@mnbbrown

@mnbbrown mnbbrown commented May 25, 2023 •

Copy link
Copy Markdown

This allows non-admin users on RBAC enforced clusters to run krr.

It does this by:

  • Adding a new CLI flag called "resources" which allows users to only
    run krr on specific resources.

  • Using the _namespaced_ functions in the k8s python client library
    where specific namespaces are being queried.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This allows non-admin users on RBAC enforced clusters to run krr.

It does this by:

- Adding a new CLI flag called "resources" which allows users to only
  run krr on specific resources.

- Using the `_namespaced_` functions in the k8s python client library
  where specific namespaces are being queried.
@mnbbrown
mnbbrown force-pushed the filter-by-namespace-by-resource branch from 2584629 to 57bdd6d Compare May 25, 2023 14:07
@mnbbrown
mnbbrown marked this pull request as ready for review May 25, 2023 14:11
@LeaveMyYard
LeaveMyYard self-requested a review May 25, 2023 19:05
@LeaveMyYard

Copy link
Copy Markdown
Contributor

Hey, @mnbbrown!
Thanks for the PR! I will test it tomorrow.
Could you sign the CLA please (look in the PR messages ^)?

@LeaveMyYard LeaveMyYard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work! Found some space to improvements and left them as comments.

for item in ret.items:
resources.append(item)
else:
for namespace in self.config.namespaces:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we are doing a for loop in a blocking manner. Using asyncio.gather should give us a performance boost

list_fns.append(self._list_all_daemon_set)
if self._should_list_resource("jobs"):
list_fns.append(self._list_all_jobs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should add a warning in case filtering by resources ends up in filtering everything, as it might be confusing to user.

if v == []:
return "*"

return v

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe to also make those resources case-insensitive by adding return [res.lower() for res in v].
With current implementation "Deployment" passed from user in CLI will not make it to show deployments.


async def _list_resources(self, all_namespaces_fn, namespaced_fn):
resources = []
if self.config.namespaces == "*":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think here you accidentally lost the logic where kube-system is ignored by default (when scanning with "*")

@LeaveMyYard LeaveMyYard added bug Something isn't working enhancement New feature or request labels May 29, 2023
Comment thread robusta_krr/main.py
resources: List[str] = typer.Option(
None,
"--resource",
"-n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
"-n",
"-r",

@LeaveMyYard

Copy link
Copy Markdown
Contributor

@mnbbrown I can finish your PR, if you want, but I need you to sign the CLA for that

@LeaveMyYard

Copy link
Copy Markdown
Contributor

@mnbbrown Hey again! Can you just sign the CLA requested by the bot? I will finish everything else. It will take a few minutes of your time

@LeaveMyYard

Copy link
Copy Markdown
Contributor

Remade as #122

@LeaveMyYard LeaveMyYard closed this Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants