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

[BUG] Annotations conflict when using a single Secret for multiple users #884

Closed
evheniyt opened this issue Oct 28, 2024 · 2 comments · Fixed by #899
Closed

[BUG] Annotations conflict when using a single Secret for multiple users #884

evheniyt opened this issue Oct 28, 2024 · 2 comments · Fixed by #899
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@evheniyt
Copy link
Contributor

In our configuration, we have a single Secret users-credentials which contains passwords for multiple Opensearch users.
Users configuration looks like this:

  users:
    - name: backup-and-restore
      secretName: users-credentials
      secretKey: backup-and-restore
    - name: collections
      secretName: users-credentials
      secretKey: collections
    - name: es-consumer
      secretName: users-credentials
      secretKey: es-consumer

So each user takes it's password from the users-credentials Secret, where the password is a dedicated Secret key.
But after Operator created these users, we could see constant changes in Secret annotations. During reconciling loop Operator updates Secret annotation for each user.

I think it's a pretty common scenario when we are taking Secret from some external secret manager and want to share it by multiple users. Do we really need to set these annotations for the Secret?

@evheniyt evheniyt added bug Something isn't working untriaged Issues that have not yet been triaged labels Oct 28, 2024
@swoehrl-mw
Copy link
Collaborator

Hi @evheniyt

I think it's a pretty common scenario when we are taking Secret from some external secret manager and want to share it by multiple users.

I agree.

Do we really need to set these annotations for the Secret?

I had a quick look at the code and I don't see a technical need for setting the annotations. So I'm fine with removing that code. Would you be open to filing a PR for that?

@swoehrl-mw swoehrl-mw added good first issue Good for newcomers and removed untriaged Issues that have not yet been triaged labels Nov 5, 2024
@evheniyt
Copy link
Contributor Author

evheniyt commented Nov 5, 2024

Will do it soon

swoehrl-mw pushed a commit that referenced this issue Nov 18, 2024
### Description
Correctly set annotations for Secret that stores multiple User
passwords.
`OsUserNameAnnotation` will be assigned only to the Secret that is
storing the password for a single user. Otherwise, if Secret is used by
multiple Users this annotation will be skipped.

To support correct reconciliation for multi-user Secret, I have added
iteration over `secretObj.Data`.
In the case of multi-user Secret, reconciliation will work only if the
Secret keys correspond to the User name. So in theory there could be a
breaking change here for people who are using multi-user Secret and have
different Secret keys and User names.

### Issues Resolved
Closes #884

### Check List
- [x] Commits are signed per the DCO using --signoff 
- [x] Unittest added for the new/changed functionality and all unit
tests are successful
- [x] Customer-visible features documented
- [x] No linter warnings (`make lint`)


Please refer to the [PR
guidelines](https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/developing.md#submitting-a-pr)
before submitting this pull request.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Yevhenii Tiutiunnyk <[email protected]>
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Engineering Effectiveness Board Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants