mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
kubelet: ignore /dev/kmsg error when running in userns
oomwatcher.NewWatcher returns "open /dev/kmsg: operation not permitted" error, when running with sysctl value `kernel.dmesg_restrict=1`. The error is negligible for KubeletInUserNamespace. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
192790c52f
commit
26e83ac4d4
@ -34,6 +34,7 @@ import (
|
|||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
|
libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"k8s.io/mount-utils"
|
"k8s.io/mount-utils"
|
||||||
"k8s.io/utils/integer"
|
"k8s.io/utils/integer"
|
||||||
|
|
||||||
@ -481,8 +482,20 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
|||||||
|
|
||||||
oomWatcher, err := oomwatcher.NewWatcher(kubeDeps.Recorder)
|
oomWatcher, err := oomwatcher.NewWatcher(kubeDeps.Recorder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if libcontaineruserns.RunningInUserNS() {
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletInUserNamespace) {
|
||||||
|
// oomwatcher.NewWatcher returns "open /dev/kmsg: operation not permitted" error,
|
||||||
|
// when running in a user namespace with sysctl value `kernel.dmesg_restrict=1`.
|
||||||
|
klog.V(2).InfoS("Failed to create an oomWatcher (running in UserNS, ignoring)", "err", err)
|
||||||
|
oomWatcher = nil
|
||||||
|
} else {
|
||||||
|
klog.ErrorS(err, "Failed to create an oomWatcher (running in UserNS, Hint: enable KubeletInUserNamespace feature flag to ignore the error)")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clusterDNS := make([]net.IP, 0, len(kubeCfg.ClusterDNS))
|
clusterDNS := make([]net.IP, 0, len(kubeCfg.ClusterDNS))
|
||||||
for _, ipEntry := range kubeCfg.ClusterDNS {
|
for _, ipEntry := range kubeCfg.ClusterDNS {
|
||||||
@ -1360,8 +1373,10 @@ func (kl *Kubelet) initializeModules() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start out of memory watcher.
|
// Start out of memory watcher.
|
||||||
|
if kl.oomWatcher != nil {
|
||||||
if err := kl.oomWatcher.Start(kl.nodeRef); err != nil {
|
if err := kl.oomWatcher.Start(kl.nodeRef); err != nil {
|
||||||
return fmt.Errorf("failed to start OOM watcher %v", err)
|
return fmt.Errorf("failed to start OOM watcher: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start resource analyzer
|
// Start resource analyzer
|
||||||
|
Loading…
Reference in New Issue
Block a user