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:
Madhu Rajanna 2021-10-25 15:58:37 +05:30 committed by mergify[bot]
parent c41bf37b95
commit ca4bf66035

View File

@ -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,16 +511,15 @@ func (rs *ReplicationServer) DemoteVolume(ctx context.Context,
func checkRemoteSiteStatus(ctx context.Context, mirrorStatus *librbd.GlobalMirrorImageStatus) bool {
ready := true
for _, s := range mirrorStatus.SiteStatuses {
util.UsefulLog(
ctx,
"peer site mirrorUUID=%s, mirroring state=%s, description=%s and lastUpdate=%s",
s.MirrorUUID,
s.State.String(),
s.Description,
s.LastUpdate)
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",
s.MirrorUUID,
s.State.String(),
s.Description,
s.LastUpdate)
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
}