Skip to content

Commit a9f3369

Browse files
zzzeekclaude
andcommitted
Propagate MariaDB TargetVersion to the Galera CR (OSPRH-32083)
Adds ServiceDefaults.MariadbVersion to OpenStackVersion and propagates it to the Galera CR's spec.targetVersion, following the pattern already used by ServiceDefaults.RabbitmqVersion for the rabbitmq-server 3.9->4.2 upgrade. Currently does not indicate a "default" version for mariadb-galera, as 10.5 is already deployed in existing deployments that dont have the "targetversion" field at all; setting it to 10.5 here would force a restart of those clusters. Once this change is running on a rhel-10 environment with mariadb 10.11 available as the mariadb image, the RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT should be added as "10.11"; when deployed on an existing cluster that runs 10.5, this will apply the new version to the galera cluster which will then do a restart and run the mariadb upgrade scripts. Doing so before a 10.11 image is present would put running clusters into a state that includes MariaDBServerUpgradeReady=False with UpgradeVersionMismatch (however those clusters would still remain in a ready state). References: OSPRH-32083 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent b499545 commit a9f3369

8 files changed

Lines changed: 134 additions & 4 deletions

File tree

‎api/bases/core.openstack.org_openstackversions.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ spec:
258258
type: string
259259
manilaSharev1:
260260
type: string
261+
mariadbVersion:
262+
type: string
261263
neutronWsgi:
262264
type: string
263265
rabbitmqVersion:
@@ -701,6 +703,8 @@ spec:
701703
type: string
702704
manilaSharev1:
703705
type: string
706+
mariadbVersion:
707+
type: string
704708
neutronWsgi:
705709
type: string
706710
rabbitmqVersion:

‎api/core/v1beta1/openstackversion_types.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,12 @@ type ContainerTemplate struct {
299299
// ServiceDefaults - struct that contains defaults for OSP services that can change over time
300300
// but are associated with a specific OpenStack release version
301301
type ServiceDefaults struct {
302-
GlanceWsgi *string `json:"glanceWsgi,omitempty"`
303-
RabbitmqVersion *string `json:"rabbitmqVersion,omitempty"`
302+
GlanceWsgi *string `json:"glanceWsgi,omitempty"`
303+
RabbitmqVersion *string `json:"rabbitmqVersion,omitempty"`
304+
MariadbVersion *string `json:"mariadbVersion,omitempty"`
304305
GlanceLocationAPI *string `json:"glanceLocationAPI,omitempty"`
305-
ManilaSharev1 *string `json:"manilaSharev1,omitempty"`
306-
NeutronWsgi *string `json:"neutronWsgi,omitempty"`
306+
ManilaSharev1 *string `json:"manilaSharev1,omitempty"`
307+
NeutronWsgi *string `json:"neutronWsgi,omitempty"`
307308
}
308309

309310
// OpenStackVersionStatus defines the observed state of OpenStackVersion

‎api/core/v1beta1/zz_generated.deepcopy.go‎

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bindata/crds/crds.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22620,6 +22620,8 @@ spec:
2262022620
type: string
2262122621
manilaSharev1:
2262222622
type: string
22623+
mariadbVersion:
22624+
type: string
2262322625
neutronWsgi:
2262422626
type: string
2262522627
rabbitmqVersion:
@@ -23063,6 +23065,8 @@ spec:
2306323065
type: string
2306423066
manilaSharev1:
2306523067
type: string
23068+
mariadbVersion:
23069+
type: string
2306623070
neutronWsgi:
2306723071
type: string
2306823072
rabbitmqVersion:

‎config/crd/bases/core.openstack.org_openstackversions.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ spec:
258258
type: string
259259
manilaSharev1:
260260
type: string
261+
mariadbVersion:
262+
type: string
261263
neutronWsgi:
262264
type: string
263265
rabbitmqVersion:
@@ -701,6 +703,8 @@ spec:
701703
type: string
702704
manilaSharev1:
703705
type: string
706+
mariadbVersion:
707+
type: string
704708
neutronWsgi:
705709
type: string
706710
rabbitmqVersion:

‎internal/openstack/galera.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ func reconcileGalera(
282282
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), galera, func() error {
283283
spec.DeepCopyInto(&galera.Spec.GaleraSpecCore)
284284
galera.Spec.ContainerImage = *version.Status.ContainerImages.MariadbImage
285+
286+
// set the target mariadb major.minor version in spec. when the deployed
287+
// OpenStack version predates this field, leave TargetVersion empty rather
288+
// than asserting the version currently running: the mariadb-operator folds
289+
// TargetVersion into the ClusterProperties hash, so writing it where it was
290+
// previously absent would trip StopRequired and stop a healthy cluster that
291+
// is not being upgraded at all.
292+
if version.Status.ServiceDefaults.MariadbVersion != nil {
293+
galera.Spec.TargetVersion = *version.Status.ServiceDefaults.MariadbVersion
294+
} else {
295+
galera.Spec.TargetVersion = ""
296+
}
285297
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), galera, helper.GetScheme())
286298
if err != nil {
287299
return err

‎internal/openstack/version.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ func InitializeOpenStackVersionServiceDefaults(ctx context.Context) *corev1beta1
243243

244244
defaults.NeutronWsgi = &trueString // enable WSGI (httpd/mod_wsgi + split neutron-rpc/neutron-worker Deployments) for neutron
245245

246+
// NOTE: MariadbVersion is deliberately left unset for now, which leaves
247+
// Galera's TargetVersion empty (see reconcileGalera()). The mariadb image
248+
// this build ships is still MariaDB 10.5, so declaring "10.11" here would
249+
// stop every existing cluster once and then leave it permanently reporting
250+
// MariaDBServerUpgradeReady=False/UpgradeVersionMismatch. Set this to
251+
// "10.11" in the same change that moves
252+
// RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT to a 10.11 image.
253+
246254
return defaults
247255
}
248256

‎test/functional/ctlplane/openstackoperator_controller_test.go‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,6 +3109,98 @@ var _ = Describe("OpenStackOperator controller", func() {
31093109
// Template-level takes precedence over top-level.
31103110
})
31113111

3112+
//
3113+
// MariaDB major version upgrade (ServiceDefaults.MariadbVersion -> Galera TargetVersion)
3114+
//
3115+
// ServiceDefaults.MariadbVersion is not defaulted yet: the mariadb image
3116+
// currently shipped is still 10.5, so nothing may be written to Galera's
3117+
// TargetVersion. The mariadb-operator folds TargetVersion into the
3118+
// ClusterProperties hash, so writing it where it was previously absent would
3119+
// trip StopRequired and stop a healthy cluster that is not being upgraded.
3120+
When("A OpenStackControlPlane is created at the current OpenStack version", func() {
3121+
BeforeEach(func() {
3122+
spec := GetDefaultOpenStackControlPlaneSpec()
3123+
spec["tls"] = GetTLSPublicSpec()
3124+
3125+
DeferCleanup(
3126+
th.DeleteInstance,
3127+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
3128+
)
3129+
})
3130+
3131+
It("leaves the Galera TargetVersion empty while MariadbVersion is undefaulted", func() {
3132+
Eventually(func(g Gomega) {
3133+
version := GetOpenStackVersion(names.OpenStackVersionName)
3134+
g.Expect(version.Status.ServiceDefaults.MariadbVersion).Should(BeNil())
3135+
3136+
g.Expect(mariadb.GetGalera(names.DBName).Spec.TargetVersion).To(Equal(""))
3137+
g.Expect(mariadb.GetGalera(names.DBCell1Name).Spec.TargetVersion).To(Equal(""))
3138+
}, timeout, interval).Should(Succeed())
3139+
})
3140+
})
3141+
3142+
// Guards the propagation itself, so that turning the default on later is a
3143+
// one-line change in InitializeOpenStackVersionServiceDefaults.
3144+
When("A OpenStackControlPlane is created at a version declaring a MariadbVersion", func() {
3145+
const mariadbVersion = "10.11"
3146+
const taggedVersion = "0.0.0"
3147+
3148+
BeforeEach(func() {
3149+
DeferCleanup(
3150+
th.DeleteInstance,
3151+
CreateOpenStackVersion(names.OpenStackVersionName, GetDefaultOpenStackVersionSpec()),
3152+
)
3153+
3154+
th.ExpectCondition(
3155+
names.OpenStackVersionName,
3156+
ConditionGetterFunc(OpenStackVersionConditionGetter),
3157+
corev1.OpenStackVersionInitialized,
3158+
k8s_corev1.ConditionTrue,
3159+
)
3160+
3161+
// record a version whose ServiceDefaults declare a MariadbVersion, as
3162+
// InitializeOpenStackVersionServiceDefaults will once a 10.11 mariadb
3163+
// image ships
3164+
Eventually(func(g Gomega) {
3165+
version := GetOpenStackVersion(names.OpenStackVersionName)
3166+
version.Status.ContainerImageVersionDefaults[taggedVersion] =
3167+
version.Status.ContainerImageVersionDefaults[version.Spec.TargetVersion]
3168+
version.Status.AvailableServiceDefaults[taggedVersion] = &corev1.ServiceDefaults{
3169+
MariadbVersion: ptr.To(mariadbVersion),
3170+
}
3171+
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
3172+
}, timeout, interval).Should(Succeed())
3173+
3174+
Eventually(func(g Gomega) {
3175+
version := GetOpenStackVersion(names.OpenStackVersionName)
3176+
version.Spec.TargetVersion = taggedVersion
3177+
g.Expect(th.K8sClient.Update(th.Ctx, version)).To(Succeed())
3178+
}, timeout, interval).Should(Succeed())
3179+
3180+
Eventually(func(g Gomega) {
3181+
version := GetOpenStackVersion(names.OpenStackVersionName)
3182+
g.Expect(version.Spec.TargetVersion).To(Equal(taggedVersion))
3183+
g.Expect(version.Status.ServiceDefaults.MariadbVersion).ShouldNot(BeNil())
3184+
g.Expect(*version.Status.ServiceDefaults.MariadbVersion).To(Equal(mariadbVersion))
3185+
}, timeout, interval).Should(Succeed())
3186+
3187+
spec := GetDefaultOpenStackControlPlaneSpec()
3188+
spec["tls"] = GetTLSPublicSpec()
3189+
3190+
DeferCleanup(
3191+
th.DeleteInstance,
3192+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
3193+
)
3194+
})
3195+
3196+
It("propagates ServiceDefaults.MariadbVersion onto the Galera CRs", func() {
3197+
Eventually(func(g Gomega) {
3198+
g.Expect(mariadb.GetGalera(names.DBName).Spec.TargetVersion).To(Equal(mariadbVersion))
3199+
g.Expect(mariadb.GetGalera(names.DBCell1Name).Spec.TargetVersion).To(Equal(mariadbVersion))
3200+
}, timeout, interval).Should(Succeed())
3201+
})
3202+
})
3203+
31123204
//
31133205
// Galera Secret field behavior tests
31143206
//

0 commit comments

Comments
 (0)