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 committed Nov 9, 2024
1 parent 9df3650 commit 35fce04
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 {

Check warning on line 185 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L185

Added line #L185 was not covered by tests
r.RLock()
defer r.RUnlock()
return r.State == types.InstanceStateRunning && r.isRebuilding

Check warning on line 188 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L188

Added line #L188 was not covered by tests
}

func (r *Replica) replicaLvolFilter(bdev *spdktypes.BdevInfo) bool {
if bdev == nil || len(bdev.Aliases) < 1 || bdev.DriverSpecific.Lvol == nil {
return false

Check warning on line 193 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L191-L193

Added lines #L191 - L193 were not covered by tests
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

Check warning on line 261 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L258-L261

Added lines #L258 - L261 were not covered by tests
}
noReplicaLvol := true
for lvolName := range bdevLvolMap {
if IsReplicaLvol(r.Name, lvolName) {
Expand Down

0 comments on commit 35fce04

Please sign in to comment.