From 3d1345084608a66e8d1fdb514979b50c8a62e276 Mon Sep 17 00:00:00 2001 From: dlorenc Date: Wed, 27 Dec 2017 20:57:44 -0800 Subject: [PATCH] Make rbac creation idempotent. Also cleanup the etcd data dir in jenkins. --- hack/jenkins/common.sh | 3 --- hack/jenkins/linux_integration_tests_none.sh | 6 ++++++ pkg/minikube/bootstrapper/kubeadm/util.go | 12 ++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 852d836417..4f232bb784 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -67,9 +67,6 @@ hdiutil info \ # Clean up xhyve processes pgrep xhyve | xargs kill || true -# kubeadm cleanup -sudo kubeadm reset || true - # Set the executable bit on the e2e binary and out binary chmod +x out/e2e-${OS_ARCH} chmod +x out/minikube-${OS_ARCH} diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index 525adda22b..d98ebf4d76 100644 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -34,5 +34,11 @@ EXTRA_ARGS="--bootstrapper=kubeadm" SUDO_PREFIX="sudo -E " export KUBECONFIG="/root/.kube/config" +# "none" driver specific cleanup from previous runs. +# kubeadm +sudo kubeadm reset || true +# Cleanup data directory +sudo rm -rf /data/* + # Download files and set permissions source common.sh diff --git a/pkg/minikube/bootstrapper/kubeadm/util.go b/pkg/minikube/bootstrapper/kubeadm/util.go index 7e4f45c0b0..24e207eaf8 100644 --- a/pkg/minikube/bootstrapper/kubeadm/util.go +++ b/pkg/minikube/bootstrapper/kubeadm/util.go @@ -21,6 +21,7 @@ import ( "encoding/json" "html/template" + "github.com/golang/glog" "github.com/pkg/errors" clientv1 "k8s.io/api/core/v1" rbacv1beta1 "k8s.io/api/rbac/v1beta1" @@ -35,7 +36,10 @@ import ( "k8s.io/minikube/pkg/util" ) -const masterTaint = "node-role.kubernetes.io/master" +const ( + masterTaint = "node-role.kubernetes.io/master" + rbacName = "minikube-rbac" +) var master = "" @@ -92,7 +96,7 @@ func elevateKubeSystemPrivileges() error { client, err := k8s.GetClientset() clusterRoleBinding := &rbacv1beta1.ClusterRoleBinding{ ObjectMeta: v1.ObjectMeta{ - Name: "minikube-rbac", + Name: rbacName, }, Subjects: []rbacv1beta1.Subject{ { @@ -107,6 +111,10 @@ func elevateKubeSystemPrivileges() error { }, } + if _, err := client.RbacV1beta1().ClusterRoleBindings().Get(rbacName, metav1.GetOptions{}); err == nil { + glog.Infof("Role binding %s already exists. Skipping creation.", rbacName) + return nil + } _, err = client.RbacV1beta1().ClusterRoleBindings().Create(clusterRoleBinding) if err != nil { return errors.Wrap(err, "creating clusterrolebinding")