mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: add helper function to get local state
added helper function to check the local image state is up+replaying. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
3462cd9bbd
commit
35324b2e17
@ -128,3 +128,24 @@ func (ri *rbdImage) getImageMirroringStatus() (*librbd.GlobalMirrorImageStatus,
|
|||||||
|
|
||||||
return &statusInfo, nil
|
return &statusInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getLocalState returns the local state of the image.
|
||||||
|
func (ri *rbdImage) getLocalState() (librbd.SiteMirrorImageStatus, error) {
|
||||||
|
localStatus := librbd.SiteMirrorImageStatus{}
|
||||||
|
image, err := ri.open()
|
||||||
|
if err != nil {
|
||||||
|
return localStatus, fmt.Errorf("failed to open image %q with error: %w", ri, err)
|
||||||
|
}
|
||||||
|
defer image.Close()
|
||||||
|
|
||||||
|
statusInfo, err := image.GetGlobalMirrorStatus()
|
||||||
|
if err != nil {
|
||||||
|
return localStatus, fmt.Errorf("failed to get image mirroring status %q with error: %w", ri, err)
|
||||||
|
}
|
||||||
|
localStatus, err = statusInfo.LocalStatus()
|
||||||
|
if err != nil {
|
||||||
|
return localStatus, fmt.Errorf("failed to get local status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return localStatus, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user