Fix seeing resources after rolebinding has been deleted for user #3433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2733
Added being able to create ClusterRoles and Roles without rules to simulate manual creation of objects for delete transactions.
Added creating a role or binding client object for delete transactions manually in case of an "object not found" error (which was previously returned + ignored for objects without finalizers).
Added sending delete object transactions with manually created RBAC client objects for deleted roles and bindings in case of an "object not found" error.
As discussed with @enekofb , added
IsValidID
method to role to be able to delete roles without policy rules (those, which are manually constructed for passing them with delete transactions).Updated corresponding tests in
reconciler
,rolecollector
, andstore
packages.Minor refactoring in variable names for consistency.
Notes:
Added a
CategoryRBAC
category toobjectkind
to supportassertObjectTransaction
calls when running reconciler tests on RBAC objects. If there is another option, please let me know.In
rolecollector_test
, count of upsert, delete, and deleteAll transactions (or calls?) are retained between tests. Is it expected behavior?Comment that "// Explorer should support aggregated clusteroles." was added based on a discussion with @enekofb
Testing:
I test it when running the app in Tilt. So, first run WGE with Tilt as a developer.
The export the
wego-admin-read-apps
ClusterRoleBinding
andgitops-apps-reader
ClusterRole
as YAML and copy and paste the output to a YAML file to re-apply them later.Then open Explorer, confirm that objects are visible in Explorer as expected, and delete these
ClusterRoleBinding
andClusterRole
:The objects should disappear in Explorer. Then apply the YAML to which you saved the output to re-create these
ClusterRoleBinding
andClusterRole
— and the objects should appear in Explorer again.Here is a screen recording of a testing session:
Screen.Recording.2023-10-05.at.18.45.55.mov
Not sure why the only object appears after deleting the ClusterRoleBinding, but I don't think it is related to Explorer, probably smth. related to how RBAC is setup for development.