Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislovecnm committed Jan 17, 2017
1 parent 64a1be9 commit d980445
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 32 deletions.
18 changes: 9 additions & 9 deletions pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,49 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
k8sv148, err := kops.ParseKubernetesVersion("v1.4.8")

if err != nil {
return fmt.Errorf("Unable to parse kubernetesVersion v1.4.8")
return fmt.Errorf("Unable to parse kubernetesVersion %s", err)
}

k8sv152, _ := kops.ParseKubernetesVersion("v1.5.2")

if err != nil {
return fmt.Errorf("Unable to parse kubernetesVersion v1.5.2")
return fmt.Errorf("Unable to parse kubernetesVersion %s", err)
}

kubernetesVersion, err := b.Context.KubernetesVersion()
if err != nil {
return fmt.Errorf("Unable to parse kubernetesVersion")
return fmt.Errorf("Unable to parse kubernetesVersion %s", err)
}

// In 1.4.8+ and 1.5.2+ k8s added the capability to tune the duration upon which the volume attach detach
// component is called.
// See https://github.com/kubernetes/kubernetes/pull/39551
// TLDR; set this too low, and have a few PVC, and you will spam AWS api
// TLDR; set this too low, and have a few EBS Volumes, and you will spam AWS api

// if 1.4.8+ and 1.5.2+
if kubernetesVersion.GTE(*k8sv148) || kubernetesVersion.GTE(*k8sv152) {

glog.Info("k-c-m default-attach-detach-reconcile-sync-period correct version found")
glog.V(4).Infof("Kubernetes version %q supports AttachDetachReconcileSyncPeriod; will configure", kubernetesVersion)
// If not set ... or set to 0s ... which is stupid
if options.KubeControllerManager.AttachDetachReconcileSyncPeriod == nil ||
options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration.String() == "0s" {

glog.V(8).Info("k-c-m default-attach-detach-reconcile-sync-period flag is set to default")
glog.V(8).Info("AttachDetachReconcileSyncPeriod is not set; will set to default %v", defaultAttachDetachReconcileSyncPeriod)
options.KubeControllerManager.AttachDetachReconcileSyncPeriod = &metav1.Duration{Duration: defaultAttachDetachReconcileSyncPeriod}

// If less than 1 min and greater than 1 sec ... you get a warning
} else if options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration < defaultAttachDetachReconcileSyncPeriod &&
options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration > time.Second {

glog.Info("k-c-m default-attach-detach-reconcile-sync-period flag is set lower than recommended")
glog.Info("KubeControllerManager AttachDetachReconcileSyncPeriod is set lower than recommended")

// If less than 1sec you get an error. Controller no worky .. it goes boom.
} else if options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration < time.Second {
return fmt.Errorf("Unable to set k-c-m default-attach-detach-reconcile-sync-period flag lower than 1 second")
return fmt.Errorf("Unable to set AttachDetachReconcileSyncPeriod than 1 second")
}
} else {

glog.Info("not setting k-c-m default-attach-detach-reconcile-sync-period, k8s version is too low")
glog.Info("not setting AttachDetachReconcileSyncPeriod, k8s version is too low")
options.KubeControllerManager.AttachDetachReconcileSyncPeriod = nil
}

Expand Down
17 changes: 0 additions & 17 deletions pkg/model/components/kubecontrollermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (

api "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
//"k8s.io/kops/upup/pkg/fi/nodeup"
//metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
)

type ClusterParams struct {
Expand Down Expand Up @@ -109,18 +107,3 @@ func Test_Build_KCM_Builder_High_Enough_Version(t *testing.T) {
}

}

/*
func TestBuildFlags(t *testing.T) {
kcm := &api.KubeControllerManagerConfig{
AttachDetachReconcileSyncPeriod: &metav1.Duration{Duration: time.Minute},
}
actual, err := nodeup.BuildFlags(kcm)
if err != nil {
t.Fatalf("error from BuildFlags: %v", err)
}
expected := "--attach-detach-reconcile-sync-period=1m0s --v=0"
if actual != expected {
t.Fatalf("unexpected flags. actual=%q expected=%q", actual, expected)
}
}*/
4 changes: 0 additions & 4 deletions upup/pkg/fi/cloudup/populatecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
api "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/davecgh/go-spew/spew"

)

func buildMinimalCluster() *api.Cluster {
Expand Down Expand Up @@ -473,8 +471,6 @@ func TestPopulateCluster_KubeController_High_Enough_Version(t *testing.T) {
t.Fatalf("Attache Detach not set correctly")
}

spew.Dump(*full.Spec.KubeControllerManager)
t.Fatal("BOOM")
}

func TestPopulateCluster_KubeController_Fail(t *testing.T) {
Expand Down
9 changes: 7 additions & 2 deletions upup/pkg/fi/nodeup/build_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ package nodeup

import (
"fmt"
"github.com/golang/glog"
"k8s.io/kops/upup/pkg/fi/utils"
"reflect"
"sort"
"strings"

"github.com/golang/glog"
"k8s.io/kops/upup/pkg/fi/utils"
metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
)

// buildFlags is a template helper, which builds a string containing the flags to be passed to a command
Expand Down Expand Up @@ -104,6 +106,9 @@ func buildFlags(options interface{}) (string, error) {
case bool, int, int32, int64, float32, float64:
vString := fmt.Sprintf("%v", v)
flag = fmt.Sprintf("--%s=%s", flagName, vString)
case metav1.Duration:
vString := v.Duration.String()
flag = fmt.Sprintf("--%s=%s", flagName, vString)

default:
return fmt.Errorf("BuildFlags of value type not handled: %T %s=%v", v, path, v)
Expand Down

0 comments on commit d980445

Please sign in to comment.