Skip to content

Commit

Permalink
fix: avoid eliminating rebuilding replicas without heads
Browse files Browse the repository at this point in the history
Signed-off-by: Shuo Wu <[email protected]>
  • Loading branch information
shuo-wu authored and derekbit committed Nov 16, 2024
1 parent be17c30 commit f09c9b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/spdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ func NewReplica(ctx context.Context, replicaName, lvsName, lvsUUID string, specS
}
}

func (r *Replica) IsRebuilding() bool {
r.RLock()
defer r.RUnlock()
return r.State == types.InstanceStateRunning && r.isRebuilding
}

func (r *Replica) replicaLvolFilter(bdev *spdktypes.BdevInfo) bool {
if bdev == nil || len(bdev.Aliases) < 1 || bdev.DriverSpecific.Lvol == nil {
return false
Expand Down
5 changes: 4 additions & 1 deletion pkg/spdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ func (s *Server) verify() (err error) {
replicaMapForSync[lvolName] = replicaMap[lvolName]
}
for replicaName, r := range replicaMap {
// Try the best to avoid eliminating broken replicas without a head lvol
// Try the best to avoid eliminating broken replicas or rebuilding replicas without head lvols
if bdevLvolMap[r.Name] == nil {
if r.IsRebuilding() {
continue
}
noReplicaLvol := true
for lvolName := range bdevLvolMap {
if IsReplicaLvol(r.Name, lvolName) {
Expand Down

0 comments on commit f09c9b9

Please sign in to comment.