Skip to content

Commit

Permalink
✨ make sure the cloud provider vsphere pod restart only on modify eve…
Browse files Browse the repository at this point in the history
…nt and restart gracefully

Signed-off-by: xudong liu <[email protected]>
  • Loading branch information
XudongLiuHarold committed Aug 23, 2024
1 parent 0dcfa4d commit e4c93b6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/vsphere-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ func initializeWatch(_ *appconfig.CompletedConfig, paths []string) (watch *fsnot
case err := <-watch.Errors:
klog.Warningf("watcher receives err: %v\n", err)
case event := <-watch.Events:
if event.Op != fsnotify.Chmod {
klog.Fatalf("restarting pod because received event %v\n", event)
// only restart pod when monitor an update event on watched file
if event.Op&fsnotify.Write == fsnotify.Write {
klog.Errorf("restarting pod because received event %v\n", event)
stopCh <- struct{}{}
} else {
klog.V(5).Infof("watcher receives %s on the mounted file %s\n", event.Op.String(), event.Name)
Expand Down

0 comments on commit e4c93b6

Please sign in to comment.