Skip to content

Commit

Permalink
fix(replica): reconstruct ActiveChain and SnapshotLvolMap while creat…
Browse files Browse the repository at this point in the history
…ing replica

If a replica's ActiveChain is not constructed while creating it, the mismatch
found by the validateAndUpdate() will result in the error state.

```
....
	newSnapshotLvolMap, err := constructSnapshotLvolMap(r.Name, bdevLvolMap)
	if err != nil {
		return err
	}
	if len(r.SnapshotLvolMap) != len(newSnapshotLvolMap) {
		return fmt.Errorf("replica current active snapshot ....")
	}
...
````

Longhorn 10033

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Dec 25, 2024
1 parent 2b38157 commit 387771b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/spdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (r *Replica) construct(bdevLvolMap map[string]*spdktypes.BdevInfo) (err err
}()

switch r.State {
case types.InstanceStatePending:
case types.InstanceStateStopped, types.InstanceStatePending:
break
case types.InstanceStateRunning:
if r.isRebuilding {
Expand Down Expand Up @@ -735,6 +735,16 @@ func (r *Replica) Create(spdkClient *spdkclient.Client, portCount int32, superio
if err := r.prepareHead(spdkClient, backingImage); err != nil {
return nil, err
}

// Construct the snapshot lvol map and the active chain
bdevLvolMap, err := GetBdevLvolMapWithFilter(spdkClient, r.replicaLvolFilter)
if err != nil {
return nil, err
}
if err := r.construct(bdevLvolMap); err != nil {
return nil, err
}

r.State = types.InstanceStateStopped

podIP, err := commonnet.GetIPForPod()
Expand Down

0 comments on commit 387771b

Please sign in to comment.