Skip to content

Commit 12994d1

Browse files
cerealsnowske-prow[bot]
authored andcommitted
feat: disable shoot control plane HA validation
Signed-off-by: cerealsnow <13483299+cerealsnow@users.noreply.github.com>
1 parent 8a6aba9 commit 12994d1

File tree

2 files changed

+2
-159
lines changed

2 files changed

+2
-159
lines changed

pkg/apis/core/validation/shoot.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,33 +3291,11 @@ func validateHAShootControlPlaneConfigurationValue(shoot *core.Shoot) field.Erro
32913291
return allErrs
32923292
}
32933293

3294-
func validateShootHAControlPlaneSpecUpdate(newShoot, oldShoot *core.Shoot, fldPath *field.Path) field.ErrorList {
3294+
func validateShootHAControlPlaneSpecUpdate(_, _ *core.Shoot, _ *field.Path) field.ErrorList {
32953295
var (
3296-
allErrs = field.ErrorList{}
3297-
shootIsScheduled = newShoot.Spec.SeedName != nil
3298-
3299-
oldVal, newVal core.FailureToleranceType
3300-
oldValExists bool
3296+
allErrs = field.ErrorList{}
33013297
)
33023298

3303-
if oldShoot.Spec.ControlPlane != nil && oldShoot.Spec.ControlPlane.HighAvailability != nil {
3304-
oldVal = oldShoot.Spec.ControlPlane.HighAvailability.FailureTolerance.Type
3305-
oldValExists = true
3306-
}
3307-
3308-
if newShoot.Spec.ControlPlane != nil && newShoot.Spec.ControlPlane.HighAvailability != nil {
3309-
newVal = newShoot.Spec.ControlPlane.HighAvailability.FailureTolerance.Type
3310-
// TODO(@aaronfern): remove this validation of not allowing scale-up to HA while hibernated when https://github.com/gardener/etcd-druid/issues/589 is resolved
3311-
if !oldValExists && helper.IsShootInHibernation(newShoot) {
3312-
allErrs = append(allErrs, field.Forbidden(fldPath.Child("highAvailability", "failureTolerance", "type"), "Shoot is currently hibernated and cannot be scaled up to HA. Please make sure your cluster has woken up before scaling it up to HA"))
3313-
}
3314-
}
3315-
3316-
if oldValExists && shootIsScheduled {
3317-
// If the HighAvailability field is already set for the shoot then enforce that it cannot be changed.
3318-
allErrs = append(allErrs, apivalidation.ValidateImmutableField(newVal, oldVal, fldPath.Child("highAvailability", "failureTolerance", "type"))...)
3319-
}
3320-
33213299
return allErrs
33223300
}
33233301

pkg/apis/core/validation/shoot_test.go

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -352,141 +352,6 @@ var _ = Describe("Shoot Validation Tests", func() {
352352
))
353353
})
354354

