-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Updates for new k-c-m flag #1465
Updates for new k-c-m flag #1465
Conversation
8c84e52
to
60bd9e7
Compare
Jenkins Kubernetes AWS e2e failed for commit 34bc061. Full PR test history. cc @chrislovecnm The magic incantation to run this job again is Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I am not able to get the yaml updating on the cluster spec of a running server:
kubeControllerManager:
allocateNodeCIDRs: true
attachDetachReconcileSyncPeriod: 1m0s
cloudProvider: aws
clusterCIDR: 100.96.0.0/11
clusterName: liea-ginny.dev.datapipe.io
configureCloudRoutes: false
image: gcr.io/google_containers/kube-controller-manager:v1.5.2
leaderElection:
leaderElect: true
logLevel: 2
master: 127.0.0.1:8080
master: 127.0.0.1:8080
config: /etc/kubernetes/manifests
enableDebuggingHandlers: true
hostnameOverride: '@aws'
logLevel: 2
networkPluginMTU: null
networkPluginName: cni
nonMasqueradeCIDR: 100.64.0.0/10 Ideas? |
return fmt.Errorf("Unable to parse kubernetesVersion v1.4.8") | ||
} | ||
|
||
k8sv152, _ := kops.ParseKubernetesVersion("v1.5.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this returns an error
k8sv152, _
Shouldn't we grab it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already did in an update ... will push
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of style nits. Will now look at why the flag isn't working...
} | ||
|
||
if spec.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration != time.Minute { | ||
t.Fatalf("k-c-m builder should be set to 1m - %s", spec.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/k-c-m- builder/AttachDetachReconcileSyncPeriod/g
err := kcm.BuildOptions(&spec) | ||
|
||
if err != nil { | ||
t.Fatalf("k-c-m builder errors: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/k-c-m builder errors/unexpected error from BuildOptions/g
} | ||
|
||
if spec.KubeControllerManager.AttachDetachReconcileSyncPeriod != nil { | ||
t.Fatalf("k-c-m builder cannot be set for k8s %s", spec.KubernetesVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AttachDetachReconcileSyncPeriod should not be set for old kubernetes version %s"
err := kcm.BuildOptions(&spec) | ||
|
||
if err != nil { | ||
t.Fatalf("k-c-m builder errors: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unexpected error from BuildOptions"
UpdatePolicy string | ||
} | ||
|
||
func buildCluster(clusterArgs interface{}) *api.Cluster { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why interface{}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just code I grabbed from elsewhere, will clean-up the tests some
return fmt.Errorf("Unable to parse kubernetesVersion v1.4.8") | ||
} | ||
|
||
k8sv152, _ := kops.ParseKubernetesVersion("v1.5.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to assign err here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have in an update
|
||
kubernetesVersion, err := b.Context.KubernetesVersion() | ||
if err != nil { | ||
return fmt.Errorf("Unable to parse kubernetesVersion") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to add to the error - the error that comes back from KubernetesVersion
is already pretty good I think. But you shouldn't swallow the error i.e. do fmt.Errorf("additional info: %v", err)
glog.Info("k-c-m default-attach-detach-reconcile-sync-period correct version found") | ||
// If not set ... or set to 0s ... which is stupid | ||
if options.KubeControllerManager.AttachDetachReconcileSyncPeriod == nil || | ||
options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration.String() == "0s" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can do == 0
rather than calling .String() == "0s"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That did not work when I tested it :(
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AttachDetachReconcileSyncPeriod is not set; will set to default %v", defaultAttachDetachReconcileSyncPeriod
} 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either use the flag name attach-detach-reconcile-sync-period
or the field AttachDetachReconcileSyncPeriod
. And probably best to spell out kube-controller-manager
, particularly as this is at level Info
You want a test like this also...
Which will fail because |
And to fix that you need this in build_flags.go
|
Also glog.Infof is really annoying after a But then it works for me:
I haven't tested it all the way through, but I think that should be it.... |
Correct version of test. Note also the awkward v=0 arg, but that's a separate issue...
|
@justinsb thanks for the catch ... was driving me nuts. |
@justinsb not sure where you want me to put the test, because you seemed to changed:
to
You changed |
34bc061
to
d980445
Compare
@justinsb / @kris-nova need another review. Will rebase after e2e |
f1ed339
to
b647126
Compare
…-detach-reconcile-sync-period
b647126
to
3cabfb2
Compare
#1528 filed this issue for documenting changes like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more tweaks needed I think
} | ||
|
||
k8sv148, err := kops.ParseKubernetesVersion("v1.4.8") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler is better I think.
return fmt.Errorf("Unable to parse kubernetesVersion %s", err) | ||
} | ||
|
||
k8sv152, _ := kops.ParseKubernetesVersion("v1.5.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to map the error here
if options.KubeControllerManager.AttachDetachReconcileSyncPeriod == nil || | ||
options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration.String() == "0s" { | ||
|
||
glog.V(8).Info("AttachDetachReconcileSyncPeriod is not set; will set to default %v", defaultAttachDetachReconcileSyncPeriod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infof. I prefer always to use Infof, because then you never make this mistake, though I think go vet or go lint doesn't like it
|
||
glog.Info("KubeControllerManager AttachDetachReconcileSyncPeriod is set lower than recommended") | ||
|
||
// If less than 1sec you get an error. Controller no worky .. it goes boom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a k8s issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misworded .. let me reword
} | ||
} else { | ||
|
||
glog.Info("not setting AttachDetachReconcileSyncPeriod, k8s version is too low") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V(2) or higher
} | ||
|
||
if spec.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration != time.Minute { | ||
t.Fatalf("k-c-m builder should be set to 1m - %s", spec.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttachDetachReconcileSyncPeriod should be set...
} | ||
|
||
if full.Spec.KubeControllerManager.AttachDetachReconcileSyncPeriod == nil { | ||
t.Fatalf("Attache Detach not set correctly") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttachDetachReconcileSyncPeriod
} | ||
|
||
if full.Spec.KubeControllerManager.AttachDetachReconcileSyncPeriod != nil { | ||
t.Fatalf("Attach Detach is not supported in 1.4.7") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttachDetachReconcileSyncPeriod
|
||
// 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 AttachDetachReconcileSyncPeriod than 1 second") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it more obviously a validation error: "AttachDetachReconcileSyncPeriod cannot be set to less than 1 second"
} else if options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration < defaultAttachDetachReconcileSyncPeriod && | ||
options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration > time.Second { | ||
|
||
glog.Info("KubeControllerManager AttachDetachReconcileSyncPeriod is set lower than recommended") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infof(...than recommend: %v", options.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration)
Huh?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #1417
New flag for kubernetes controller manager that reduces the number of API calls that k-c-m makes. In 1.4.7 and 1.5.x a new feature was added to k-c-m. That feature can now spam AWS APIs if not tuned correctly.
This change is