mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rbd: log the remote site details during resync
logging the remote site details during resyncing
for better debugging.
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit b92a6f5ccb
)
This commit is contained in:
parent
c41bf37b95
commit
ca4bf66035
@ -43,18 +43,6 @@ const (
|
||||
imageMirrorModeSnapshot imageMirroringMode = "snapshot"
|
||||
)
|
||||
|
||||
// imageMirroringState represents the image mirroring state.
|
||||
type imageMirroringState string
|
||||
|
||||
const (
|
||||
// If the state is unknown means the rbd-mirror daemon is
|
||||
// running and the image is demoted on both the clusters.
|
||||
unknown imageMirroringState = "unknown"
|
||||
|
||||
// If the state is error means image need resync.
|
||||
errorState imageMirroringState = "error"
|
||||
)
|
||||
|
||||
const (
|
||||
// mirroringMode + key to get the imageMirroringMode from parameters.
|
||||
imageMirroringKey = "mirroringMode"
|
||||
@ -523,8 +511,6 @@ func (rs *ReplicationServer) DemoteVolume(ctx context.Context,
|
||||
func checkRemoteSiteStatus(ctx context.Context, mirrorStatus *librbd.GlobalMirrorImageStatus) bool {
|
||||
ready := true
|
||||
for _, s := range mirrorStatus.SiteStatuses {
|
||||
if s.MirrorUUID != "" {
|
||||
if imageMirroringState(s.State.String()) != unknown && !s.Up {
|
||||
util.UsefulLog(
|
||||
ctx,
|
||||
"peer site mirrorUUID=%s, mirroring state=%s, description=%s and lastUpdate=%s",
|
||||
@ -532,7 +518,8 @@ func checkRemoteSiteStatus(ctx context.Context, mirrorStatus *librbd.GlobalMirro
|
||||
s.State.String(),
|
||||
s.Description,
|
||||
s.LastUpdate)
|
||||
|
||||
if s.MirrorUUID != "" {
|
||||
if s.State != librbd.MirrorImageStatusStateUnknown && !s.Up {
|
||||
ready = false
|
||||
}
|
||||
}
|
||||
@ -619,7 +606,16 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
|
||||
|
||||
return nil, fmt.Errorf("failed to get local status: %w", err)
|
||||
}
|
||||
state := imageMirroringState(localStatus.State.String())
|
||||
|
||||
// convert the last update time to UTC
|
||||
lastUpdateTime := time.Unix(localStatus.LastUpdate, 0).UTC()
|
||||
util.UsefulLog(
|
||||
ctx,
|
||||
"local image mirroring state=%s, description=%s and lastUpdate=%s",
|
||||
localStatus.State.String(),
|
||||
localStatus.Description,
|
||||
lastUpdateTime)
|
||||
|
||||
// To recover from split brain (up+error) state the image need to be
|
||||
// demoted and requested for resync on site-a and then the image on site-b
|
||||
// should be demoted. The volume should be marked to ready=true when the
|
||||
@ -630,17 +626,9 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
|
||||
// If the image state on both the sites are up+unknown consider that
|
||||
// complete data is synced as the last snapshot
|
||||
// gets exchanged between the clusters.
|
||||
if state == unknown && localStatus.Up {
|
||||
if localStatus.State == librbd.MirrorImageStatusStateUnknown && localStatus.Up {
|
||||
ready = checkRemoteSiteStatus(ctx, mirrorStatus)
|
||||
}
|
||||
// convert the last update time to UTC
|
||||
lastUpdateTime := time.Unix(localStatus.LastUpdate, 0).UTC()
|
||||
util.UsefulLog(
|
||||
ctx,
|
||||
"image mirroring state=%s, description=%s and lastUpdate=%s",
|
||||
localStatus.State.String(),
|
||||
localStatus.Description,
|
||||
lastUpdateTime)
|
||||
|
||||
if resyncRequired(localStatus) {
|
||||
err = rbdVol.resyncImage()
|
||||
@ -696,7 +684,7 @@ func resyncRequired(localStatus librbd.SiteMirrorImageStatus) bool {
|
||||
// be in an error state. It would be also worth considering the `description`
|
||||
// field to make sure about split-brain.
|
||||
splitBrain := "split-brain"
|
||||
if strings.Contains(localStatus.State.String(), string(errorState)) ||
|
||||
if localStatus.State == librbd.MirrorImageStatusStateError ||
|
||||
strings.Contains(localStatus.Description, splitBrain) {
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user