forked from kubernetes-sigs/cluster-api-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate machineset before reconciling
Even thought the MachineSet type implements Validate() function, it's not called by default. The validation function is responsible for making sure every machine set matchLabels selector is matched with machine template labels. Given the validation is not performed by default, it is possible to create an invalid machineset that causes the machineset controller to start creating machine object one by one without any upper bound. Causing the machine controller to launch as many instances as there is machine objects.
- Loading branch information
1 parent
e90429a
commit cb8be7b
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 3200e454110d91955ab849c75db5ee60085c8991 Mon Sep 17 00:00:00 2001 | ||
From: Jan Chaloupka <[email protected]> | ||
Date: Fri, 11 Jan 2019 12:31:06 +0100 | ||
Subject: [PATCH] Validate machineset before reconciliation | ||
|
||
--- | ||
.../cluster-api/pkg/controller/machineset/controller.go | 7 +++++++ | ||
1 file changed, 7 insertions(+) | ||
|
||
diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go | ||
index a1d3923..cb537bd 100644 | ||
--- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go | ||
+++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go | ||
@@ -150,6 +150,13 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re | ||
} | ||
|
||
klog.V(4).Infof("Reconcile machineset %v", machineSet.Name) | ||
+ | ||
+ if errList := machineSet.Validate(); len(errList) > 0 { | ||
+ err := fmt.Errorf("%q machineset validation failed: %v", machineSet.Name, errList.ToAggregate().Error()) | ||
+ klog.Error(err) | ||
+ return reconcile.Result{}, err | ||
+ } | ||
+ | ||
allMachines := &clusterv1alpha1.MachineList{} | ||
|
||
err = r.Client.List(context.Background(), client.InNamespace(machineSet.Namespace), allMachines) | ||
-- | ||
2.7.5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.