Skip to content

Conversation

@zzzeek
Copy link
Contributor

@zzzeek zzzeek commented Jul 1, 2025

The existing mariadb operator in fact already "supports" in-place
change of secret, since if you change Spec.Secret to a new secret
name, that would imply a new job hash, and the account.sh script running
using only GRANT statements would update the password per mariadb.
This already works for flipping the TLS flag on and off too.

So in this patch, we clean this up and add a test to include:

  • a new field Status.CurrentSecret, which is used to indicate the
    previous secret from which the finalizer should be removed. This will
    also be used when we migrate the root password to use MariaDBAccount
    by providing the "current" root password when changing to a new root
    password
  • improved messaging in log messages, name of job. This changes the
    job hash for mariadbaccount which will incur a run on existing environments,
    however the
    job hashes are already changing on existing environments due to the
    change in how the mysql root password is sent, i.e. via volume mounted
    script rather than env var secret
  • update account.sh to use modern idiomatic patterns for user create
    /alter, while mariadb is fine with the legacy style of using only
    GRANT statements, MySQL 8 no longer allows this statement to proceed
    without a CREATE USER, so formalize the commands used here to use
    distinct CREATE USER, ALTER USER, GRANT statements and clarify the
    script is good for all create/update user operations.

@openshift-ci openshift-ci bot requested review from dciabrin and dprince July 1, 2025 13:13
@zzzeek zzzeek changed the title support in-place secret changes support in-place secret changes (PR 5 of 6) Jul 1, 2025
@zzzeek zzzeek force-pushed the OSPRH-14916-pr5 branch 3 times, most recently from 11b8925 to a1ccbd6 Compare July 4, 2025 16:09
@zzzeek zzzeek force-pushed the OSPRH-14916-pr5 branch 2 times, most recently from 06467ea to 350ed1f Compare August 18, 2025 19:22
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 11, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zzzeek
Once this PR has been reviewed and has the lgtm label, please assign viroel for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@zzzeek zzzeek force-pushed the OSPRH-14916-pr5 branch 3 times, most recently from 116ddda to 74e9a8e Compare October 12, 2025 21:59
@zzzeek zzzeek force-pushed the OSPRH-14916-pr5 branch 2 times, most recently from e685bef to 1811f02 Compare November 6, 2025 12:30
introduce a new class of MariaDBAccount called a "system"
MariaDBAccount, indicated by a new enumerated field AccountType
on the CR.  Such accounts link directly to a Galera instance
and have no dependency on a MariaDBDatabase CR.

The expected targets for "system" accounts will include the
Galera/mysql root username and password, as well as a system
account used by mariadbbackup for SST.

Refactor mariadbaccount_controller to isolate logic used for
acquiring MariaDBDatabase and Galera CRs into separate functions,
and ensure all MariaDBDatabase logic takes place only for "user"
accounts (which would be all current MariaDBAccount CRs).

Also correct an oversight where MariaDBAccount would not unconditionally
apply a finalizer to its Secret object.   This logic now takes place
in addition to an unconditional removal of the finalizer when the
MariaDBAccount object is deleted.

A subsequent change will allow system-level passwords to be changed
in place by applying the secret name to two separate fields
MariaDBAccount/Spec/Secret and MariaDBAccount/Status/Secret.  When
these two names differ it will indicate an in-place password change
should take place.
The existing mariadb operator in fact already "supports" in-place
change of secret, since if you change Spec.Secret to a new secret
name, that would imply a new job hash, and the account.sh script running
using only GRANT statements would update the password per mariadb.
This already works for flipping the TLS flag on and off too.

So in this patch, we clean this up and add a test to include:

* a new field Status.CurrentSecret, which is used to indicate the
  previous secret from which the finalizer should be removed.  This will
  also be used when we migrate the root password to use MariaDBAccount
  by providing the "current" root password when changing to a new root
  password
* improved messaging in log messages, name of job.   This changes the
  job hash for mariadbaccount which will incur a run on existing environments,
  however the
  job hashes are already changing on existing environments due to the
  change in how the mysql root password is sent, i.e. via volume mounted
  script rather than env var secret
* update account.sh to use modern idiomatic patterns for user create
  /alter, while mariadb is fine with the legacy style of using only
  GRANT statements, MySQL 8 no longer allows this statement to proceed
  without a CREATE USER, so formalize the commands used here to use
  distinct CREATE USER, ALTER USER, GRANT statements and clarify the
  script is good for all create/update user operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant