From dce81695e0a0be450b648102795c7a79b682be4c Mon Sep 17 00:00:00 2001 From: Enxebre Date: Tue, 17 Sep 2019 12:30:00 +0200 Subject: [PATCH] UPSTREAM: : openshift: Revendor to bring https://github.com/openshift/cluster-api/pull/72 --- Gopkg.lock | 6 +-- .../github.com/openshift/cluster-api/Makefile | 4 ++ .../openshift/cluster-api/hack/goimports.sh | 29 ++++++++++++++ .../pkg/controller/machine/controller.go | 39 +------------------ 4 files changed, 36 insertions(+), 42 deletions(-) create mode 100755 vendor/github.com/openshift/cluster-api/hack/goimports.sh diff --git a/Gopkg.lock b/Gopkg.lock index d2b3d168459..e4a84469988 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -379,7 +379,7 @@ [[projects]] branch = "openshift-4.2-cluster-api-0.1.0" - digest = "1:31312627ff61477fbb4ef78d381bb5cec9ccca4d8731f1f2e17bffa84425d4c3" + digest = "1:3981936e2b498f98977288a69942aded35aec7465b3dd87c301d8a25466e9910" name = "github.com/openshift/cluster-api" packages = [ "pkg/apis", @@ -401,7 +401,7 @@ "pkg/util", ] pruneopts = "T" - revision = "072f7d777dc81aac0dd222686e1516dd9e7db38b" + revision = "655e2d6ccdd5774442da004081f933cd8f1f3273" [[projects]] digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" @@ -1257,9 +1257,7 @@ "k8s.io/client-go/kubernetes", "k8s.io/client-go/kubernetes/scheme", "k8s.io/client-go/plugin/pkg/client/auth/gcp", - "k8s.io/client-go/rest", "k8s.io/client-go/tools/clientcmd", - "k8s.io/client-go/tools/clientcmd/api", "k8s.io/client-go/tools/record", "k8s.io/client-go/util/cert", "k8s.io/cluster-bootstrap/token/util", diff --git a/vendor/github.com/openshift/cluster-api/Makefile b/vendor/github.com/openshift/cluster-api/Makefile index 73eb4450ec8..60c850fc3af 100644 --- a/vendor/github.com/openshift/cluster-api/Makefile +++ b/vendor/github.com/openshift/cluster-api/Makefile @@ -72,6 +72,10 @@ manifests: ## Generate manifests e.g. CRD, RBAC etc. fmt: ## Run go fmt against code go fmt ./pkg/... ./cmd/... +.PHONY: goimports +goimports: ## Go fmt your code + hack/goimports.sh . + .PHONY: vet vet: ## Run go vet against code go vet ./pkg/... ./cmd/... diff --git a/vendor/github.com/openshift/cluster-api/hack/goimports.sh b/vendor/github.com/openshift/cluster-api/hack/goimports.sh new file mode 100755 index 00000000000..1c1573291fc --- /dev/null +++ b/vendor/github.com/openshift/cluster-api/hack/goimports.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +REPO_NAME=$(basename "${PWD}") +if [ "$IS_CONTAINER" != "" ]; then + for TARGET in "${@}"; do + find "${TARGET}" -name '*.go' ! -path '*/vendor/*' ! -path '*/.build/*' -exec goimports -w {} \+ + done + git diff --exit-code +else + docker run -it --rm \ + --env IS_CONTAINER=TRUE \ + --volume "${PWD}:/go/src/sigs.k8s.io/${REPO_NAME}:z" \ + --workdir "/go/src/sigs.k8s.io/${REPO_NAME}" \ + openshift/origin-release:golang-1.12 \ + ./hack/goimports.sh "${@}" +fi diff --git a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go index 6b54f552d5b..3a6214566ce 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go +++ b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go @@ -19,7 +19,6 @@ package machine import ( "context" "fmt" - "os" "time" "github.com/go-log/log/info" @@ -78,14 +77,8 @@ func newReconciler(mgr manager.Manager, actuator Actuator) reconcile.Reconciler eventRecorder: mgr.GetEventRecorderFor("machine-controller"), config: mgr.GetConfig(), scheme: mgr.GetScheme(), - nodeName: os.Getenv(NodeNameEnvVar), actuator: actuator, } - - if r.nodeName == "" { - klog.Warningf("Environment variable %q is not set, this controller will not protect against deleting its own machine", NodeNameEnvVar) - } - return r } @@ -113,9 +106,6 @@ type ReconcileMachine struct { eventRecorder record.EventRecorder actuator Actuator - - // nodeName is the name of the node on which the machine controller is running, if not present, it is loaded from NODE_NAME. - nodeName string } // Reconcile reads that state of the cluster for a Machine object and makes changes based on the state read @@ -199,13 +189,7 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul return reconcile.Result{}, nil } - if !r.isDeleteAllowed(m) { - klog.Infof("Deleting machine hosting this controller is not allowed. Skipping reconciliation of machine %q", name) - return reconcile.Result{}, nil - } - klog.Infof("Reconciling machine %q triggers delete", name) - // Drain node before deletion // If a machine is not linked to a node, just delete the machine. Since a node // can be unlinked from a machine when the node goes NotReady and is removed @@ -225,7 +209,7 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul // after an instance was created. So only a small window is left when // we can loose instances, e.g. right after request to create one // was sent and before a list of node addresses was set. - if len(m.Status.Addresses) > 0 || !isInvalidMachineConfigurationError(err) { + if len(m.Status.Addresses) > 0 || !isInvalidMachineConfigurationError(err) { klog.Errorf("Failed to delete machine %q: %v", name, err) return delayIfRequeueAfterError(err) } @@ -334,27 +318,6 @@ func (r *ReconcileMachine) getCluster(ctx context.Context, machine *machinev1.Ma return cluster, nil } -func (r *ReconcileMachine) isDeleteAllowed(machine *machinev1.Machine) bool { - if r.nodeName == "" || machine.Status.NodeRef == nil { - return true - } - - if machine.Status.NodeRef.Name != r.nodeName { - return true - } - - node := &corev1.Node{} - if err := r.Client.Get(context.Background(), client.ObjectKey{Name: r.nodeName}, node); err != nil { - klog.Infof("Failed to determine if controller's node %q is associated with machine %q: %v", r.nodeName, machine.Name, err) - return true - } - - // When the UID of the machine's node reference and this controller's actual node match then then the request is to - // delete the machine this machine-controller is running on. Return false to not allow machine controller to delete its - // own machine. - return node.UID != machine.Status.NodeRef.UID -} - func (r *ReconcileMachine) deleteNode(ctx context.Context, name string) error { var node corev1.Node if err := r.Client.Get(ctx, client.ObjectKey{Name: name}, &node); err != nil {