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

Validate machineset before reconciling #109

Merged
merged 1 commit into from
Jan 15, 2019
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
30 changes: 30 additions & 0 deletions 0001-Validate-machineset-before-reconciliation.patch
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

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vendor:
dep ensure -v
patch -p1 < 0001-Delete-annotated-machines-first-when-scaling-down.patch
patch -p1 < 0002-Sort-machines-before-syncing.patch
# patch -p1 < 0001-use-Update-instead-of-Status.Update-as-CustomResourc.patch
patch -p1 < 0001-Validate-machineset-before-reconciliation.patch

.PHONY: generate
generate: gendeepcopy
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.