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

migrate from databaseUsername to databaseAccount #167

Conversation

zzzeek
Copy link
Contributor

@zzzeek zzzeek commented Feb 23, 2024

This moves placement to fully use MariaDBAccount based on the dev work being done for mariadb-operator:

https://github.com/openstack-k8s-operators/mariadb-operator/pull/184/files

Lead Jira: OSPRH-4095

  1. controller calls EnsureMariaDBAccount up front to make sure MariaDBAccount is present
  2. error code from EnsureMariaDBAccount is handled, Conditions are amended when error is returned
  3. controller calls NewDatabaseForAccount instead of NewDatabase
  4. GetAccountAndSecret is used to retrieve account /secret to populate template
  5. GetDatabaseByName() , normally used for delete finalizers, replaced with GetDatabaseByNameAndAccount
  6. CreateOrPatchAll() used to patch the Database, replacing CreateOrPatchDB / CreateOrPatchDBByName
  7. controller calls DeleteUnusedMariaDBAccountFinalizers when launched pods are definitely running on a new MariaDBAccount, returns error code if present
  8. PasswordSelectors that refer to database are removed
  9. all databaseUser replaced with databaseAccount inside of all XYZ_types.go
  10. all databaseUser replaced with databaseAccount inside of all kuttl/*.yaml
  11. all default databaseUser names become databaseAccount, replacing underscores with dashes inside of all XYZ_types.go
  12. all default databaseUser names become databaseAccount, replacing underscores with dashes inside of all kuttl/*.yaml
  13. MariaDBAccountSuiteTests are used in controller ginkgo tests if it has them
  14. Use configsecrets for database URLs; remove from job hash - already was like that
  15. 184 is merged and replaces from go.mod are removed

@zzzeek zzzeek force-pushed the integrate_oo_accounts branch 2 times, most recently from b6a74eb to b5821b4 Compare February 26, 2024 16:59
@zzzeek zzzeek force-pushed the integrate_oo_accounts branch from b5821b4 to ba0040b Compare February 26, 2024 17:15
@zzzeek zzzeek requested a review from stuggi February 26, 2024 17:16
controllers/placementapi_controller.go Outdated Show resolved Hide resolved
tests/functional/placementapi_controller_test.go Outdated Show resolved Hide resolved
tests/functional/base_test.go Outdated Show resolved Hide resolved
@zzzeek zzzeek force-pushed the integrate_oo_accounts branch from ba0040b to 39a8dd8 Compare February 26, 2024 17:30
// yet associated with any MariaDBDatabase.
_, _, err = mariadbv1.EnsureMariaDBAccount(
ctx, h, instance.Spec.DatabaseAccount,
instance.Namespace, false, placement.DatabaseName,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to set the requireTLS flag based on some input?

Copy link
Contributor

Choose a reason for hiding this comment

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

tls is used as soon the mariadbdatabase reflects it is hosted on a galera supporting tls and the service has a CA to validate it. we could add setting requiredTLS as a follow up. maybe after we switched our default to enable podlevel/internal tls per default?

Copy link
Collaborator

@gibizer gibizer Feb 27, 2024

Choose a reason for hiding this comment

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

I'm OK about a follow up, just seemed strange that we merged #165 yesterday in placement, and here we explicitly disable it. So I wanted to make sure it is intentional.

Copy link
Contributor Author

@zzzeek zzzeek Feb 27, 2024

Choose a reason for hiding this comment

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

the ensuremariadbaccount is ultimately going to be a receiver of a MariaDBAccount that may be coming from openstack-operator, and the account is not associated with any database as of yet. at this stage, it's not appropriate to set TLS, because nothing is yet known about what kind of database this account will be applied to. if we are flipping a TLS flag on when we do the ensure MariaDBDatabase phase, then we would want to flip on "require TLS" on the MariaDBAccount as well, and that would be within the mariadbdatabase_funcs. if that's the use we want? that is, if DB supports TLS, then all accounts should require TLS. is that a req?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK about a follow up, just seemed strange that we merged #165 yesterday in placement, and here we explicitly disable it. So I wanted to make sure it is intentional.

right, setting requireTLS == false is not that then no tls is used for db connection. it is just that this db user could use tls and non tls to connect. if tls is used is being controlled by the my.cnf content.

that is, if DB supports TLS, then all accounts should require TLS. is that a req?

I am not sure right now. I can discuss it in our tomorrows tls meeting and get back

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for the explanation. I defer to @stuggi if this is OK as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

we did not came up with a real preference if "require TLS" should be used as soon the DB supports TLS. since the services will use tls as soon the DB supports it and the service has the CA we could set it, but atm it won't hurt keep it available. I'd personally do it in a follow up, after we tested all the different scenarios, also with adoption in mind. adoption of tlse env is still in early phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yah i think this should be all followup stuff. we're just trying to get all the levers available right now (like, every controller gets a distinct DB password, stuff like that :) )

// created here with a generated username as well as a secret with
// generated password. The MariaDBAccount is created without being
// yet associated with any MariaDBDatabase.
_, _, err = mariadbv1.EnsureMariaDBAccount(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel that ensuring the DBAccount logically belongs to ensureDB, so I would move this new logic into that func.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I noticed that the recent merge has consolidated DB functions to be ahead of configmaps in any case, which was one of the reasons ensureaccount was up there. since ensureaccount isn't actually going away, for those controllers where ensuredb is before configmaps (Which I guess will be all of them now), might as well put ensure account into it. it starts to look like the whole of the various ensureDB functions could just be one big function in mariadb-operator, but i dont know that we have time to do all that just yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, @stuggi fixed the ordering of the steps to have db created before we generate config. I would do the ensureDB consolidation here locally, and maybe looking at a common mariadb-operator/api function later separatly

tests/functional/placementapi_controller_test.go Outdated Show resolved Hide resolved
@zzzeek zzzeek force-pushed the integrate_oo_accounts branch from 39a8dd8 to 33e80c2 Compare February 27, 2024 19:42
Copy link
Collaborator

@gibizer gibizer left a comment

Choose a reason for hiding this comment

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

looks good to me. We just need to land the mariadb dependency first

@zzzeek
Copy link
Contributor Author

zzzeek commented Feb 29, 2024

looks good to me. We just need to land the mariadb dependency first

yah once mariadb lands I can re-crank through everyone and add mistral / telemetry / barbican also

Copy link
Collaborator

@gibizer gibizer left a comment

Choose a reason for hiding this comment

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

I tested this and I was able to rotate the db password properly. Nice work!

Copy link
Contributor

openshift-ci bot commented Mar 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gibizer, zzzeek

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved label Mar 4, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 9270551 into openstack-k8s-operators:main Mar 4, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants