mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-30 10:10:21 +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>
(cherry picked from commit 35324b2e17
)
This commit is contained in:
parent
8997a1bbdb
commit
e42552dd2f
@ -128,3 +128,24 @@ func (ri *rbdImage) getImageMirroringStatus() (*librbd.GlobalMirrorImageStatus,
|
||||
|
||||
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