Skip to content

Commit

Permalink
Reduce unnecessary diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Nov 22, 2022
1 parent 854bb87 commit 1defca4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion azure/services/scalesets/scalesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ func (s *Service) buildVMSSFromSpec(ctx context.Context, vmssSpec azure.ScaleSet
Zones: to.StringSlicePtr(vmssSpec.FailureDomains),
Plan: s.generateImagePlan(ctx),
VirtualMachineScaleSetProperties: &compute.VirtualMachineScaleSetProperties{
OrchestrationMode: getOrchestrationMode(s.Scope.ScaleSetSpec().OrchestrationMode),
SinglePlacementGroup: to.BoolPtr(false),
OrchestrationMode: getOrchestrationMode(s.Scope.ScaleSetSpec().OrchestrationMode),
PlatformFaultDomainCount: to.Int32Ptr(platformFaultDomainCount),
VirtualMachineProfile: &compute.VirtualMachineScaleSetVMProfile{
OsProfile: osProfile,
Expand Down
30 changes: 15 additions & 15 deletions azure/services/scalesetvms/scalesetvms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"sigs.k8s.io/cluster-api-provider-azure/azure/scope"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms/mock_scalesetvms"
infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1"
gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock"
gomock2 "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestService_Reconcile(t *testing.T) {
vm := compute.VirtualMachineScaleSetVM{
InstanceID: to.StringPtr("0"),
}
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(vm, nil)
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(vm, nil)
s.SetVMSSVM(converters.SDKToVMSSVM(vm))
},
},
Expand All @@ -118,7 +118,7 @@ func TestService_Reconcile(t *testing.T) {
s.InstanceID().Return("0")
s.ProviderID().Return("foo")
s.ScaleSetName().Return("scaleset")
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, autorest404)
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, autorest404)
},
Err: azure.WithTransientError(errors.New("vm does not exist yet"), 30*time.Second),
CheckIsErr: true,
Expand All @@ -130,7 +130,7 @@ func TestService_Reconcile(t *testing.T) {
s.InstanceID().Return("0")
s.ProviderID().Return("foo")
s.ScaleSetName().Return("scaleset")
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, errors.New("boom"))
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, errors.New("boom"))
},
Err: errors.Wrap(errors.New("boom"), "failed getting vm"),
},
Expand Down Expand Up @@ -185,10 +185,10 @@ func TestService_Delete(t *testing.T) {
future := &infrav1.Future{
Type: infrav1.DeleteFuture,
}
m.DeleteAsync(gomockinternal.AContext(), "rg", "scaleset", "0").Return(future, nil)
m.DeleteAsync(gomock2.AContext(), "rg", "scaleset", "0").Return(future, nil)
s.SetLongRunningOperationState(future)
m.GetResultIfDone(gomockinternal.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, azure.WithTransientError(azure.NewOperationNotDoneError(future), 15*time.Second))
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
m.GetResultIfDone(gomock2.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, azure.WithTransientError(azure.NewOperationNotDoneError(future), 15*time.Second))
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
},
CheckIsErr: true,
Err: errors.Wrap(azure.WithTransientError(azure.NewOperationNotDoneError(&infrav1.Future{
Expand All @@ -206,9 +206,9 @@ func TestService_Delete(t *testing.T) {
Type: infrav1.DeleteFuture,
}
s.GetLongRunningOperationState("0", serviceName, infrav1.DeleteFuture).Return(future)
m.GetResultIfDone(gomockinternal.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, nil)
m.GetResultIfDone(gomock2.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, nil)
s.DeleteLongRunningOperationState("0", serviceName, infrav1.DeleteFuture)
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
},
},
{
Expand All @@ -219,8 +219,8 @@ func TestService_Delete(t *testing.T) {
s.ProviderID().Return("foo")
s.ScaleSetName().Return("scaleset")
s.GetLongRunningOperationState("0", serviceName, infrav1.DeleteFuture).Return(nil)
m.DeleteAsync(gomockinternal.AContext(), "rg", "scaleset", "0").Return(nil, autorest404)
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
m.DeleteAsync(gomock2.AContext(), "rg", "scaleset", "0").Return(nil, autorest404)
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
},
},
{
Expand All @@ -231,8 +231,8 @@ func TestService_Delete(t *testing.T) {
s.ProviderID().Return("foo")
s.ScaleSetName().Return("scaleset")
s.GetLongRunningOperationState("0", serviceName, infrav1.DeleteFuture).Return(nil)
m.DeleteAsync(gomockinternal.AContext(), "rg", "scaleset", "0").Return(nil, errors.New("boom"))
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
m.DeleteAsync(gomock2.AContext(), "rg", "scaleset", "0").Return(nil, errors.New("boom"))
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
},
Err: errors.Wrap(errors.New("boom"), "failed to delete vm scaleset/0"),
},
Expand All @@ -247,8 +247,8 @@ func TestService_Delete(t *testing.T) {
Type: infrav1.DeleteFuture,
}
s.GetLongRunningOperationState("0", serviceName, infrav1.DeleteFuture).Return(future)
m.GetResultIfDone(gomockinternal.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, errors.New("boom"))
m.Get(gomockinternal.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
m.GetResultIfDone(gomock2.AContext(), future).Return(compute.VirtualMachineScaleSetVM{}, errors.New("boom"))
m.Get(gomock2.AContext(), "rg", "scaleset", "0").Return(compute.VirtualMachineScaleSetVM{}, nil)
},
Err: errors.Wrap(errors.New("boom"), "failed to get result of long running operation"),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ spec:
type: array
longRunningOperationStates:
description: LongRunningOperationStates saves the state for Azure
long-running operations, so they can be continued on the next reconciliation
long-running operations so they can be continued on the next reconciliation
loop.
items:
description: Future contains the data needed for an Azure long-running
Expand Down
3 changes: 1 addition & 2 deletions exp/api/v1beta1/azuremachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const (
)

type (

// AzureMachinePoolMachineTemplate defines the template for an AzureMachine.
AzureMachinePoolMachineTemplate struct {
// VMSize is the size of the Virtual Machine to build.
Expand Down Expand Up @@ -290,7 +289,7 @@ type (
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`

// LongRunningOperationStates saves the state for Azure long-running operations, so they can be continued on the
// LongRunningOperationStates saves the state for Azure long-running operations so they can be continued on the
// next reconciliation loop.
// +optional
LongRunningOperationStates infrav1.Futures `json:"longRunningOperationStates,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion exp/controllers/azuremachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (ampr *AzureMachinePoolReconciler) reconcileNormal(ctx context.Context, mac
}

if reconcileError.IsTransient() {
log.V(4).Info("failed to reconcile AzureMachinePoolMachine", "name", machinePoolScope.Name(), "transient_error", err)
log.Error(err, "failed to reconcile AzureMachinePool", "name", machinePoolScope.Name())
return reconcile.Result{RequeueAfter: reconcileError.RequeueAfter()}, nil
}

Expand Down

0 comments on commit 1defca4

Please sign in to comment.