Skip to content

Commit c301f93

Browse files
authored
Revert "refactor: move custom sysctls to cse" (#2863) (#2865)
This reverts commit 92060d0.
1 parent d80c8cb commit c301f93

File tree

161 files changed

+1319
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1319
-440
lines changed

parts/linux/cloud-init/artifacts/cse_cmd.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ CUSTOM_SEARCH_REALM_PASSWORD="{{GetSearchDomainRealmPassword}}"
132132
MESSAGE_OF_THE_DAY="{{GetMessageOfTheDay}}"
133133
HAS_KUBELET_DISK_TYPE="{{HasKubeletDiskType}}"
134134
NEEDS_CGROUPV2="{{Is2204VHD}}"
135-
SYSCTL_CONTENT="{{GetSysctlContent}}"
136135
TLS_BOOTSTRAP_TOKEN="{{GetTLSBootstrapTokenForKubeConfig}}"
137136
KUBELET_FLAGS="{{GetKubeletConfigKeyVals}}"
138137
NETWORK_POLICY="{{GetParameter "networkPolicy"}}"

parts/linux/cloud-init/artifacts/cse_config.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,7 @@ EOF
443443

444444
ensureSysctl() {
445445
SYSCTL_CONFIG_FILE=/etc/sysctl.d/999-sysctl-aks.conf
446-
mkdir -p "$(dirname "${SYSCTL_CONFIG_FILE}")"
447-
touch "${SYSCTL_CONFIG_FILE}"
448-
chmod 0644 "${SYSCTL_CONFIG_FILE}"
449-
echo "${SYSCTL_CONTENT}" | base64 -d > "${SYSCTL_CONFIG_FILE}"
446+
wait_for_file 1200 1 $SYSCTL_CONFIG_FILE || exit $ERR_FILE_WATCH_TIMEOUT
450447
retrycmd_if_failure 24 5 25 sysctl --system
451448
}
452449

parts/linux/cloud-init/nodecustomdata.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,113 @@ write_files:
373373
owner: root
374374
content: !!binary |
375375
{{GetVariableProperty "cloudInitData" "customSearchDomainsScript"}}
376+
377+
378+
- path: /etc/sysctl.d/999-sysctl-aks.conf
379+
permissions: "0644"
380+
owner: root
381+
content: |
382+
# This is a partial workaround to this upstream Kubernetes issue:
383+
# https://github.com/kubernetes/kubernetes/issues/41916#issuecomment-312428731
384+
net.ipv4.tcp_retries2=8
385+
net.core.message_burst=80
386+
net.core.message_cost=40
387+
{{- if GetCustomSysctlConfigByName "NetCoreSomaxconn"}}
388+
net.core.somaxconn={{.CustomLinuxOSConfig.Sysctls.NetCoreSomaxconn}}
389+
{{- else}}
390+
net.core.somaxconn=16384
391+
{{- end}}
392+
{{- if GetCustomSysctlConfigByName "NetIpv4TcpMaxSynBacklog"}}
393+
net.ipv4.tcp_max_syn_backlog={{.CustomLinuxOSConfig.Sysctls.NetIpv4TcpMaxSynBacklog}}
394+
{{- else}}
395+
net.ipv4.tcp_max_syn_backlog=16384
396+
{{- end}}
397+
{{- if GetCustomSysctlConfigByName "NetIpv4NeighDefaultGcThresh1"}}
398+
net.ipv4.neigh.default.gc_thresh1={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh1}}
399+
{{- else}}
400+
net.ipv4.neigh.default.gc_thresh1=4096
401+
{{- end}}
402+
{{- if GetCustomSysctlConfigByName "NetIpv4NeighDefaultGcThresh2"}}
403+
net.ipv4.neigh.default.gc_thresh2={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh2}}
404+
{{- else}}
405+
net.ipv4.neigh.default.gc_thresh2=8192
406+
{{- end}}
407+
{{- if GetCustomSysctlConfigByName "NetIpv4NeighDefaultGcThresh3"}}
408+
net.ipv4.neigh.default.gc_thresh3={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh3}}
409+
{{- else}}
410+
net.ipv4.neigh.default.gc_thresh3=16384
411+
{{- end}}
412+
{{if ShouldConfigCustomSysctl}}
413+
# The following are sysctl configs passed from API
414+
{{- $s:=.CustomLinuxOSConfig.Sysctls}}
415+
{{- if $s.NetCoreNetdevMaxBacklog}}
416+
net.core.netdev_max_backlog={{$s.NetCoreNetdevMaxBacklog}}
417+
{{- end}}
418+
{{- if $s.NetCoreRmemDefault}}
419+
net.core.rmem_default={{$s.NetCoreRmemDefault}}
420+
{{- end}}
421+
{{- if $s.NetCoreRmemMax}}
422+
net.core.rmem_max={{$s.NetCoreRmemMax}}
423+
{{- end}}
424+
{{- if $s.NetCoreWmemDefault}}
425+
net.core.wmem_default={{$s.NetCoreWmemDefault}}
426+
{{- end}}
427+
{{- if $s.NetCoreWmemMax}}
428+
net.core.wmem_max={{$s.NetCoreWmemMax}}
429+
{{- end}}
430+
{{- if $s.NetCoreOptmemMax}}
431+
net.core.optmem_max={{$s.NetCoreOptmemMax}}
432+
{{- end}}
433+
{{- if $s.NetIpv4TcpMaxTwBuckets}}
434+
net.ipv4.tcp_max_tw_buckets={{$s.NetIpv4TcpMaxTwBuckets}}
435+
{{- end}}
436+
{{- if $s.NetIpv4TcpFinTimeout}}
437+
net.ipv4.tcp_fin_timeout={{$s.NetIpv4TcpFinTimeout}}
438+
{{- end}}
439+
{{- if $s.NetIpv4TcpKeepaliveTime}}
440+
net.ipv4.tcp_keepalive_time={{$s.NetIpv4TcpKeepaliveTime}}
441+
{{- end}}
442+
{{- if $s.NetIpv4TcpKeepaliveProbes}}
443+
net.ipv4.tcp_keepalive_probes={{$s.NetIpv4TcpKeepaliveProbes}}
444+
{{- end}}
445+
{{- if $s.NetIpv4TcpkeepaliveIntvl}}
446+
net.ipv4.tcp_keepalive_intvl={{$s.NetIpv4TcpkeepaliveIntvl}}
447+
{{- end}}
448+
{{- if $s.NetIpv4TcpTwReuse}}
449+
net.ipv4.tcp_tw_reuse={{BoolPtrToInt $s.NetIpv4TcpTwReuse}}
450+
{{- end}}
451+
{{- if $s.NetIpv4IpLocalPortRange}}
452+
net.ipv4.ip_local_port_range={{$s.NetIpv4IpLocalPortRange}}
453+
{{- end}}
454+
{{- if $s.NetNetfilterNfConntrackMax}}
455+
net.netfilter.nf_conntrack_max={{$s.NetNetfilterNfConntrackMax}}
456+
{{- end}}
457+
{{- if $s.NetNetfilterNfConntrackBuckets}}
458+
net.netfilter.nf_conntrack_buckets={{$s.NetNetfilterNfConntrackBuckets}}
459+
{{- end}}
460+
{{- if $s.FsInotifyMaxUserWatches}}
461+
fs.inotify.max_user_watches={{$s.FsInotifyMaxUserWatches}}
462+
{{- end}}
463+
{{- if $s.FsFileMax}}
464+
fs.file-max={{$s.FsFileMax}}
465+
{{- end}}
466+
{{- if $s.FsAioMaxNr}}
467+
fs.aio-max-nr={{$s.FsAioMaxNr}}
468+
{{- end}}
469+
{{- if $s.FsNrOpen}}
470+
fs.nr_open={{$s.FsNrOpen}}
471+
{{- end}}
472+
{{- if $s.KernelThreadsMax}}
473+
kernel.threads-max={{$s.KernelThreadsMax}}
474+
{{- end}}
475+
{{- if $s.VMMaxMapCount}}
476+
vm.max_map_count={{$s.VMMaxMapCount}}
477+
{{- end}}
478+
{{- if $s.VMSwappiness}}
479+
vm.swappiness={{$s.VMSwappiness}}
480+
{{- end}}
481+
{{- if $s.VMVfsCachePressure}}
482+
vm.vfs_cache_pressure={{$s.VMVfsCachePressure}}
483+
{{- end}}
484+
{{- end}}
485+
#EOF

pkg/agent/baker.go

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
390390
},
391391
"GetCustomSysctlConfigByName": func(fn string) interface{} {
392392
if profile.CustomLinuxOSConfig != nil && profile.CustomLinuxOSConfig.Sysctls != nil {
393-
// TODO(ace): this should be removed.
394-
// yes, enumerating fields of a struct is annoying without reflection.
395-
// that means your api/implementation is probably wrong.
396393
v := reflect.ValueOf(*profile.CustomLinuxOSConfig.Sysctls)
397394
return v.FieldByName(fn).Interface()
398395
}
@@ -887,14 +884,6 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
887884
"ShouldDisableSSH": func() bool {
888885
return config.SSHStatus == datamodel.SSHOff
889886
},
890-
"GetSysctlContent": func() string {
891-
sysctlTemplate := template.Must(template.New("sysctl").Parse(sysctlTemplateString))
892-
var b bytes.Buffer
893-
if err := sysctlTemplate.Execute(&b, profile); err != nil {
894-
panic(fmt.Errorf("failed to execute sysctl template: %s", err))
895-
}
896-
return base64.StdEncoding.EncodeToString(b.Bytes())
897-
},
898887
}
899888
}
900889

@@ -933,113 +922,6 @@ func isMariner(osSku string) bool {
933922
return osSku == datamodel.OSSKUCBLMariner || osSku == datamodel.OSSKUMariner
934923
}
935924

