Skip to content

Commit 8d290e5

Browse files
committed
return warnings
1 parent 051d35a commit 8d290e5

36 files changed

Lines changed: 155 additions & 110 deletions

‎api/bases/telemetry.openstack.org_autoscalings.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ spec:
328328
e.g. to check logs
329329
type: boolean
330330
rabbitMqClusterName:
331-
default: rabbitmq
332331
description: |-
333332
RabbitMQ instance name
334333
Needed to request a transportURL that is created and used in Aodh

‎api/bases/telemetry.openstack.org_cloudkitties.yaml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,6 @@ spec:
808808
type: string
809809
description: Map of hashes to track e.g. job status
810810
type: object
811-
notificationsURLSecret:
812-
description: NotificationsURLSecret - Secret containing RabbitMQ notification
813-
transportURL
814-
type: string
815811
observedGeneration:
816812
description: |-
817813
ObservedGeneration - the most recent generation observed for this service.

‎api/bases/telemetry.openstack.org_telemetries.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ spec:
331331
finished e.g. to check logs
332332
type: boolean
333333
rabbitMqClusterName:
334-
default: rabbitmq
335334
description: |-
336335
RabbitMQ instance name
337336
Needed to request a transportURL that is created and used in Aodh

‎api/v1beta1/autoscaling_types.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ type AodhCore struct {
7171
// RabbitMQ instance name
7272
// Needed to request a transportURL that is created and used in Aodh
7373
// Deprecated: Use NotificationsBus.Cluster instead
74-
// +kubebuilder:default=rabbitmq
7574
RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"`
7675

7776
// +kubebuilder:validation:Required

‎api/v1beta1/autoscaling_webhook.go‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ func (spec *AutoscalingSpec) Default() {
7777
// Default - note only *Core* versions like this will have validations that are called from the
7878
// Controlplane webhook
7979
func (spec *AodhCore) Default() {
80-
// Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty
80+
// NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured
8181
// Migration from deprecated fields is handled by openstack-operator
82-
if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" {
83-
spec.NotificationsBus.Cluster = "rabbitmq"
84-
}
82+
// This ensures users make a conscious choice about which cluster to use for notifications
8583

8684
if spec.MemcachedInstance == "" {
8785
spec.MemcachedInstance = "memcached"
@@ -167,19 +165,22 @@ func (r *Autoscaling) ValidateCreate() (admission.Warnings, error) {
167165
autoscalinglog.Info("validate create", "name", r.Name)
168166

169167
var allErrs field.ErrorList
168+
var allWarns []string
170169
basePath := field.NewPath("spec")
171170

172-
if err := r.Spec.Aodh.ValidateCreate(basePath.Child("aodh"), r.Namespace); err != nil {
171+
warns, err := r.Spec.Aodh.ValidateCreate(basePath.Child("aodh"), r.Namespace)
172+
allWarns = append(allWarns, warns...)
173+
if err != nil {
173174
allErrs = append(allErrs, err...)
174175
}
175176

176177
if len(allErrs) != 0 {
177-
return nil, apierrors.NewInvalid(
178+
return allWarns, apierrors.NewInvalid(
178179
schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"},
179180
r.Name, allErrs)
180181
}
181182

182-
return nil, nil
183+
return allWarns, nil
183184
}
184185

185186
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
@@ -192,19 +193,22 @@ func (r *Autoscaling) ValidateUpdate(old runtime.Object) (admission.Warnings, er
192193
}
193194

194195
var allErrs field.ErrorList
196+
var allWarns []string
195197
basePath := field.NewPath("spec")
196198

197-
if err := r.Spec.Aodh.ValidateUpdate(oldAutoscaling.Spec.Aodh.AodhCore, basePath.Child("aodh"), r.Namespace); err != nil {
199+
warns, err := r.Spec.Aodh.ValidateUpdate(oldAutoscaling.Spec.Aodh.AodhCore, basePath.Child("aodh"), r.Namespace)
200+
allWarns = append(allWarns, warns...)
201+
if err != nil {
198202
allErrs = append(allErrs, err...)
199203
}
200204

201205
if len(allErrs) != 0 {
202-
return nil, apierrors.NewInvalid(
206+
return allWarns, apierrors.NewInvalid(
203207
schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"},
204208
r.Name, allErrs)
205209
}
206210

207-
return nil, nil
211+
return allWarns, nil
208212
}
209213

210214
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
@@ -216,28 +220,32 @@ func (r *Autoscaling) ValidateDelete() (admission.Warnings, error) {
216220

217221
// ValidateCreate - Exported function wrapping non-exported validate functions,
218222
// this function can be called externally to validate an aodh spec.
219-
func (spec *AodhCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
223+
func (spec *AodhCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) {
220224
var allErrs field.ErrorList
225+
var allWarns []string
221226

222227
// Validate deprecated fields using shared helper
223-
_, errs := spec.validateDeprecatedFieldsCreate(basePath)
228+
warns, errs := spec.validateDeprecatedFieldsCreate(basePath)
229+
allWarns = append(allWarns, warns...)
224230
allErrs = append(allErrs, errs...)
225231

226232
allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...)
227233

228-
return allErrs
234+
return allWarns, allErrs
229235
}
230236

231237
// ValidateUpdate - Exported function wrapping non-exported validate functions,
232238
// this function can be called externally to validate an aodh spec.
233-
func (spec *AodhCore) ValidateUpdate(old AodhCore, basePath *field.Path, namespace string) field.ErrorList {
239+
func (spec *AodhCore) ValidateUpdate(old AodhCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) {
234240
var allErrs field.ErrorList
241+
var allWarns []string
235242

236243
// Validate deprecated fields using shared helper
237-
_, errs := spec.validateDeprecatedFieldsUpdate(old, basePath)
244+
warns, errs := spec.validateDeprecatedFieldsUpdate(old, basePath)
245+
allWarns = append(allWarns, warns...)
238246
allErrs = append(allErrs, errs...)
239247

240248
allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...)
241249

242-
return allErrs
250+
return allWarns, allErrs
243251
}

‎api/v1beta1/ceilometer_webhook.go‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,9 @@ func (spec *CeilometerSpec) Default() {
9191

9292
// Default - set defaults for this CeilometerSpecCore. NOTE: this version is used by the OpenStackControlplane webhook
9393
func (spec *CeilometerSpecCore) Default() {
94-
// Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty
94+
// NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured
9595
// Migration from deprecated fields is handled by openstack-operator
96-
if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" {
97-
spec.NotificationsBus.Cluster = "rabbitmq"
98-
}
96+
// This ensures users make a conscious choice about which cluster to use for notifications
9997
}
10098

10199
// getDeprecatedFields returns the centralized list of deprecated fields for CeilometerSpecCore
@@ -150,19 +148,22 @@ func (r *Ceilometer) ValidateCreate() (admission.Warnings, error) {
150148
ceilometerlog.Info("validate create", "name", r.Name)
151149

152150
var allErrs field.ErrorList
151+
var allWarns []string
153152
basePath := field.NewPath("spec")
154153

155-
if err := r.Spec.CeilometerSpecCore.ValidateCreate(basePath, r.Namespace); err != nil {
154+
warns, err := r.Spec.CeilometerSpecCore.ValidateCreate(basePath, r.Namespace)
155+
allWarns = append(allWarns, warns...)
156+
if err != nil {
156157
allErrs = append(allErrs, err...)
157158
}
158159

159160
if len(allErrs) != 0 {
160-
return nil, apierrors.NewInvalid(
161+
return allWarns, apierrors.NewInvalid(
161162
schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"},
162163
r.Name, allErrs)
163164
}
164165

165-
return nil, nil
166+
return allWarns, nil
166167
}
167168

168169
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
@@ -175,19 +176,22 @@ func (r *Ceilometer) ValidateUpdate(old runtime.Object) (admission.Warnings, err
175176
}
176177

177178
var allErrs field.ErrorList
179+
var allWarns []string
178180
basePath := field.NewPath("spec")
179181

180-
if err := r.Spec.CeilometerSpecCore.ValidateUpdate(oldCeilometer.Spec.CeilometerSpecCore, basePath, r.Namespace); err != nil {
182+
warns, err := r.Spec.CeilometerSpecCore.ValidateUpdate(oldCeilometer.Spec.CeilometerSpecCore, basePath, r.Namespace)
183+
allWarns = append(allWarns, warns...)
184+
if err != nil {
181185
allErrs = append(allErrs, err...)
182186
}
183187

184188
if len(allErrs) != 0 {
185-
return nil, apierrors.NewInvalid(
189+
return allWarns, apierrors.NewInvalid(
186190
schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"},
187191
r.Name, allErrs)
188192
}
189193

190-
return nil, nil
194+
return allWarns, nil
191195
}
192196

193197
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
@@ -199,28 +203,32 @@ func (r *Ceilometer) ValidateDelete() (admission.Warnings, error) {
199203

200204
// ValidateCreate - Exported function wrapping non-exported validate functions,
201205
// this function can be called externally to validate a ceilometer spec.
202-
func (spec *CeilometerSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
206+
func (spec *CeilometerSpecCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) {
203207
var allErrs field.ErrorList
208+
var allWarns []string
204209

205210
// Validate deprecated fields using shared helper
206-
_, errs := spec.validateDeprecatedFieldsCreate(basePath)
211+
warns, errs := spec.validateDeprecatedFieldsCreate(basePath)
212+
allWarns = append(allWarns, warns...)
207213
allErrs = append(allErrs, errs...)
208214

209215
allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...)
210216

211-
return allErrs
217+
return allWarns, allErrs
212218
}
213219

214220
// ValidateUpdate - Exported function wrapping non-exported validate functions,
215221
// this function can be called externally to validate a ceilometer spec.
216-
func (spec *CeilometerSpecCore) ValidateUpdate(old CeilometerSpecCore, basePath *field.Path, namespace string) field.ErrorList {
222+
func (spec *CeilometerSpecCore) ValidateUpdate(old CeilometerSpecCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) {
217223
var allErrs field.ErrorList
224+
var allWarns []string
218225

219226
// Validate deprecated fields using shared helper
220-
_, errs := spec.validateDeprecatedFieldsUpdate(old, basePath)
227+
warns, errs := spec.validateDeprecatedFieldsUpdate(old, basePath)
228+
allWarns = append(allWarns, warns...)
221229
allErrs = append(allErrs, errs...)
222230

223231
allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...)
224232

225-
return allErrs
233+
return allWarns, allErrs
226234
}

‎api/v1beta1/cloudkitty_types.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ type CloudKittyStatus struct {
313313
// TransportURLSecret - Secret containing RabbitMQ transportURL
314314
TransportURLSecret string `json:"transportURLSecret,omitempty"`
315315

316-
// NotificationsURLSecret - Secret containing RabbitMQ notification transportURL
317-
NotificationsURLSecret *string `json:"notificationsURLSecret,omitempty"`
318-
319316
// API endpoints
320317
APIEndpoints map[string]map[string]string `json:"apiEndpoints,omitempty"`
321318

‎api/v1beta1/cloudkitty_webhook.go‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,41 +188,43 @@ func (r *ObjectStorageSpec) Validate(basePath *field.Path) field.ErrorList {
188188
func (r *CloudKitty) ValidateCreate() (admission.Warnings, error) {
189189
cloudKittyLog.Info("validate create", "name", r.Name)
190190

191-
allErrs := r.Spec.ValidateCreate(field.NewPath("spec"), r.Namespace)
191+
allWarns, allErrs := r.Spec.ValidateCreate(field.NewPath("spec"), r.Namespace)
192192

193193
if len(allErrs) != 0 {
194-
return nil, apierrors.NewInvalid(
194+
return allWarns, apierrors.NewInvalid(
195195
schema.GroupKind{Group: "cloudkitties.telemetry.openstack.org", Kind: "CloudKitty"},
196196
r.Name, allErrs)
197197
}
198198

199-
return nil, nil
199+
return allWarns, nil
200200
}
201201

202202
// ValidateCreate validates the CloudKittySpec during the webhook invocation.
203-
func (r *CloudKittySpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
203+
func (r *CloudKittySpec) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) {
204204
return r.CloudKittySpecBase.ValidateCreate(basePath, namespace)
205205
}
206206

207207
// ValidateCreate validates the CloudKittySpecCore during the webhook invocation. It is
208208
// expected to be called by the validation webhook in the higher level telemetry webhook
209-
func (r *CloudKittySpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
209+
func (r *CloudKittySpecCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) {
210210
return r.CloudKittySpecBase.ValidateCreate(basePath, namespace)
211211
}
212212

213213
// ValidateCreate validates the CloudKittySpecBase during the webhook invocation.
214-
func (r *CloudKittySpecBase) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
214+
func (r *CloudKittySpecBase) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) {
215215
var allErrs field.ErrorList
216+
var allWarns []string
216217

217218
// Validate deprecated fields using shared helper
218-
_, errs := r.validateDeprecatedFieldsCreate(basePath)
219+
warns, errs := r.validateDeprecatedFieldsCreate(basePath)
220+
allWarns = append(allWarns, warns...)
219221
allErrs = append(allErrs, errs...)
220222

221223
allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...)
222224

223225
// TODO: Add other CK spec field validations as needed
224226

225-
return allErrs
227+
return allWarns, allErrs
226228
}
227229

228230
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
@@ -234,42 +236,44 @@ func (r *CloudKitty) ValidateUpdate(old runtime.Object) (admission.Warnings, err
234236
return nil, apierrors.NewInternalError(fmt.Errorf("unable to convert existing object"))
235237
}
236238

237-
allErrs := r.Spec.ValidateUpdate(oldCloudKitty.Spec, field.NewPath("spec"), r.Namespace)
239+
allWarns, allErrs := r.Spec.ValidateUpdate(oldCloudKitty.Spec, field.NewPath("spec"), r.Namespace)
238240

239241
if len(allErrs) != 0 {
240-
return nil, apierrors.NewInvalid(
242+
return allWarns, apierrors.NewInvalid(
241243
schema.GroupKind{Group: "cloudkitties.telemetry.openstack.org", Kind: "CloudKitty"},
242244
r.Name, allErrs)
243245
}
244246

245-
return nil, nil
247+
return allWarns, nil
246248

247249
}
248250

249-
// ValidateCreate validates the CloudKittySpec during the webhook invocation.
250-
func (r *CloudKittySpec) ValidateUpdate(old CloudKittySpec, basePath *field.Path, namespace string) field.ErrorList {
251+
// ValidateUpdate validates the CloudKittySpec during the webhook invocation.
252+
func (r *CloudKittySpec) ValidateUpdate(old CloudKittySpec, basePath *field.Path, namespace string) ([]string, field.ErrorList) {
251253
return r.CloudKittySpecBase.ValidateUpdate(old.CloudKittySpecBase, basePath, namespace)
252254
}
253255

254256
// ValidateUpdate validates the CloudKittySpecCore during the webhook invocation. It is
255257
// expected to be called by the validation webhook in the higher level telemetry webhook
256-
func (r *CloudKittySpecCore) ValidateUpdate(old CloudKittySpecCore, basePath *field.Path, namespace string) field.ErrorList {
258+
func (r *CloudKittySpecCore) ValidateUpdate(old CloudKittySpecCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) {
257259
return r.CloudKittySpecBase.ValidateUpdate(old.CloudKittySpecBase, basePath, namespace)
258260
}
259261

260262
// ValidateUpdate validates the CloudKittySpecBase during the webhook invocation.
261-
func (r *CloudKittySpecBase) ValidateUpdate(old CloudKittySpecBase, basePath *field.Path, namespace string) field.ErrorList {
263+
func (r *CloudKittySpecBase) ValidateUpdate(old CloudKittySpecBase, basePath *field.Path, namespace string) ([]string, field.ErrorList) {
262264
var allErrs field.ErrorList
265+
var allWarns []string
263266

264267
// Validate deprecated fields using shared helper
265-
_, errs := r.validateDeprecatedFieldsUpdate(old, basePath)
268+
warns, errs := r.validateDeprecatedFieldsUpdate(old, basePath)
269+
allWarns = append(allWarns, warns...)
266270
allErrs = append(allErrs, errs...)
267271

268272
allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...)
269273

270274
// TODO: Add other CK spec field validations as needed
271275

272-
return allErrs
276+
return allWarns, allErrs
273277
}
274278

275279
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type

0 commit comments

Comments
 (0)