-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubelet: Optionally, have kubelet exit if lock file contention is observed, using --exit-on-lock-contention flag #25596
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2015 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package app | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
"golang.org/x/exp/inotify" | ||
) | ||
|
||
func watchForLockfileContention(path string, done chan struct{}) error { | ||
watcher, err := inotify.NewWatcher() | ||
if err != nil { | ||
glog.Errorf("unable to create watcher for lockfile: %v", err) | ||
return err | ||
} | ||
if err = watcher.AddWatch(path, inotify.IN_OPEN|inotify.IN_DELETE_SELF); err != nil { | ||
glog.Errorf("unable to watch lockfile: %v", err) | ||
return err | ||
} | ||
go func() { | ||
select { | ||
case ev := <-watcher.Event: | ||
glog.Infof("inotify event: %v", ev) | ||
case err = <-watcher.Error: | ||
glog.Errorf("inotify watcher error: %v", err) | ||
} | ||
close(done) | ||
}() | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// +build !linux | ||
|
||
/* | ||
Copyright 2015 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package app | ||
|
||
import "errors" | ||
|
||
func watchForLockfileContention(path string, done chan struct{}) error { | ||
return errors.New("kubelet unsupported in this build") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need kubelet to build and run across different platforms. So we need a stub for features that are OS dependent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's why I added this file/function. To enable kubelet to build across platforms. Did you want something more than this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this implementation make the kubelet exit right away when run on OSX? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if this flag was supplied, but the kubelet doesn't actually work correctly on OSX, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We support development on OSX to some extent. So we want integration tests On Wed, May 18, 2016 at 3:57 PM, Derek Parker notifications@github.com
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't effect the integration tests then, at least, as none of them should hit this code path. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at
https://github.com/fsnotify/fsnotify
? I believe it works across OSes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, but it does not contain the "open" event, so I went with inotify instead, which was already vendored. https://github.com/fsnotify/fsnotify/blob/master/fsnotify.go#L25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh ok..