From e4c93b6c67ce825c2f2fb6a64b960f95a4a74e63 Mon Sep 17 00:00:00 2001 From: xudong liu Date: Fri, 23 Aug 2024 10:37:32 +0530 Subject: [PATCH] :sparkles: make sure the cloud provider vsphere pod restart only on modify event and restart gracefully Signed-off-by: xudong liu --- cmd/vsphere-cloud-controller-manager/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/vsphere-cloud-controller-manager/main.go b/cmd/vsphere-cloud-controller-manager/main.go index 38767db43..353baea5b 100644 --- a/cmd/vsphere-cloud-controller-manager/main.go +++ b/cmd/vsphere-cloud-controller-manager/main.go @@ -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)