Commit 0f3f232b authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51095 from cofyc/rbd_log

Automatic merge from submit-queue RBD Plugin: Log RBD Attach/Mount/Unmout actions in addition to Detach **What this PR does / why we need it**: Currently, RBD Plugin can log a info message for a successful action of RBD Unmap, e.g.: ``` I0822 09:32:31.595162 15177 rbd_util.go:349] rbd: successfully unmap device /dev/rbd0 ``` This PR adds logs for another three important actions: Attach, Mount and Unmount. Logging these actions and associated info is *very* useful in diagnosing problems. **Special notes for your reviewer**: Example RBD Plugin logs of successful pod volume attaching and mounting: ``` I0822 09:30:27.512015 15177 rbd_util.go:148] lock list output "2017-08-22 09:30:27.493889 7fa4ae3c23c0 -1 auth: unable to find a keyring on /etc/ceph/ceph.client.kube.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory\n" W0822 09:30:27.547513 15177 rbd_util.go:460] rbd: no watchers on kubernetes-dynamic-pvc-83bfd49e-871c-11e7-b88e-000c291fbe71 I0822 09:30:27.704703 15177 rbd_util.go:315] rbd: successfully map image kube/kubernetes-dynamic-pvc-83bfd49e-871c-11e7-b88e-000c291fbe71 to /dev/rbd0 I0822 09:30:27.965603 15177 rbd_util.go:322] rbd: successfully mount image kube/kubernetes-dynamic-pvc-83bfd49e-871c-11e7-b88e-000c291fbe71 at /var/lib/kubelet/plugins/kubernetes.io/rbd/rbd/kube-image-kubernetes-dynamic-pvc-83bfd49e-871c-11e7-b88e-000c291fbe71 ``` Example RBD Plugin logs of successful pod volume detaching and unmouting: ``` I0822 09:32:31.380124 15177 rbd_util.go:334] rbd: successfully umount mountpoint /var/lib/kubelet/plugins/kubernetes.io/rbd/rbd/kube-image-kubernetes-dynamic-pvc-83bfd49e-871c-11e7-b88e-000c291fbe71 I0822 09:32:31.459867 15177 rbd_util.go:148] lock list output "2017-08-22 09:32:31.443643 7f2bb8ab53c0 -1 auth: unable to find a keyring on /etc/ceph/ceph.client.kube.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin: (2) No such file or directory\nThere is 1 exclusive lock on this image.\nLocker ID Address \nclient.64117 kubelet_lock_magic_k8s 192.168.2.128:0/4124042516 \n" I0822 09:32:31.595162 15177 rbd_util.go:349] rbd: successfully unmap device /dev/rbd0 ``` It does not add too much logs, but admins/ops can know what RBD plugin are doing internally and exact time a RBD image is mapped, mounted or unmounted (in addition to unmapped). **Release note**: ```release-note NONE ```
parents 16fee229 c648505f
...@@ -77,6 +77,7 @@ func diskSetUp(manager diskManager, b rbdMounter, volPath string, mounter mount. ...@@ -77,6 +77,7 @@ func diskSetUp(manager diskManager, b rbdMounter, volPath string, mounter mount.
glog.Errorf("failed to bind mount:%s", globalPDPath) glog.Errorf("failed to bind mount:%s", globalPDPath)
return err return err
} }
glog.V(3).Infof("rbd: successfully bind mount %s to %s with options %v", globalPDPath, volPath, mountOptions)
if !b.ReadOnly { if !b.ReadOnly {
volume.SetVolumeOwnership(&b, fsGroup) volume.SetVolumeOwnership(&b, fsGroup)
......
...@@ -312,12 +312,14 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) error { ...@@ -312,12 +312,14 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) error {
if !found { if !found {
return errors.New("Could not map image: Timeout after 10s") return errors.New("Could not map image: Timeout after 10s")
} }
glog.V(3).Infof("rbd: successfully map image %s/%s to %s", b.Pool, b.Image, devicePath)
} }
// mount it // mount it
if err = b.mounter.FormatAndMount(devicePath, globalPDPath, b.fsType, nil); err != nil { if err = b.mounter.FormatAndMount(devicePath, globalPDPath, b.fsType, nil); err != nil {
err = fmt.Errorf("rbd: failed to mount rbd volume %s [%s] to %s, error %v", devicePath, b.fsType, globalPDPath, err) err = fmt.Errorf("rbd: failed to mount rbd volume %s [%s] to %s, error %v", devicePath, b.fsType, globalPDPath, err)
} }
glog.V(3).Infof("rbd: successfully mount image %s/%s at %s", b.Pool, b.Image, globalPDPath)
return err return err
} }
...@@ -329,6 +331,7 @@ func (util *RBDUtil) DetachDisk(c rbdUnmounter, mntPath string) error { ...@@ -329,6 +331,7 @@ func (util *RBDUtil) DetachDisk(c rbdUnmounter, mntPath string) error {
if err = c.mounter.Unmount(mntPath); err != nil { if err = c.mounter.Unmount(mntPath); err != nil {
return fmt.Errorf("rbd detach disk: failed to umount: %s\nError: %v", mntPath, err) return fmt.Errorf("rbd detach disk: failed to umount: %s\nError: %v", mntPath, err)
} }
glog.V(3).Infof("rbd: successfully umount mountpoint %s", mntPath)
// if device is no longer used, see if can unmap // if device is no longer used, see if can unmap
if cnt <= 1 { if cnt <= 1 {
// rbd unmap // rbd unmap
...@@ -343,7 +346,7 @@ func (util *RBDUtil) DetachDisk(c rbdUnmounter, mntPath string) error { ...@@ -343,7 +346,7 @@ func (util *RBDUtil) DetachDisk(c rbdUnmounter, mntPath string) error {
util.defencing(c) util.defencing(c)
} }
glog.Infof("rbd: successfully unmap device %s", device) glog.V(3).Infof("rbd: successfully unmap device %s", device)
} }
return nil return nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment