Skip to content

Refactor roles: static definitions in bundle#1209

Merged
jotak merged 4 commits intonetobserv:mainfrom
jotak:refactor-roles
Mar 13, 2025
Merged

Refactor roles: static definitions in bundle#1209
jotak merged 4 commits intonetobserv:mainfrom
jotak:refactor-roles

Conversation

@jotak
Copy link
Member

@jotak jotak commented Mar 4, 2025

Description

Move all roles from in-code/dynamic definition to yaml/bundle static definions.

It better clarifies which roles are used and why. Use a finer granularity in role definitions, and keep only the logic for bindings attribution.

All component roles are defined in config/rbac/component_roles.yaml. Files netobserv-<rolename>_etc.yaml in bundle are generated from component_roles.yaml

New functions to generate bindings for roles

Change prometheus role to be a namespaced role instead of cluster role

Remove a few unnecessary roles

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
    • If so, make sure the JIRA epic is labeled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
    • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
    • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

@jotak jotak requested a review from OlivierCazade March 4, 2025 18:06
Copy link
Member

@OlivierCazade OlivierCazade left a comment

Choose a reason for hiding this comment

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

One comment about some tests, but most of the PR is looking good to me.

// By("Not expecting mono-ingester role binding")
// Eventually(func() interface{} {
// return k8sClient.Get(ctx, rbKeyTransformMono, &rbacv1.ClusterRoleBinding{})
// }, timeout, interval).Should(MatchError(`clusterrolebindings.rbac.authorization.k8s.io "flowlogs-pipeline-transformer-role-mono" not found`))
Copy link
Member

Choose a reason for hiding this comment

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

Were these comments intended ?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably something I forgot to finish, thanks for pointing this out :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

jotak added 3 commits March 12, 2025 10:13
Move all roles from in-code/dynamic definition to yaml/bundle static
definions.

It better clarifies which roles are used and why. Use a finer
granularity in role definitions, and keep only the logic for bindings
attribution.

All component roles are defined in `config/rbac/component_roles.yaml`.
Files `netobserv-<rolename>_etc.yaml` in bundle are generated from component_roles.yaml

New functions to generate bindings for roles

Change prometheus role to be a namespaced role instead of cluster role

Remove a few unnecessary roles
- Add previous CRB to the cleanup list, as their names changed
  - We won't clean up old cluster roles, since we're removing the CR
    create/update/delete permission to the operator, we can't do that.
They'll just remain on the cluster, unused.
  - Removing old entries from the cleanup list, dating back to 1.3/1.5.
    Since operator upgrades doesn't jump over versions, they should have
already been clean up from previous upgrades

- Shorten CRB names

- Fix tests
@codecov
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 86.97674% with 56 lines in your changes missing coverage. Please review.

Project coverage is 62.63%. Comparing base (7e68060) to head (3ab567a).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
controllers/flp/flp_monolith_objects.go 85.10% 10 Missing and 4 partials ⚠️
controllers/flp/flp_transfo_objects.go 86.00% 10 Missing and 4 partials ⚠️
controllers/flp/flp_monolith_reconciler.go 68.42% 5 Missing and 7 partials ⚠️
controllers/flp/flp_transfo_reconciler.go 79.31% 2 Missing and 4 partials ⚠️
controllers/flp/flp_common_objects.go 95.06% 3 Missing and 1 partial ⚠️
...ntrollers/ebpf/internal/permissions/permissions.go 25.00% 2 Missing and 1 partial ⚠️
controllers/monitoring/monitoring_controller.go 33.33% 1 Missing and 1 partial ⚠️
pkg/cleanup/cleanup.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1209      +/-   ##
==========================================
+ Coverage   62.42%   62.63%   +0.21%     
==========================================
  Files          77       76       -1     
  Lines       11581    11503      -78     
==========================================
- Hits         7229     7205      -24     
+ Misses       3893     3834      -59     
- Partials      459      464       +5     
Flag Coverage Δ
unittests 62.63% <86.97%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
controllers/consoleplugin/consoleplugin_objects.go 85.59% <ø> (-0.88%) ⬇️
...trollers/consoleplugin/consoleplugin_reconciler.go 69.14% <100.00%> (+2.09%) ⬆️
controllers/flp/flp_controller.go 64.40% <ø> (+0.40%) ⬆️
controllers/monitoring/monitoring_objects.go 88.00% <ø> (+36.23%) ⬆️
controllers/reconcilers/common.go 90.00% <ø> (+15.00%) ⬆️
...trollers/reconcilers/namespaced_objects_manager.go 87.71% <100.00%> (+0.44%) ⬆️
controllers/reconcilers/reconcilers.go 72.14% <100.00%> (+10.69%) ⬆️
pkg/helper/flowcollector.go 82.37% <100.00%> (ø)
pkg/manager/manager.go 58.18% <ø> (ø)
pkg/resources/roles.go 100.00% <100.00%> (ø)
... and 9 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@OlivierCazade OlivierCazade left a comment

Choose a reason for hiding this comment

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

LGTM

@jotak
Copy link
Member Author

jotak commented Mar 13, 2025

/approve

@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jotak jotak added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Mar 13, 2025
@jotak jotak merged commit e414e32 into netobserv:main Mar 13, 2025
13 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm ok-to-test To set manually when a PR is safe to test. Triggers image build on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants