Skip to content

Commit 5592dfc

Browse files
Merge pull request #309 from fmount/must_parse
Do not use MustParse to process PVC size
2 parents 381cb0b + d1a9b2e commit 5592dfc

File tree

7 files changed

+20
-10
lines changed

7 files changed

+20
-10
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/onsi/ginkgo/v2 v2.20.1
88
github.com/onsi/gomega v1.34.1
99
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded
10-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91
10+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97
1111
k8s.io/api v0.29.14
1212
k8s.io/apimachinery v0.29.14
1313
k8s.io/client-go v0.29.14

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6
7878
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
7979
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded h1:09SyMAXgnohPLQGKuvBeR72nxZWXLXI7309RjmYYBUU=
8080
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
81-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91 h1:JSWODgJhcD1Q5YEwYZwtdE+ixjsjJq70AxwKgggwi3g=
82-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
81+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97 h1:3LC66vrXJzGMV/eCdvImosOEL2Cgc2KFJIm2YhfTG3w=
82+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
8383
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8484
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8585
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

api/v1beta1/galera_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ func (r *GaleraSpec) ValidateUpdate(old GaleraSpec, basePath *field.Path, namesp
172172
func (r *GaleraSpecCore) ValidateUpdate(old GaleraSpecCore, basePath *field.Path, namespace string) field.ErrorList {
173173
allErrs := field.ErrorList{}
174174

175+
_, errs := common_webhook.ValidateStorageRequest(basePath, r.StorageRequest, storageRequestProdMin, true)
176+
allErrs = append(allErrs, errs...)
175177
// When a TopologyRef CR is referenced, fail if a different Namespace is
176178
// referenced because is not supported
177179
if r.TopologyRef != nil {

controllers/galera_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,12 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
740740
instance.Status.LastAppliedTopology = nil
741741
}
742742

743-
commonstatefulset := commonstatefulset.NewStatefulSet(mariadb.StatefulSet(instance, hashOfHashes, topology), 5)
743+
stsSpec, err := mariadb.StatefulSet(instance, hashOfHashes, topology)
744+
// an error is detected while creating the StatefulSet spec
745+
if err != nil {
746+
return ctrl.Result{}, err
747+
}
748+
commonstatefulset := commonstatefulset.NewStatefulSet(stsSpec, 5)
744749
sfres, sferr := commonstatefulset.CreateOrPatch(ctx, helper)
745750
if sferr != nil {
746751
if k8s_errors.IsNotFound(sferr) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/onsi/ginkgo/v2 v2.20.1
99
github.com/onsi/gomega v1.34.1
1010
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded
11-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91
11+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97
1212
github.com/openstack-k8s-operators/mariadb-operator/api v0.0.0-00010101000000-000000000000
1313
go.uber.org/zap v1.27.0
1414
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6
8787
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
8888
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded h1:09SyMAXgnohPLQGKuvBeR72nxZWXLXI7309RjmYYBUU=
8989
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
90-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91 h1:JSWODgJhcD1Q5YEwYZwtdE+ixjsjJq70AxwKgggwi3g=
91-
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227072032-4046ee8c6a91/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
90+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97 h1:3LC66vrXJzGMV/eCdvImosOEL2Cgc2KFJIm2YhfTG3w=
91+
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250228124213-cd63da392f97/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
9292
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
9393
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9494
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

pkg/mariadb/statefulset.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// StatefulSet returns a StatefulSet object for the galera cluster
18-
func StatefulSet(g *mariadbv1.Galera, configHash string, topology *topologyv1.Topology) *appsv1.StatefulSet {
18+
func StatefulSet(g *mariadbv1.Galera, configHash string, topology *topologyv1.Topology) (*appsv1.StatefulSet, error) {
1919
ls := StatefulSetLabels(g)
2020
name := StatefulSetName(g.Name)
2121
var replicas *int32
@@ -25,7 +25,10 @@ func StatefulSet(g *mariadbv1.Galera, configHash string, topology *topologyv1.To
2525
replicas = g.Spec.Replicas
2626
}
2727
storage := g.Spec.StorageClass
28-
storageRequest := resource.MustParse(g.Spec.StorageRequest)
28+
storageRequest, err := resource.ParseQuantity(g.Spec.StorageRequest)
29+
if err != nil {
30+
return nil, err
31+
}
2932
sts := &appsv1.StatefulSet{
3033
ObjectMeta: metav1.ObjectMeta{
3134
Name: name,
@@ -87,7 +90,7 @@ func StatefulSet(g *mariadbv1.Galera, configHash string, topology *topologyv1.To
8790
corev1.LabelHostname,
8891
)
8992
}
90-
return sts
93+
return sts, nil
9194
}
9295

9396
func getGaleraInitContainers(g *mariadbv1.Galera) []corev1.Container {

0 commit comments

Comments
 (0)