...

Source file src/k8s.io/kubernetes/cmd/kubelet/app/server_linux.go

Documentation: k8s.io/kubernetes/cmd/kubelet/app

     1  /*
     2  Copyright 2015 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package app
    18  
    19  import (
    20  	"k8s.io/klog/v2"
    21  	"k8s.io/utils/inotify"
    22  
    23  	libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
    24  )
    25  
    26  func watchForLockfileContention(path string, done chan struct{}) error {
    27  	watcher, err := inotify.NewWatcher()
    28  	if err != nil {
    29  		klog.ErrorS(err, "Unable to create watcher for lockfile")
    30  		return err
    31  	}
    32  	if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil {
    33  		klog.ErrorS(err, "Unable to watch lockfile")
    34  		watcher.Close()
    35  		return err
    36  	}
    37  	go func() {
    38  		select {
    39  		case ev := <-watcher.Event:
    40  			klog.InfoS("Inotify event", "event", ev)
    41  		case err = <-watcher.Error:
    42  			klog.ErrorS(err, "inotify watcher error")
    43  		}
    44  		close(done)
    45  		watcher.Close()
    46  	}()
    47  	return nil
    48  }
    49  
    50  func isCgroup2UnifiedMode() bool {
    51  	return libcontainercgroups.IsCgroup2UnifiedMode()
    52  }
    53  

View as plain text