355-
Context("#ValidateShootHAControlPlaneUpdate", func() {
356-
It("should pass as Shoot ControlPlane Spec with HA set to zone has not changed", func() {
357-
shoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
358-
newShoot := prepareShootForUpdate(shoot)
359-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
360-
Expect(errorList).To(BeEmpty())
361-
})
362-
363-
It("should pass as non-HA Shoot ControlPlane Spec has not changed", func() {
364-
newShoot := prepareShootForUpdate(shoot)
365-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
366-
Expect(errorList).To(BeEmpty())
367-
})
368-
369-
It("should allow upgrading from non-HA to HA Shoot ControlPlane.HighAvailability Spec", func() {
370-
shoot.Spec.ControlPlane = &core.ControlPlane{}
371-
newShoot := prepareShootForUpdate(shoot)
372-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
373-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
374-
Expect(errorList).To(BeEmpty())
375-
})
376-
377-
Context("shoot is scheduled", func() {
378-
BeforeEach(func() {
379-
shoot.Spec.SeedName = ptr.To("someSeed")
380-
})
381-
382-
It("should forbid to change the Shoot ControlPlane spec", func() {
383-
shoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
384-
newShoot := prepareShootForUpdate(shoot)
385-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeNode}}}
386-
387-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
388-
Expect(errorList).To(ConsistOf(
389-
PointTo(MatchFields(IgnoreExtras, Fields{
390-
"Type": Equal(field.ErrorTypeInvalid),
391-
"BadValue": Equal(core.FailureToleranceTypeNode),
392-
"Field": Equal("spec.controlPlane.highAvailability.failureTolerance.type"),
393-
})),
394-
))
395-
})
396-
397-
It("should forbid to unset of Shoot ControlPlane", func() {
398-
shoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
399-
newShoot := prepareShootForUpdate(shoot)
400-
newShoot.Spec.ControlPlane = nil
401-
402-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
403-
404-
Expect(errorList).To(ConsistOf(
405-
PointTo(MatchFields(IgnoreExtras, Fields{
406-
"Type": Equal(field.ErrorTypeInvalid),
407-
"Field": Equal("spec.controlPlane.highAvailability.failureTolerance.type"),
408-
})),
409-
))
410-
})
411-
})
412-
413-
Context("shoot is not scheduled", func() {
414-
It("should allow to change the Shoot ControlPlane spec", func() {
415-
shoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
416-
newShoot := prepareShootForUpdate(shoot)
417-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeNode}}}
418-
419-
Expect(ValidateShootHAConfigUpdate(newShoot, shoot)).To(BeEmpty())
420-
})
421-
422-
It("should allow to unset of Shoot ControlPlane", func() {
423-
shoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
424-
newShoot := prepareShootForUpdate(shoot)
425-
newShoot.Spec.ControlPlane = nil
426-
427-
Expect(ValidateShootHAConfigUpdate(newShoot, shoot)).To(BeEmpty())
428-
})
429-
})
430-
431-
Context("shoot is hibernated", func() {
432-
It("should not allow upgrading from non-HA to HA when Spec.Hibernation.Enabled is set to `true`", func() {
433-
shoot.Spec.ControlPlane = &core.ControlPlane{}
434-
newShoot := prepareShootForUpdate(shoot)
435-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeZone}}}
436-
newShoot.Spec.Hibernation = &core.Hibernation{Enabled: ptr.To(true)}
437-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
438-
Expect(errorList).To(ConsistOf(
439-
PointTo(MatchFields(IgnoreExtras, Fields{
440-
"Type": Equal(field.ErrorTypeForbidden),
441-
"Field": Equal("spec.controlPlane.highAvailability.failureTolerance.type"),
442-
"Detail": Equal("Shoot is currently hibernated and cannot be scaled up to HA. Please make sure your cluster has woken up before scaling it up to HA"),
443-
})),
444-
))
445-
})
446-
447-
It("should not allow upgrading from non-HA to HA when Status.IsHibernation is set to `true`", func() {
448-
shoot.Spec.ControlPlane = &core.ControlPlane{}
449-
newShoot := prepareShootForUpdate(shoot)
450-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeNode}}}
451-
newShoot.Status.IsHibernated = true
452-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
453-
Expect(errorList).To(ConsistOf(
454-
PointTo(MatchFields(IgnoreExtras, Fields{
455-
"Type": Equal(field.ErrorTypeForbidden),
456-
"Field": Equal("spec.controlPlane.highAvailability.failureTolerance.type"),
457-
"Detail": Equal("Shoot is currently hibernated and cannot be scaled up to HA. Please make sure your cluster has woken up before scaling it up to HA"),
458-
})),
459-
))
460-
})
461-
462-
It("should not allow upgrading from non-HA to HA when Spec.Hibernation.Enabled is set to `false` and Status.IsHibernation is set to `true`", func() {
463-
shoot.Spec.ControlPlane = &core.ControlPlane{}
464-
newShoot := prepareShootForUpdate(shoot)
465-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeNode}}}
466-
newShoot.Spec.Hibernation = &core.Hibernation{Enabled: ptr.To(false)}
467-
newShoot.Status.IsHibernated = true
468-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
469-
Expect(errorList).To(ConsistOf(
470-
PointTo(MatchFields(IgnoreExtras, Fields{
471-
"Type": Equal(field.ErrorTypeForbidden),
472-
"Field": Equal("spec.controlPlane.highAvailability.failureTolerance.type"),
473-
"Detail": Equal("Shoot is currently hibernated and cannot be scaled up to HA. Please make sure your cluster has woken up before scaling it up to HA"),
474-
})),
475-
))
476-
})
477-
478-
It("should allow upgrading from non-HA to HA when Spec.Hibernation.Enabled is set to `false` and Status.IsHibernation is set to `false`", func() {
479-
shoot.Spec.ControlPlane = &core.ControlPlane{}
480-
newShoot := prepareShootForUpdate(shoot)
481-
newShoot.Spec.ControlPlane = &core.ControlPlane{HighAvailability: &core.HighAvailability{FailureTolerance: core.FailureTolerance{Type: core.FailureToleranceTypeNode}}}
482-
newShoot.Spec.Hibernation = &core.Hibernation{Enabled: ptr.To(false)}
483-
newShoot.Status.IsHibernated = false
484-
errorList := ValidateShootHAConfigUpdate(newShoot, shoot)
485-
Expect(errorList).To(BeEmpty())
486-
})
487-
})
488-
})
489-
490355
Context("#ValidateShootHAConfig", func() {
491356
It("should forbid to set unsupported failure tolerance type", func() {
492357
shoot.Spec.ControlPlane = &core.ControlPlane{}

0 commit comments

Comments
 (0)