Skip to content

Commit

Permalink
fix: server try the best to avoid eliminating broken replicas
Browse files Browse the repository at this point in the history
Signed-off-by: Shuo Wu <[email protected]>
  • Loading branch information
shuo-wu committed Oct 21, 2024
1 parent c14d882 commit bd37078
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkg/spdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package spdk
import (
"fmt"
"net"
"reflect"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -254,17 +255,24 @@ func (s *Server) verify() (err error) {
replicaMapForSync[lvolName] = replicaMap[lvolName]
}
for replicaName, r := range replicaMap {
headSvcLvol := r.Head
if headSvcLvol == nil {
delete(replicaMap, replicaName)
continue
}
// TODO: How to handle a broken replica without a head lvol
if bdevLvolMap[headSvcLvol.Name] == nil {
delete(replicaMap, replicaName)
continue
// Try the best to avoid eliminating broken replicas without a head lvol
if r.Head == nil || bdevLvolMap[r.Head.Name] == nil {
noReplicaLvol := true
for lvolName := range bdevLvolMap {
if IsReplicaLvol(r.Name, lvolName) {
noReplicaLvol = false
break
}
}
if noReplicaLvol {
delete(replicaMap, replicaName)
continue
}
}
}
if !reflect.DeepEqual(s.replicaMap, replicaMap) {
logrus.Infof("spdk gRPC server: Updating replica map from %+v to %+v", s.replicaMap, replicaMap)
}
s.replicaMap = replicaMap
s.Unlock()

Expand Down

0 comments on commit bd37078

Please sign in to comment.