From 3a553b3b38667b6bf26673f755cb393a36e068cd Mon Sep 17 00:00:00 2001 From: KsaweryZietara Date: Thu, 23 Jan 2025 15:31:27 +0100 Subject: [PATCH] Disable changing HA zones setting --- common/runtime/model.go | 6 +++--- internal/broker/instance_update.go | 2 +- internal/broker/instance_update_test.go | 8 ++++---- internal/broker/plans_schema.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/runtime/model.go b/common/runtime/model.go index ac42c0f5e9..56bf359134 100644 --- a/common/runtime/model.go +++ b/common/runtime/model.go @@ -406,11 +406,11 @@ func (a AdditionalWorkerNodePool) Validate() error { return nil } -func (a AdditionalWorkerNodePool) ValidateDisablingHAZones(currentAdditionalWorkerNodePools []AdditionalWorkerNodePool) error { +func (a AdditionalWorkerNodePool) ValidateHAZonesUnchanged(currentAdditionalWorkerNodePools []AdditionalWorkerNodePool) error { for _, currentAdditionalWorkerNodePool := range currentAdditionalWorkerNodePools { if a.Name == currentAdditionalWorkerNodePool.Name { - if !a.HAZones && currentAdditionalWorkerNodePool.HAZones { - return fmt.Errorf("HA zones cannot be disabled for %s additional worker node pool", a.Name) + if a.HAZones != currentAdditionalWorkerNodePool.HAZones { + return fmt.Errorf("HA zones setting is permanent and cannot be changed for %s additional worker node pool", a.Name) } } } diff --git a/internal/broker/instance_update.go b/internal/broker/instance_update.go index 875f08bfe4..007abea211 100644 --- a/internal/broker/instance_update.go +++ b/internal/broker/instance_update.go @@ -275,7 +275,7 @@ func (b *UpdateEndpoint) processUpdateParameters(instance *internal.Instance, de if err := additionalWorkerNodePool.Validate(); err != nil { return domain.UpdateServiceSpec{}, apiresponses.NewFailureResponse(err, http.StatusBadRequest, err.Error()) } - if err := additionalWorkerNodePool.ValidateDisablingHAZones(instance.Parameters.Parameters.AdditionalWorkerNodePools); err != nil { + if err := additionalWorkerNodePool.ValidateHAZonesUnchanged(instance.Parameters.Parameters.AdditionalWorkerNodePools); err != nil { return domain.UpdateServiceSpec{}, apiresponses.NewFailureResponse(err, http.StatusBadRequest, err.Error()) } } diff --git a/internal/broker/instance_update_test.go b/internal/broker/instance_update_test.go index 527094e368..36a92992f4 100644 --- a/internal/broker/instance_update_test.go +++ b/internal/broker/instance_update_test.go @@ -688,7 +688,7 @@ func TestUpdateAdditionalWorkerNodePools(t *testing.T) { } func TestHAZones(t *testing.T) { - t.Run("should fail when attempting to disable HA zones for additional worker node pool", func(t *testing.T) { + t.Run("should fail when attempting to disable HA zones for existing additional worker node pool", func(t *testing.T) { // given instance := fixture.FixInstance(instanceID) instance.ServicePlanID = PreviewPlanID @@ -728,10 +728,10 @@ func TestHAZones(t *testing.T) { }, true) // then - assert.EqualError(t, err, "HA zones cannot be disabled for name-1 additional worker node pool") + assert.EqualError(t, err, "HA zones setting is permanent and cannot be changed for name-1 additional worker node pool") }) - t.Run("should succeed when enabling HA zones for additional worker node pool", func(t *testing.T) { + t.Run("should fail when attempting to enable HA zones for existing additional worker node pool", func(t *testing.T) { // given instance := fixture.FixInstance(instanceID) instance.ServicePlanID = PreviewPlanID @@ -771,7 +771,7 @@ func TestHAZones(t *testing.T) { }, true) // then - assert.NoError(t, err) + assert.EqualError(t, err, "HA zones setting is permanent and cannot be changed for name-1 additional worker node pool") }) } diff --git a/internal/broker/plans_schema.go b/internal/broker/plans_schema.go index 3bcff5a781..cd2906c5b1 100644 --- a/internal/broker/plans_schema.go +++ b/internal/broker/plans_schema.go @@ -467,7 +467,7 @@ func NewAdditionalWorkerNodePoolsSchema(machineTypesDisplay map[string]string, m Type: "boolean", Title: "HA zones", Default: true, - Description: "Specifies whether high availability (HA) zones are supported. If HA is disabled, all resources are placed in a single, randomly selected zone. Disabling HA allows setting both autoScalerMin and autoScalerMax to 1, which helps reduce costs. It is not recommended for production environments. Once HA is enabled, it cannot be disabled. When enabled, resources are distributed across three zones to enhance fault tolerance. Enabling HA requires setting autoScalerMin to the minimal value 3.", + Description: "Specifies whether high availability (HA) zones are supported. This setting is permanent and cannot be changed later. If HA is disabled, all resources are placed in a single, randomly selected zone. Disabled HA allows setting both autoScalerMin and autoScalerMax to 1, which helps reduce costs. It is not recommended for production environments. When enabled, resources are distributed across three zones to enhance fault tolerance. Enabled HA requires setting autoScalerMin to the minimal value 3.", }, AutoScalerMin: Type{ Type: "integer",