Revert "now recreates the gateway vmss if there is a change in the probe (#2784)"

This reverts commit cbbe620b82.
This commit is contained in:
Jeremy Facchetti 2023-03-22 10:30:56 +01:00 коммит произвёл Caden Marchese
Родитель 3bace9f042
Коммит 5b0ad2b653
5 изменённых файлов: 10 добавлений и 85 удалений

Просмотреть файл

@ -158,24 +158,16 @@ func (d *deployer) deploy(ctx context.Context, rgName, deploymentName, vmssName
for i := 0; i < 3; i++ {
d.log.Printf("deploying %s", deploymentName)
err = d.deployments.CreateOrUpdateAndWait(ctx, rgName, deploymentName, deployment)
serviceErr, isServiceError := err.(*azure.ServiceError)
if isServiceError {
if serviceErr.Code == "DeploymentFailed" &&
i < 1 {
// on new RP deployments, we get a spurious DeploymentFailed error
// from the Microsoft.Insights/metricAlerts resources indicating
// that rp-lb can't be found, even though it exists and the
// resources correctly have a dependsOn stanza referring to it.
// Retry once.
d.log.Print(err)
continue
}
if serviceErr.Code == "CannotModifyProbeUsedByVMSS" {
// removes the probe reference so we can update the lb rules
if retry := d.vmssCleaner.UpdateVMSSProbes(ctx, rgName); retry {
continue
}
}
if serviceErr, ok := err.(*azure.ServiceError); ok &&
serviceErr.Code == "DeploymentFailed" &&
i < 1 {
// on new RP deployments, we get a spurious DeploymentFailed error
// from the Microsoft.Insights/metricAlerts resources indicating
// that rp-lb can't be found, even though it exists and the
// resources correctly have a dependsOn stanza referring to it.
// Retry once.
d.log.Print(err)
continue
}
if err != nil && *d.config.Configuration.VMSSCleanupEnabled {
if retry := d.vmssCleaner.RemoveFailedNewScaleset(ctx, rgName, vmssName); retry {

Просмотреть файл

@ -5,7 +5,6 @@ package vmsscleaner
import (
"context"
"strings"
"github.com/sirupsen/logrus"
@ -14,7 +13,6 @@ import (
type Interface interface {
RemoveFailedNewScaleset(ctx context.Context, rgName, vmssToDelete string) (retry bool)
UpdateVMSSProbes(ctx context.Context, rgName string) (retry bool)
}
type cleaner struct {
@ -64,30 +62,3 @@ func (c *cleaner) RemoveFailedNewScaleset(ctx context.Context, rgName, vmssToDel
// If it was not returned from List, assume it does not exist and that deployment can be retried.
return true
}
// UpdateVMSSProbes attempts to remove the probes references so we can update the load balancer rules
func (c *cleaner) UpdateVMSSProbes(ctx context.Context, rgName string) (retry bool) {
scalesets, err := c.vmss.List(ctx, rgName)
if err != nil {
c.log.Warn(err)
return false
}
for _, vmss := range scalesets {
name := *vmss.Name
if !strings.HasPrefix(name, "gateway-vmss-") {
continue
}
//removes the network profile healthprobe
vmss.VirtualMachineProfile.NetworkProfile.HealthProbe = nil
c.log.Printf("removing the probe reference from the vmss %s", name)
err = c.vmss.CreateOrUpdateAndWait(ctx, rgName, name, vmss)
if err != nil {
c.log.Warn(err)
return false // If update failed, gateway vmss still exists. Don't retry.
}
}
// no scaleset matched, so we should not retry and return the error
return false
}

Просмотреть файл

@ -12,7 +12,6 @@ import (
type VirtualMachineScaleSetsClientAddons interface {
List(ctx context.Context, resourceGroupName string) ([]mgmtcompute.VirtualMachineScaleSet, error)
DeleteAndWait(ctx context.Context, resourceGroupName, vmScaleSetName string) error
CreateOrUpdateAndWait(ctx context.Context, resourceGroupName, vmScaleSetName string, parameters mgmtcompute.VirtualMachineScaleSet) error
}
func (c *virtualMachineScaleSetsClient) DeleteAndWait(ctx context.Context, resourceGroupName string, vmScaleSetName string) error {
@ -24,15 +23,6 @@ func (c *virtualMachineScaleSetsClient) DeleteAndWait(ctx context.Context, resou
return future.WaitForCompletionRef(ctx, c.VirtualMachineScaleSetsClient.Client)
}
func (c *virtualMachineScaleSetsClient) CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, vmScaleSetName string, parameters mgmtcompute.VirtualMachineScaleSet) error {
future, err := c.VirtualMachineScaleSetsClient.CreateOrUpdate(ctx, resourceGroupName, vmScaleSetName, parameters)
if err != nil {
return err
}
return future.WaitForCompletionRef(ctx, c.VirtualMachineScaleSetsClient.Client)
}
func (c *virtualMachineScaleSetsClient) List(ctx context.Context, resourceGroupName string) ([]mgmtcompute.VirtualMachineScaleSet, error) {
var scaleSets []mgmtcompute.VirtualMachineScaleSet
result, err := c.VirtualMachineScaleSetsClient.List(ctx, resourceGroupName)

Просмотреть файл

@ -353,20 +353,6 @@ func (m *MockVirtualMachineScaleSetsClient) EXPECT() *MockVirtualMachineScaleSet
return m.recorder
}
// CreateOrUpdateAndWait mocks base method.
func (m *MockVirtualMachineScaleSetsClient) CreateOrUpdateAndWait(arg0 context.Context, arg1, arg2 string, arg3 compute.VirtualMachineScaleSet) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateOrUpdateAndWait", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
// CreateOrUpdateAndWait indicates an expected call of CreateOrUpdateAndWait.
func (mr *MockVirtualMachineScaleSetsClientMockRecorder) CreateOrUpdateAndWait(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateAndWait", reflect.TypeOf((*MockVirtualMachineScaleSetsClient)(nil).CreateOrUpdateAndWait), arg0, arg1, arg2, arg3)
}
// DeleteAndWait mocks base method.
func (m *MockVirtualMachineScaleSetsClient) DeleteAndWait(arg0 context.Context, arg1, arg2 string) error {
m.ctrl.T.Helper()

Просмотреть файл

@ -47,17 +47,3 @@ func (mr *MockInterfaceMockRecorder) RemoveFailedNewScaleset(arg0, arg1, arg2 in
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveFailedNewScaleset", reflect.TypeOf((*MockInterface)(nil).RemoveFailedNewScaleset), arg0, arg1, arg2)
}
// UpdateVMSSProbes mocks base method.
func (m *MockInterface) UpdateVMSSProbes(arg0 context.Context, arg1 string) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateVMSSProbes", arg0, arg1)
ret0, _ := ret[0].(bool)
return ret0
}
// UpdateVMSSProbes indicates an expected call of UpdateVMSSProbes.
func (mr *MockInterfaceMockRecorder) UpdateVMSSProbes(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateVMSSProbes", reflect.TypeOf((*MockInterface)(nil).UpdateVMSSProbes), arg0, arg1)
}