Fail on swap enabled and deprecate experimental-fail-swap-on flag
* Deprecate the old experimental-fail-swap-on * Add a new flag fail-swap-on and set it to true Before this change, we would not fail when swap is on. With this change we fail for everyone when swap is on, unless they explicitly set --fail-swap-on to false.
This commit is contained in:
parent
dd819b5013
commit
71e8c8eba4
@ -144,8 +144,9 @@ func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
|
||||
// addFlags adds flags for a specific componentconfig.KubeletConfiguration to the specified FlagSet
|
||||
func (c *kubeletConfiguration) addFlags(fs *pflag.FlagSet) {
|
||||
// TODO(#34726:1.8.0): Remove the opt-in for failing when swap is enabled.
|
||||
fs.BoolVar(&c.ExperimentalFailSwapOn, "experimental-fail-swap-on", c.ExperimentalFailSwapOn, "Makes the Kubelet fail to start if swap is enabled on the node. This is a temporary opton to maintain legacy behavior, failing due to swap enabled will happen by default in v1.6.")
|
||||
fs.BoolVar(&c.FailSwapOn, "fail-swap-on", true, "Makes the Kubelet fail to start if swap is enabled on the node. ")
|
||||
fs.BoolVar(&c.FailSwapOn, "experimental-fail-swap-on", true, "DEPRECATED: please use --fail-swap-on instead.")
|
||||
fs.MarkDeprecated("experimental-fail-swap-on", "This flag is deprecated and will be removed in future releases. please use --fail-swap-on instead.")
|
||||
|
||||
fs.StringVar(&c.PodManifestPath, "pod-manifest-path", c.PodManifestPath, "Path to to the directory containing pod manifest files to run, or the path to a single pod manifest file. Files starting with dots will be ignored.")
|
||||
fs.DurationVar(&c.SyncFrequency.Duration, "sync-frequency", c.SyncFrequency.Duration, "Max period between synchronizing running containers and config")
|
||||
|
@ -584,7 +584,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
},
|
||||
ExperimentalQOSReserved: *experimentalQOSReserved,
|
||||
},
|
||||
s.ExperimentalFailSwapOn,
|
||||
s.FailSwapOn,
|
||||
kubeDeps.Recorder)
|
||||
|
||||
if err != nil {
|
||||
|
@ -271,6 +271,7 @@ external-hostname
|
||||
external-ip
|
||||
external-name
|
||||
extra-peer-dirs
|
||||
fail-swap-on
|
||||
failover-timeout
|
||||
failure-domains
|
||||
fake-clientset
|
||||
|
@ -465,9 +465,8 @@ type KubeletConfiguration struct {
|
||||
// featureGates is a string of comma-separated key=value pairs that describe feature
|
||||
// gates for alpha/experimental features.
|
||||
FeatureGates string
|
||||
// TODO(#34726:1.8.0): Remove the opt-in for failing when swap is enabled.
|
||||
// Tells the Kubelet to fail to start if swap is enabled on the node.
|
||||
ExperimentalFailSwapOn bool
|
||||
FailSwapOn bool
|
||||
// This flag, if set, enables a check prior to mount operations to verify that the required components
|
||||
// (binaries, etc.) to mount the volume are available on the underlying node. If the check is enabled
|
||||
// and fails the mount operation fails.
|
||||
|
@ -530,9 +530,8 @@ type KubeletConfiguration struct {
|
||||
// featureGates is a string of comma-separated key=value pairs that describe feature
|
||||
// gates for alpha/experimental features.
|
||||
FeatureGates string `json:"featureGates,omitempty"`
|
||||
// TODO(#34726:1.8.0): Remove the opt-in for failing when swap is enabled.
|
||||
// Tells the Kubelet to fail to start if swap is enabled on the node.
|
||||
ExperimentalFailSwapOn bool `json:"experimentalFailSwapOn,omitempty"`
|
||||
FailSwapOn bool `json:"failSwapOn,omitempty"`
|
||||
// This flag, if set, enables a check prior to mount operations to verify that the required components
|
||||
// (binaries, etc.) to mount the volume are available on the underlying node. If the check is enabled
|
||||
// and fails the mount operation fails.
|
||||
|
@ -504,7 +504,7 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_componentconfig_KubeletConfigu
|
||||
}
|
||||
out.AllowedUnsafeSysctls = *(*[]string)(unsafe.Pointer(&in.AllowedUnsafeSysctls))
|
||||
out.FeatureGates = in.FeatureGates
|
||||
out.ExperimentalFailSwapOn = in.ExperimentalFailSwapOn
|
||||
out.FailSwapOn = in.FailSwapOn
|
||||
out.ExperimentalCheckNodeCapabilitiesBeforeMount = in.ExperimentalCheckNodeCapabilitiesBeforeMount
|
||||
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
|
||||
out.SystemReserved = *(*componentconfig.ConfigurationMap)(unsafe.Pointer(&in.SystemReserved))
|
||||
@ -686,7 +686,7 @@ func autoConvert_componentconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigu
|
||||
}
|
||||
out.AllowedUnsafeSysctls = *(*[]string)(unsafe.Pointer(&in.AllowedUnsafeSysctls))
|
||||
out.FeatureGates = in.FeatureGates
|
||||
out.ExperimentalFailSwapOn = in.ExperimentalFailSwapOn
|
||||
out.FailSwapOn = in.FailSwapOn
|
||||
out.ExperimentalCheckNodeCapabilitiesBeforeMount = in.ExperimentalCheckNodeCapabilitiesBeforeMount
|
||||
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
|
||||
out.SystemReserved = *(*map[string]string)(unsafe.Pointer(&in.SystemReserved))
|
||||
|
@ -204,18 +204,14 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO(#34726:1.8.0): Remove the opt-in for failing when swap is enabled.
|
||||
// Running with swap enabled should be considered an error, but in order to maintain legacy
|
||||
// behavior we have to require an opt-in to this error for a period of time.
|
||||
|
||||
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should error out.
|
||||
// Running with swap enabled should be considered an error, but in order to maintain legacy
|
||||
// behavior we have to require an opt-in to this error for a period of time.
|
||||
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should
|
||||
// error out unless --fail-swap-on is set to false.
|
||||
if len(buf) > 1 {
|
||||
if failSwapOn {
|
||||
return nil, fmt.Errorf("Running with swap on is not supported, please disable swap! /proc/swaps contained: %v", buf)
|
||||
return nil, fmt.Errorf("Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: %v", buf)
|
||||
}
|
||||
glog.Warningf("Running with swap on is not supported, please disable swap! " +
|
||||
"This will be a fatal error by default starting in K8s v1.6! " +
|
||||
"In the meantime, you can opt-in to making this a fatal error by enabling --experimental-fail-swap-on.")
|
||||
}
|
||||
var capacity = v1.ResourceList{}
|
||||
// It is safe to invoke `MachineInfo` on cAdvisor before logically initializing cAdvisor here because
|
||||
|
Loading…
Reference in New Issue
Block a user