@@ -91,6 +91,7 @@ func (r *OpenStackControlPlane) ValidateCreate() (admission.Warnings, error) {
9191 openstackcontrolplanelog .Info ("validate create" , "name" , r .Name )
9292
9393 var allErrs field.ErrorList
94+ var allWarn []string
9495 basePath := field .NewPath ("spec" )
9596
9697 ctlplaneList := & OpenStackControlPlaneList {}
@@ -124,17 +125,14 @@ func (r *OpenStackControlPlane) ValidateCreate() (admission.Warnings, error) {
124125 )
125126 }
126127
127- if err := r .ValidateCreateServices (basePath ); err != nil {
128- allErrs = append (allErrs , err ... )
129- }
130-
128+ allWarn , allErrs = r .ValidateCreateServices (basePath )
131129 if len (allErrs ) != 0 {
132- return nil , apierrors .NewInvalid (
130+ return allWarn , apierrors .NewInvalid (
133131 schema.GroupKind {Group : "core.openstack.org" , Kind : "OpenStackControlPlane" },
134132 r .Name , allErrs )
135133 }
136134
137- return nil , nil
135+ return allWarn , nil
138136}
139137
140138// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
@@ -246,8 +244,9 @@ func (r *OpenStackControlPlane) checkDepsEnabled(name string) string {
246244}
247245
248246// ValidateCreateServices validating service definitions during the OpenstackControlPlane CR creation
249- func (r * OpenStackControlPlane ) ValidateCreateServices (basePath * field.Path ) field.ErrorList {
247+ func (r * OpenStackControlPlane ) ValidateCreateServices (basePath * field.Path ) (admission. Warnings , field.ErrorList ) {
250248 var errors field.ErrorList
249+ var warnings []string
251250
252251 errors = append (errors , r .ValidateServiceDependencies (basePath )... )
253252
@@ -304,7 +303,15 @@ func (r *OpenStackControlPlane) ValidateCreateServices(basePath *field.Path) fie
304303 errors = append (errors , r .Spec .Designate .Template .ValidateCreate (basePath .Child ("designate" ).Child ("template" ))... )
305304 }
306305
307- return errors
306+ if r .Spec .Galera .Enabled {
307+ for key , s := range * r .Spec .Galera .Templates {
308+ warn , err := s .ValidateCreate (basePath .Child ("galera" ).Child ("template" ).Key (key ))
309+ errors = append (errors , err ... )
310+ warnings = append (warnings , warn ... )
311+ }
312+ }
313+
314+ return warnings , errors
308315}
309316
310317// ValidateUpdateServices validating service definitions during the OpenstackControlPlane CR update
@@ -497,7 +504,7 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
497504
498505 if depErrorMsg := r .checkDepsEnabled ("Telemetry.Ceilometer" ); depErrorMsg != "" {
499506 err := field .Invalid (basePath .Child ("telemetry" ).Child ("template" ).Child ("ceilometer" ).Child ("enabled" ),
500- * r .Spec .Telemetry .Template .Ceilometer .Enabled , depErrorMsg )
507+ * r .Spec .Telemetry .Template .Ceilometer .Enabled , depErrorMsg )
501508 allErrs = append (allErrs , err )
502509 }
503510 }
@@ -507,7 +514,7 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
507514
508515 if depErrorMsg := r .checkDepsEnabled ("Telemetry.Autoscaling" ); depErrorMsg != "" {
509516 err := field .Invalid (basePath .Child ("telemetry" ).Child ("template" ).Child ("autoscaling" ).Child ("enabled" ),
510- * r .Spec .Telemetry .Template .Autoscaling .Enabled , depErrorMsg )
517+ * r .Spec .Telemetry .Template .Autoscaling .Enabled , depErrorMsg )
511518 allErrs = append (allErrs , err )
512519 }
513520 }
0 commit comments