Skip to content
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

Remove "non-charmed" user deletion at update-status and client-broken #331

Closed
phvalguima opened this issue Jun 17, 2024 · 3 comments
Closed
Assignees
Labels
24.10-2/beta Bugs targeted to be fixed for 2/beta on 24.10 bug Something isn't working

Comments

@phvalguima
Copy link
Contributor

Currently, we have OpenSearchUserManager.remove_users_and_roles, which removes users and roles that are not linked to system users or existing relations. The removal happens here.

This method is called in two different places: update status and client relation broken events. Now, removing the relation user and role makes sense, but we should only remove that user / role, not a generic clean-up. We should also remove the call from update_status.

@phvalguima phvalguima added the bug Something isn't working label Jun 17, 2024
Copy link
Contributor

@phvalguima phvalguima added the 24.10-2/beta Bugs targeted to be fixed for 2/beta on 24.10 label Jun 26, 2024
@phvalguima phvalguima changed the title Remove user deletion at update-status and client-broken Remove "non-charmed" user deletion at update-status and client-broken Jul 2, 2024
@Mehdi-Bendriss
Copy link
Contributor

Mehdi-Bendriss commented Jul 2, 2024

That's a good one. We should filter out of the removal / cleanup routine users not created through the charm's client relations.

@juditnovak
Copy link
Contributor

Shortly: the request is to support manually created users.

juditnovak added a commit that referenced this issue Sep 20, 2024
# Issue

Addressing #331 , namely that currently it's impossible to add users
manually to Opensearch, as they are cleaned up on the first
`update-status`.

# Solution

Saving every relation ID with the corresponding user's name in a
dictionary on the databag.
This allows us to keep track of relation users and the relations they
belong to.
This data structure is maintained such as
- `index-created` : adding new relation - usrer pair as craeting the
user in Opensearch
- `update-status`, `relation-broken`, `relation-departed`: removing
(stale or dedicated) relations - user pairs from the databag as removing
Opensearch users

## Developers' notes

In order to get involved scopes clear:
- Operations on the new databag structure are strongly coupled togeter.
Thus they MUST be in the same module.
  (This principle is also in attempt to decrease the "spagetti".)
- Since removing users is now clearly specific to client relations, this
functionality should reside in the Provider code.
Accompaigned with the suited user creation functionality encapsulating
all relation-specific details (role name same as username, databag
structures to be maintained, etc.)
- Note: since extra user roles may be shared across multiple users, and
re-used, we do NOT clean up those. But normal roles only.
- Note2: We are taking advantage of usernames being equal to their
related roles (and don't store roles specifically).

---------

Co-authored-by: Judit Novak <judit.novak@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
24.10-2/beta Bugs targeted to be fixed for 2/beta on 24.10 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants