Skip to content

Commit

Permalink
feat(v2/auto-salvage): stop expose bdev before start
Browse files Browse the repository at this point in the history
longhorn/longhorn-8430

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Nov 6, 2024
1 parent 675b1fd commit 415584c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/spdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,17 @@ func (r *Replica) Create(spdkClient *spdkclient.Client, portCount int32, superio
}
r.portAllocator = bitmap

nqn := helpertypes.GetNQN(r.Name)

// Blindly stop exposing the bdev if it exists. This is to avoid potential inconsistencies during salvage case.
if err := spdkClient.StopExposeBdev(nqn); err != nil && !jsonrpc.IsJSONRPCRespErrorNoSuchDevice(err) {
return nil, errors.Wrapf(err, "failed to stop expose replica %v", r.Name)
}

nguid := commonutils.RandomID(nvmeNguidLength)
if err := spdkClient.StartExposeBdev(helpertypes.GetNQN(r.Name), headSvcLvol.UUID, nguid, podIP, strconv.Itoa(int(r.PortStart))); err != nil {
return nil, err

if err := spdkClient.StartExposeBdev(nqn, headSvcLvol.UUID, nguid, podIP, strconv.Itoa(int(r.PortStart))); err != nil {
return nil, errors.Wrapf(err, "failed to expose replica %v", r.Name)
}
r.IsExposed = true
r.State = types.InstanceStateRunning
Expand Down

0 comments on commit 415584c

Please sign in to comment.