mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #77915 from SataQiu/fix-golint-util-20190515
Fix golint failures of pkg/util/parsers pkg/util/sysctl pkg/util/system
This commit is contained in:
commit
d30fbab4b8
@ -296,14 +296,11 @@ pkg/util/mount
|
||||
pkg/util/netsh/testing
|
||||
pkg/util/normalizer
|
||||
pkg/util/oom
|
||||
pkg/util/parsers
|
||||
pkg/util/procfs
|
||||
pkg/util/removeall
|
||||
pkg/util/rlimit
|
||||
pkg/util/selinux
|
||||
pkg/util/sysctl
|
||||
pkg/util/sysctl/testing
|
||||
pkg/util/system
|
||||
pkg/util/taints
|
||||
pkg/util/tolerations
|
||||
pkg/version/verflag
|
||||
|
@ -360,8 +360,8 @@ const (
|
||||
// depending upon the specified option, it will either warn, error, or modify the kernel tunable flags
|
||||
func setupKernelTunables(option KernelTunableBehavior) error {
|
||||
desiredState := map[string]int{
|
||||
utilsysctl.VmOvercommitMemory: utilsysctl.VmOvercommitMemoryAlways,
|
||||
utilsysctl.VmPanicOnOOM: utilsysctl.VmPanicOnOOMInvokeOOMKiller,
|
||||
utilsysctl.VMOvercommitMemory: utilsysctl.VMOvercommitMemoryAlways,
|
||||
utilsysctl.VMPanicOnOOM: utilsysctl.VMPanicOnOOMInvokeOOMKiller,
|
||||
utilsysctl.KernelPanic: utilsysctl.KernelPanicRebootTimeout,
|
||||
utilsysctl.KernelPanicOnOops: utilsysctl.KernelPanicOnOopsAlways,
|
||||
utilsysctl.RootMaxKeys: utilsysctl.RootMaxKeysSetting,
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultImageTag is the default tag for docker image.
|
||||
DefaultImageTag = "latest"
|
||||
)
|
||||
|
||||
|
@ -24,25 +24,47 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
sysctlBase = "/proc/sys"
|
||||
VmOvercommitMemory = "vm/overcommit_memory"
|
||||
VmPanicOnOOM = "vm/panic_on_oom"
|
||||
KernelPanic = "kernel/panic"
|
||||
KernelPanicOnOops = "kernel/panic_on_oops"
|
||||
RootMaxKeys = "kernel/keys/root_maxkeys"
|
||||
RootMaxBytes = "kernel/keys/root_maxbytes"
|
||||
sysctlBase = "/proc/sys"
|
||||
// VMOvercommitMemory refers to the sysctl variable responsible for defining
|
||||
// the memory over-commit policy used by kernel.
|
||||
VMOvercommitMemory = "vm/overcommit_memory"
|
||||
// VMPanicOnOOM refers to the sysctl variable responsible for defining
|
||||
// the OOM behavior used by kernel.
|
||||
VMPanicOnOOM = "vm/panic_on_oom"
|
||||
// KernelPanic refers to the sysctl variable responsible for defining
|
||||
// the timeout after a panic for the kernel to reboot.
|
||||
KernelPanic = "kernel/panic"
|
||||
// KernelPanicOnOops refers to the sysctl variable responsible for defining
|
||||
// the kernel behavior when an oops or BUG is encountered.
|
||||
KernelPanicOnOops = "kernel/panic_on_oops"
|
||||
// RootMaxKeys refers to the sysctl variable responsible for defining
|
||||
// the maximum number of keys that the root user (UID 0 in the root user namespace) may own.
|
||||
RootMaxKeys = "kernel/keys/root_maxkeys"
|
||||
// RootMaxBytes refers to the sysctl variable responsible for defining
|
||||
// the maximum number of bytes of data that the root user (UID 0 in the root user namespace)
|
||||
// can hold in the payloads of the keys owned by root.
|
||||
RootMaxBytes = "kernel/keys/root_maxbytes"
|
||||
|
||||
VmOvercommitMemoryAlways = 1 // kernel performs no memory over-commit handling
|
||||
VmPanicOnOOMInvokeOOMKiller = 0 // kernel calls the oom_killer function when OOM occurs
|
||||
// VMOvercommitMemoryAlways represents that kernel performs no memory over-commit handling.
|
||||
VMOvercommitMemoryAlways = 1
|
||||
// VMPanicOnOOMInvokeOOMKiller represents that kernel calls the oom_killer function when OOM occurs.
|
||||
VMPanicOnOOMInvokeOOMKiller = 0
|
||||
|
||||
KernelPanicOnOopsAlways = 1 // kernel panics on kernel oops
|
||||
KernelPanicRebootTimeout = 10 // seconds after a panic for the kernel to reboot
|
||||
// KernelPanicOnOopsAlways represents that kernel panics on kernel oops.
|
||||
KernelPanicOnOopsAlways = 1
|
||||
// KernelPanicRebootTimeout is the timeout seconds after a panic for the kernel to reboot.
|
||||
KernelPanicRebootTimeout = 10
|
||||
|
||||
RootMaxKeysSetting = 1000000 // Needed since docker creates a new key per container
|
||||
RootMaxBytesSetting = RootMaxKeysSetting * 25 // allocate 25 bytes per key * number of MaxKeys
|
||||
// RootMaxKeysSetting is the maximum number of keys that the root user (UID 0 in the root user namespace) may own.
|
||||
// Needed since docker creates a new key per container.
|
||||
RootMaxKeysSetting = 1000000
|
||||
// RootMaxBytesSetting is the maximum number of bytes of data that the root user (UID 0 in the root user namespace)
|
||||
// can hold in the payloads of the keys owned by root.
|
||||
// Allocate 25 bytes per key * number of MaxKeys.
|
||||
RootMaxBytesSetting = RootMaxKeysSetting * 25
|
||||
)
|
||||
|
||||
// An injectable interface for running sysctl commands.
|
||||
// Interface is an injectable interface for running sysctl commands.
|
||||
type Interface interface {
|
||||
// GetSysctl returns the value for the specified sysctl setting
|
||||
GetSysctl(sysctl string) (int, error)
|
||||
@ -60,7 +82,7 @@ type procSysctl struct {
|
||||
}
|
||||
|
||||
// GetSysctl returns the value for the specified sysctl setting
|
||||
func (_ *procSysctl) GetSysctl(sysctl string) (int, error) {
|
||||
func (*procSysctl) GetSysctl(sysctl string) (int, error) {
|
||||
data, err := ioutil.ReadFile(path.Join(sysctlBase, sysctl))
|
||||
if err != nil {
|
||||
return -1, err
|
||||
@ -73,6 +95,6 @@ func (_ *procSysctl) GetSysctl(sysctl string) (int, error) {
|
||||
}
|
||||
|
||||
// SetSysctl modifies the specified sysctl flag to the new value
|
||||
func (_ *procSysctl) SetSysctl(sysctl string, newVal int) error {
|
||||
func (*procSysctl) SetSysctl(sysctl string, newVal int) error {
|
||||
return ioutil.WriteFile(path.Join(sysctlBase, sysctl), []byte(strconv.Itoa(newVal)), 0640)
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsMasterNode returns true if given node is a registered master.
|
||||
// TODO: find a better way of figuring out if given node is a registered master.
|
||||
func IsMasterNode(nodeName string) bool {
|
||||
// We are trying to capture "master(-...)?$" regexp.
|
||||
|
Loading…
Reference in New Issue
Block a user