Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
test: add unit test, make default not static
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis authored and andyzhangx committed Apr 24, 2019
1 parent 45302f3 commit f5a3008
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/api/defaults-kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (cs *ContainerService) setKubeletConfig() {
"--cgroups-per-qos": "true",
"--kubeconfig": "/var/lib/kubelet/kubeconfig",
"--keep-terminated-pod-volumes": "false",
"--protect-kernel-defaults": "true",
}

// Start with copy of Linux config
Expand Down Expand Up @@ -80,6 +79,7 @@ func (cs *ContainerService) setKubeletConfig() {
"--image-pull-progress-deadline": "30m",
"--enforce-node-allocatable": "pods",
"--streaming-connection-idle-timeout": "5m",
"--protect-kernel-defaults": "true",
}

// Set --non-masquerade-cidr if ip-masq-agent is disabled on AKS
Expand Down
25 changes: 25 additions & 0 deletions pkg/api/defaults-kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,31 @@ func TestEnforceNodeAllocatable(t *testing.T) {
}
}

func TestProtectKernelDefaults(t *testing.T) {
// Validate default
cs := CreateMockContainerService("testcluster", "1.12.7", 3, 2, false)
cs.setKubeletConfig()
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
if k["--protect-kernel-defaults"] != "true" {
t.Fatalf("got unexpected '--protect-kernel-defaults' kubelet config value %s, the expected value is %s",
k["--protect-kernel-defaults"], "pods")
}

// Validate that --protect-kernel-defaults is overridable
cs = CreateMockContainerService("testcluster", "1.10.13", 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig = &KubernetesConfig{
KubeletConfig: map[string]string{
"--protect-kernel-defaults": "false",
},
}
cs.setKubeletConfig()
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
if k["--protect-kernel-defaults"] != "false" {
t.Fatalf("got unexpected '--protect-kernel-defaults' kubelet config value %s, the expected value is %s",
k["--protect-kernel-defaults"], "false")
}
}

func TestStaticWindowsConfig(t *testing.T) {
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 1, false)
p := GetK8sDefaultProperties(true)
Expand Down

0 comments on commit f5a3008

Please sign in to comment.