Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/bases/mariadb.openstack.org_galeras.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ spec:
storageRequest:
description: Storage size allocated for the mariadb databases
type: string
targetVersion:
description: |-
TargetVersion is the MariaDB major.minor version that the cluster should
run after an upgrade (e.g. "10.11"). When set and different from the
version recorded in the existing data files, the operator performs a full
cluster stop and runs mariadb-upgrade on each node before restarting.
Leave empty when no version upgrade is in progress.
type: string
tls:
description: TLS settings for MySQL service and internal Galera replication
properties:
Expand Down
37 changes: 37 additions & 0 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const (
// MariaDBServerReadyCondition Status=True condition which indicates that the MariaDB and/or
// Galera server is ready for database / account create/drop operations to proceed
MariaDBServerReadyCondition condition.Type = "MariaDBServerReady"

// MariaDBServerUpgradeReadyCondition tracks the state of a MariaDB major
// version upgrade driven by Spec.TargetVersion. Status=True means no
// upgrade is pending (the deployed version matches the spec). Status=False
// with SeverityInfo means an upgrade is in progress; Status=False with
// SeverityError means an upgrade was requested but cannot start because the
// cluster is not fully available.
MariaDBServerUpgradeReadyCondition condition.Type = "MariaDBServerUpgradeReady"
)

// MariaDB Reasons used by API objects.
Expand All @@ -59,6 +67,17 @@ const (

// ReasonDBSync - Database sync in progress
ReasonDBSync condition.Reason = "DBSync"

// MariaDBServerUpgradeInProgressReason - a major version upgrade is running
MariaDBServerUpgradeInProgressReason condition.Reason = "UpgradeInProgress"
// MariaDBServerUpgradeBlockedReason - a major version upgrade was requested
// but cannot start because the cluster is not fully available
MariaDBServerUpgradeBlockedReason condition.Reason = "UpgradeBlocked"
// MariaDBServerUpgradeVersionMismatchReason - the cluster came back up after
// an upgrade but the running MariaDB server version does not match
// spec.targetVersion (e.g. containerImage was not bumped, or targetVersion is
// wrong)
MariaDBServerUpgradeVersionMismatchReason condition.Reason = "UpgradeVersionMismatch"
)

// MariaDB Messages used by API objects.
Expand Down Expand Up @@ -114,6 +133,24 @@ const (
MariaDBAccountFinalizersRemainMessage = "Waiting for finalizers %s to be removed before dropping username"

MariaDBAccountReadyForDeleteMessage = "MariaDBAccount ready for delete"

// MariaDBServerUpgradeReadyInitMessage - upgrade tracking not yet started
MariaDBServerUpgradeReadyInitMessage = "MariaDB server version upgrade state not yet determined"

// MariaDBServerUpgradeReadyMessage - no version upgrade pending
MariaDBServerUpgradeReadyMessage = "MariaDB server version up to date"

// MariaDBServerUpgradeInProgressMessage - upgrade underway (expects target version)
MariaDBServerUpgradeInProgressMessage = "MariaDB server version upgrade to %s in progress"

// MariaDBServerUpgradeBlockedMessage - upgrade requested but cluster not
// fully available (expects target version, ready node count, total node count)
MariaDBServerUpgradeBlockedMessage = "MariaDB server version upgrade to %s blocked: cluster not fully available (%d/%d nodes ready); resolve the offline node before upgrading"

// MariaDBServerUpgradeVersionMismatchMessage - the cluster is running a
// different MariaDB version than spec.targetVersion (expects detected
// running version, then requested target version)
MariaDBServerUpgradeVersionMismatchMessage = "MariaDB server version mismatch: cluster is running %s but spec.targetVersion is %s"
)

// GaleraBackup Condition Types used by API objects.
Expand Down
8 changes: 8 additions & 0 deletions api/v1beta1/galera_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ type GaleraSpecCore struct {
// +kubebuilder:validation:Optional
// Override, provides the ability to override the generated manifest of several child resources.
Override GaleraOverrideSpec `json:"override,omitempty"`

// +kubebuilder:validation:Optional
// TargetVersion is the MariaDB major.minor version that the cluster should
// run after an upgrade (e.g. "10.11"). When set and different from the
// version recorded in the existing data files, the operator performs a full
// cluster stop and runs mariadb-upgrade on each node before restarting.
// Leave empty when no version upgrade is in progress.
TargetVersion string `json:"targetVersion,omitempty"`
}

