mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Merge pull request #25596 from derekparker/inotify
kubelet: Optionally, have kubelet exit if lock file contention is observed, using --exit-on-lock-contention flag
This commit is contained in:
@@ -19,6 +19,7 @@ package app
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
@@ -289,11 +290,22 @@ func Run(s *options.KubeletServer, kcfg *KubeletConfig) error {
|
||||
}
|
||||
|
||||
func run(s *options.KubeletServer, kcfg *KubeletConfig) (err error) {
|
||||
if s.ExitOnLockContention && s.LockFilePath == "" {
|
||||
return errors.New("cannot exit on lock file contention: no lock file specified")
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
if s.LockFilePath != "" {
|
||||
glog.Infof("aquiring lock on %q", s.LockFilePath)
|
||||
if err := flock.Acquire(s.LockFilePath); err != nil {
|
||||
return fmt.Errorf("unable to aquire file lock on %q: %v", s.LockFilePath, err)
|
||||
}
|
||||
if s.ExitOnLockContention {
|
||||
glog.Infof("watching for inotify events for: %v", s.LockFilePath)
|
||||
if err := watchForLockfileContention(s.LockFilePath, done); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if c, err := configz.New("componentconfig"); err == nil {
|
||||
c.Set(s.KubeletConfiguration)
|
||||
@@ -383,8 +395,8 @@ func run(s *options.KubeletServer, kcfg *KubeletConfig) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// run forever
|
||||
select {}
|
||||
<-done
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitializeTLS checks for a configured TLSCertFile and TLSPrivateKeyFile: if unspecified a new self-signed
|
||||
|
||||
Reference in New Issue
Block a user