mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
iscsi: don't write json medata file when the volume is already mounted.
iSCSI volume plugin persists volume metadata into global mount directory, before it is mounted. Content of the directory is shadowed by the volume mount. Therefore kubelet should not write metadata to the directory when a second pod uses the same volume on the same node. 1. The metadata were already persisted before mounting the volume for the first pod. 2. The global mount directory has the volume mounted, so any write there would write to the volume, which is undesirable.
This commit is contained in:
parent
62b7516b63
commit
9a9c216825
@ -491,6 +491,22 @@ func (util *ISCSIUtil) persistISCSI(b iscsiDiskMounter) error {
|
||||
klog.Errorf("iscsi: failed to mkdir %s, error", globalPDPath)
|
||||
return err
|
||||
}
|
||||
|
||||
if b.volumeMode == v1.PersistentVolumeFilesystem {
|
||||
notMnt, err := b.mounter.IsLikelyNotMountPoint(globalPDPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !notMnt {
|
||||
// The volume is already mounted, therefore the previous WaitForAttach must have
|
||||
// persisted the volume metadata. In addition, the metadata is actually *inside*
|
||||
// globalPDPath and we can't write it here, because it was shadowed by the volume
|
||||
// mount.
|
||||
klog.V(4).Infof("Skipping persistISCSI, the volume is already mounted at %s", globalPDPath)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Persist iscsi disk config to json file for DetachDisk path
|
||||
return util.persistISCSIFile(*(b.iscsiDisk), globalPDPath)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user