936-
const sysctlTemplateString = `# This is a partial workaround to this upstream Kubernetes issue:
937-
# https://github.com/kubernetes/kubernetes/issues/41916#issuecomment-312428731
938-
net.ipv4.tcp_retries2=8
939-
net.core.message_burst=80
940-
net.core.message_cost=40
941-
{{- if .CustomLinuxOSConfig}}{{ if .CustomLinuxOSConfig.Sysctls}}{{ if .CustomLinuxOSConfig.Sysctls.NetCoreSomaxconn}}
942-
net.core.somaxconn={{.CustomLinuxOSConfig.Sysctls.NetCoreSomaxconn}}
943-
{{end}}{{end}}{{- else}}
944-
net.core.somaxconn=16384
945-
{{- end}}
946-
{{- if .CustomLinuxOSConfig}}{{ if .CustomLinuxOSConfig.Sysctls}}{{ if .CustomLinuxOSConfig.Sysctls.NetIpv4TcpMaxSynBacklog}}
947-
net.ipv4.tcp_max_syn_backlog={{.CustomLinuxOSConfig.Sysctls.NetIpv4TcpMaxSynBacklog}}
948-
{{end}}{{end}}{{- else}}
949-
net.ipv4.tcp_max_syn_backlog=16384
950-
{{- end}}
951-
{{- if .CustomLinuxOSConfig}}{{ if .CustomLinuxOSConfig.Sysctls}}{{ if .CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh1}}
952-
net.ipv4.neigh.default.gc_thresh1={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh1}}
953-
{{end}}{{end}}{{- else}}
954-
net.ipv4.neigh.default.gc_thresh1=4096
955-
{{- end}}
956-
{{- if .CustomLinuxOSConfig}}{{ if .CustomLinuxOSConfig.Sysctls}}{{ if .CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh2}}
957-
net.ipv4.neigh.default.gc_thresh2={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh2}}
958-
{{end}}{{end}}{{- else}}
959-
net.ipv4.neigh.default.gc_thresh2=8192
960-
{{- end}}
961-
{{- if .CustomLinuxOSConfig}}{{ if .CustomLinuxOSConfig.Sysctls}}{{ if .CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh3}}
962-
net.ipv4.neigh.default.gc_thresh3={{.CustomLinuxOSConfig.Sysctls.NetIpv4NeighDefaultGcThresh3}}
963-
{{end}}{{end}}{{- else}}
964-
net.ipv4.neigh.default.gc_thresh3=16384
965-
{{- end}}
966-
{{if .CustomLinuxOSConfig}}
967-
{{if .CustomLinuxOSConfig.Sysctls}}
968-
# The following are sysctl configs passed from API
969-
{{- $s:=.CustomLinuxOSConfig.Sysctls}}
970-
{{- if $s.NetCoreNetdevMaxBacklog}}
971-
net.core.netdev_max_backlog={{$s.NetCoreNetdevMaxBacklog}}
972-
{{- end}}
973-
{{- if $s.NetCoreRmemDefault}}
974-
net.core.rmem_default={{$s.NetCoreRmemDefault}}
975-
{{- end}}
976-
{{- if $s.NetCoreRmemMax}}
977-
net.core.rmem_max={{$s.NetCoreRmemMax}}
978-
{{- end}}
979-
{{- if $s.NetCoreWmemDefault}}
980-
net.core.wmem_default={{$s.NetCoreWmemDefault}}
981-
{{- end}}
982-
{{- if $s.NetCoreWmemMax}}
983-
net.core.wmem_max={{$s.NetCoreWmemMax}}
984-
{{- end}}
985-
{{- if $s.NetCoreOptmemMax}}
986-
net.core.optmem_max={{$s.NetCoreOptmemMax}}
987-
{{- end}}
988-
{{- if $s.NetIpv4TcpMaxTwBuckets}}
989-
net.ipv4.tcp_max_tw_buckets={{$s.NetIpv4TcpMaxTwBuckets}}
990-
{{- end}}
991-
{{- if $s.NetIpv4TcpFinTimeout}}
992-
net.ipv4.tcp_fin_timeout={{$s.NetIpv4TcpFinTimeout}}
993-
{{- end}}
994-
{{- if $s.NetIpv4TcpKeepaliveTime}}
995-
net.ipv4.tcp_keepalive_time={{$s.NetIpv4TcpKeepaliveTime}}
996-
{{- end}}
997-
{{- if $s.NetIpv4TcpKeepaliveProbes}}
998-
net.ipv4.tcp_keepalive_probes={{$s.NetIpv4TcpKeepaliveProbes}}
999-
{{- end}}
1000-
{{- if $s.NetIpv4TcpkeepaliveIntvl}}
1001-
net.ipv4.tcp_keepalive_intvl={{$s.NetIpv4TcpkeepaliveIntvl}}
1002-
{{- end}}
1003-
{{- if $s.NetIpv4TcpTwReuse}}
1004-
net.ipv4.tcp_tw_reuse={{if $s.NetIpv4TcpTwReuse}}1{{else}}0{{end}}
1005-
{{- end}}
1006-
{{- if $s.NetIpv4IpLocalPortRange}}
1007-
net.ipv4.ip_local_port_range={{$s.NetIpv4IpLocalPortRange}}
1008-
{{- end}}
1009-
{{- if $s.NetNetfilterNfConntrackMax}}
1010-
net.netfilter.nf_conntrack_max={{$s.NetNetfilterNfConntrackMax}}
1011-
{{- end}}
1012-
{{- if $s.NetNetfilterNfConntrackBuckets}}
1013-
net.netfilter.nf_conntrack_buckets={{$s.NetNetfilterNfConntrackBuckets}}
1014-
{{- end}}
1015-
{{- if $s.FsInotifyMaxUserWatches}}
1016-
fs.inotify.max_user_watches={{$s.FsInotifyMaxUserWatches}}
1017-
{{- end}}
1018-
{{- if $s.FsFileMax}}
1019-
fs.file-max={{$s.FsFileMax}}
1020-
{{- end}}
1021-
{{- if $s.FsAioMaxNr}}
1022-
fs.aio-max-nr={{$s.FsAioMaxNr}}
1023-
{{- end}}
1024-
{{- if $s.FsNrOpen}}
1025-
fs.nr_open={{$s.FsNrOpen}}
1026-
{{- end}}
1027-
{{- if $s.KernelThreadsMax}}
1028-
kernel.threads-max={{$s.KernelThreadsMax}}
1029-
{{- end}}
1030-
{{- if $s.VMMaxMapCount}}
1031-
vm.max_map_count={{$s.VMMaxMapCount}}
1032-
{{- end}}
1033-
{{- if $s.VMSwappiness}}
1034-
vm.swappiness={{$s.VMSwappiness}}
1035-
{{- end}}
1036-
{{- if $s.VMVfsCachePressure}}
1037-
vm.vfs_cache_pressure={{$s.VMVfsCachePressure}}
1038-
{{- end}}
1039-
{{- end}}
1040-
{{- end}}
1041-
`
1042-
1043925
const kubenetCniTemplate = `
1044926
{
1045927
"cniVersion": "0.3.1",

0 commit comments

Comments
 (0)