From 9865a8b08601e21e1dba041929ecb08892922abe Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Mon, 31 Mar 2025 16:17:19 +0000 Subject: [PATCH] fix outdated metadata error in watcher --- pkg/gce-pd-csi-driver/cache.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/gce-pd-csi-driver/cache.go b/pkg/gce-pd-csi-driver/cache.go index 3de4bbcc7..1982a934d 100644 --- a/pkg/gce-pd-csi-driver/cache.go +++ b/pkg/gce-pd-csi-driver/cache.go @@ -641,6 +641,14 @@ func watchDiskDetaches(watcher *fsnotify.Watcher, nodeName string, errorCh chan case event := <-watcher.Events: // In case of an event i.e. creation or deletion of any new PV, we update the VG metadata. // This might include some non-LVM changes, no harm in updating metadata multiple times. + args := []string{ + "--updatemetadata", + getVolumeGroupName(nodeName), + } + _, err := common.RunCommand("" /* pipedCmd */, nil /* pipedCmdArg */, "vgck", args...) + if err != nil { + klog.Errorf("Error updating volume group's metadata: %v", err) + } reduceVolumeGroup(getVolumeGroupName(nodeName), true) klog.V(2).Infof("disk attach/detach event %#v\n", event) }