// GaleraOverrideSpec to override the generated manifest of several child resources
Expand Down
22 changes: 12 additions & 10 deletions api/v1beta1/mariadbdatabase_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,20 +941,22 @@ func ensureMariaDBAccount(ctx context.Context,
}
}

_, err = createOrPatchAccountAndSecret(ctx, helper, account, dbSecret, labels)
op, err := createOrPatchAccountAndSecret(ctx, helper, account, dbSecret, labels)
if err != nil {
return nil, nil, err
}

util.LogForObject(
helper,
fmt.Sprintf(
"Successfully ensured MariaDBAccount %s exists; database username is %s",
accountName,
account.Spec.UserName,
),
account,
)
if op != controllerutil.OperationResultNone {
util.LogForObject(
helper,
fmt.Sprintf(
"Successfully ensured MariaDBAccount %s exists; database username is %s",
accountName,
account.Spec.UserName,
),
account,
)
}

return account, dbSecret, nil

Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/mariadb.openstack.org_galeras.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ spec:
storageRequest:
description: Storage size allocated for the mariadb databases
type: string
targetVersion:
description: |-
TargetVersion is the MariaDB major.minor version that the cluster should
run after an upgrade (e.g. "10.11"). When set and different from the
version recorded in the existing data files, the operator performs a full
cluster stop and runs mariadb-upgrade on each node before restarting.
Leave empty when no version upgrade is in progress.
type: string
tls:
description: TLS settings for MySQL service and internal Galera replication
properties:
Expand Down
53 changes: 53 additions & 0 deletions hack/Containerfile.mariadb-10.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Test image: MariaDB 10.11 on CentOS Stream 9 kolla base
#
# Derives from the standard 10.5 kolla image to preserve all kolla scripts,
# uid/gid setup, and filesystem layout. Swaps the MariaDB packages to 10.11
# from mariadb.org community repos.
#
# This is a temporary test image for developing/validating the 10.5->10.11
# upgrade path (OSPRH-31231). The real target image will be RHEL 10 based
# and built via the production pipeline.
#
# Build:
# podman build -t quay.io/<user>/openstack-mariadb:10.11-test \
# -f hack/Containerfile.mariadb-10.11 .
#
# Verify:
# podman run --rm quay.io/<user>/openstack-mariadb:10.11-test mysqld --version
# podman run --rm quay.io/<user>/openstack-mariadb:10.11-test which mariadb-upgrade

FROM quay.io/podified-antelope-centos9/openstack-mariadb:current-podified

USER root

# Remove the CentOS 9 MariaDB 10.5 RPMs. The community MariaDB-server package
# conflicts on /usr/sbin/mysqld so these must be removed first.
RUN rpm -e --nodeps \
mariadb-server-galera \
mariadb-server \
mariadb-server-utils \
mariadb-backup \
mariadb \
mariadb-errmsg \
mariadb-common \
galera

# Add the MariaDB.org 10.11 repo and install the community packages.
# MariaDB-server, MariaDB-client, MariaDB-backup use uppercase names so there
# is no RPM naming conflict with the packages removed above.
RUN curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | \
bash -s -- --mariadb-server-version=mariadb-10.11 --skip-check-installed && \
dnf install -y \
MariaDB-server \
MariaDB-client \
MariaDB-backup \
galera-4 && \
dnf clean all && \
# RHEL packages differ from MariaDB.org community packages in two paths
# that the operator scripts and config reference. Add symlinks so this test
# image works without touching operator code. The production RHEL 10 image
# won't need these.
mkdir -p /usr/libexec && ln -s /usr/sbin/mysqld /usr/libexec/mysqld && \
mkdir -p /usr/lib64/galera && ln -s /usr/lib64/galera-4/libgalera_smm.so /usr/lib64/galera/libgalera_smm.so

USER mysql

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SO important

Loading