Skip to content

Commit 90d99ec

Browse files
maboehmcerealsnow
andauthored
feat: disable shoot control plane HA validation (#170)
Signed-off-by: cerealsnow <[email protected]> Co-authored-by: cerealsnow <[email protected]>
1 parent 93cbc30 commit 90d99ec

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
@@ -3339,33 +3339,11 @@ func validateHAShootControlPlaneConfigurationValue(shoot *core.Shoot) field.Erro
33393339
return allErrs
33403340
}
33413341

3342-
func validateShootHAControlPlaneSpecUpdate(newShoot, oldShoot *core.Shoot, fldPath *field.Path) field.ErrorList {
3342+
func validateShootHAControlPlaneSpecUpdate(_, _ *core.Shoot, _ *field.Path) field.ErrorList {
33433343
var (
3344-
allErrs = field.ErrorList{}
3345-
shootIsScheduled = newShoot.Spec.SeedName != nil
3346-
3347-
oldVal, newVal core.FailureToleranceType
3348-
oldValExists bool
3344+
allErrs = field.ErrorList{}
33493345
)
33503346

3351-
if oldShoot.Spec.ControlPlane != nil && oldShoot.Spec.ControlPlane.HighAvailability != nil {
3352-
oldVal = oldShoot.Spec.ControlPlane.HighAvailability.FailureTolerance.Type
3353-
oldValExists = true
3354-
}
3355-
3356-
if newShoot.Spec.ControlPlane != nil && newShoot.Spec.ControlPlane.HighAvailability != nil {
3357-
newVal = newShoot.Spec.ControlPlane.HighAvailability.FailureTolerance.Type
3358-
// 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
3359-
if !oldValExists && helper.IsShootInHibernation(newShoot) {
3360-
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"))
3361-
}
3362-
}
3363-
3364-
if oldValExists && shootIsScheduled {
3365-
// If the HighAvailability field is already set for the shoot then enforce that it cannot be changed.
3366-
allErrs = append(allErrs, apivalidation.ValidateImmutableField(newVal, oldVal, fldPath.Child("highAvailability", "failureTolerance", "type"))...)
3367-
}
3368-
33693347
return allErrs
33703348
}
33713349

pkg/apis/core/validation/shoot_test.go

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

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

0 commit comments

Comments
 (0)