Skip to content

Commit 72afeba

Browse files
authored
Merge pull request kubernetes-sigs#688 from CecileRobertMichon/cleanup
🌱 remove extra image validation in the Azure Machine controller
2 parents 5563ae1 + bdc13ed commit 72afeba

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

controllers/azuremachine_controller.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"github.com/pkg/errors"
2525
corev1 "k8s.io/api/core/v1"
2626
apierrors "k8s.io/apimachinery/pkg/api/errors"
27-
kerrors "k8s.io/apimachinery/pkg/util/errors"
28-
"k8s.io/apimachinery/pkg/util/validation/field"
2927
"k8s.io/client-go/tools/record"
3028
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha3"
3129
"sigs.k8s.io/cluster-api-provider-azure/cloud/scope"
@@ -198,17 +196,6 @@ func (r *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineSco
198196
return reconcile.Result{}, nil
199197
}
200198

201-
// Check that the image is valid
202-
// NOTE: this validation logic is also in the validating webhook
203-
if machineScope.AzureMachine.Spec.Image != nil {
204-
if errs := infrav1.ValidateImage(machineScope.AzureMachine.Spec.Image, field.NewPath("image")); len(errs) > 0 {
205-
agg := kerrors.NewAggregate(errs.ToAggregate().Errors())
206-
machineScope.Info("Invalid image: %s", agg.Error())
207-
r.Recorder.Eventf(machineScope.AzureMachine, corev1.EventTypeWarning, "InvalidImage", "Invalid image: %s", agg.Error())
208-
return reconcile.Result{}, nil
209-
}
210-
}
211-
212199
if machineScope.AzureMachine.Spec.AvailabilityZone.ID != nil {
213200
message := "AvailavilityZone is deprecated, use FailureDomain instead"
214201
machineScope.Info(message)

controllers/azuremachine_reconciler.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,16 @@ func (s *azureMachineService) getVirtualMachineZone() (string, error) {
199199

200200
func (s *azureMachineService) reconcileNetworkInterface(nicName string) error {
201201
networkInterfaceSpec := &networkinterfaces.Spec{
202-
Name: nicName,
203-
VnetName: s.clusterScope.Vnet().Name,
204-
MachineRole: s.machineScope.Role(),
202+
Name: nicName,
203+
VnetName: s.clusterScope.Vnet().Name,
204+
MachineRole: s.machineScope.Role(),
205+
AcceleratedNetworking: s.machineScope.AzureMachine.Spec.AcceleratedNetworking,
205206
}
206207

207208
if s.machineScope.AzureMachine.Spec.AllocatePublicIP == true {
208209
networkInterfaceSpec.PublicIPName = azure.GenerateNodePublicIPName(nicName)
209210
}
210211

211-
networkInterfaceSpec.AcceleratedNetworking = s.machineScope.AzureMachine.Spec.AcceleratedNetworking
212-
213212
switch role := s.machineScope.Role(); role {
214213
case infrav1.Node:
215214
networkInterfaceSpec.SubnetName = s.clusterScope.NodeSubnet().Name

exp/controllers/azuremachinepool_controller.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ import (
2525
"github.com/Azure/go-autorest/autorest/to"
2626
"github.com/go-logr/logr"
2727
"github.com/pkg/errors"
28-
corev1 "k8s.io/api/core/v1"
2928
apierrors "k8s.io/apimachinery/pkg/api/errors"
3029
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3130
"k8s.io/apimachinery/pkg/runtime"
3231
"k8s.io/apimachinery/pkg/runtime/schema"
33-
kerrors "k8s.io/apimachinery/pkg/util/errors"
34-
"k8s.io/apimachinery/pkg/util/validation/field"
3532
"k8s.io/client-go/tools/record"
3633
capiv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
3734
capierrors "sigs.k8s.io/cluster-api/errors"
@@ -214,18 +211,6 @@ func (r *AzureMachinePoolReconciler) reconcileNormal(ctx context.Context, machin
214211
return reconcile.Result{}, nil
215212
}
216213

217-
// Check that the image is valid
218-
// NOTE: this validation logic is also in the validating webhook
219-
if machinePoolScope.AzureMachinePool.Spec.Template.Image != nil {
220-
image := machinePoolScope.AzureMachinePool.Spec.Template.Image
221-
if errs := infrav1.ValidateImage(image, field.NewPath("image")); len(errs) > 0 {
222-
agg := kerrors.NewAggregate(errs.ToAggregate().Errors())
223-
machinePoolScope.Info("Invalid image: %s", agg.Error())
224-
r.Recorder.Eventf(machinePoolScope.AzureMachinePool, corev1.EventTypeWarning, "InvalidImage", "Invalid image: %s", agg.Error())
225-
return reconcile.Result{}, nil
226-
}
227-
}
228-
229214
ams := newAzureMachinePoolService(machinePoolScope, clusterScope)
230215

231216
// Get or create the virtual machine.

0 commit comments

Comments
 (0)