Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable changing HA zones setting #1671

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/runtime/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/broker/instance_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
8 changes: 4 additions & 4 deletions internal/broker/instance_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/broker/plans_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading