Skip to content

Commit

Permalink
fix: prevent nil dereference when updating replica mode ERR
Browse files Browse the repository at this point in the history
longhorn/longhorn-9852

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang authored and derekbit committed Dec 3, 2024
1 parent bfa1d21 commit 46dd200
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/spdk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,10 @@ func (e *Engine) ReplicaAdd(spdkClient *spdkclient.Client, dstReplicaName, dstRe
}
}
if engineErr != nil || err != nil {
e.log.WithError(err).Errorf("Engine failed to start replica %s rebuilding, will mark the rebuilding replica mode from %v to ERR", dstReplicaName, e.ReplicaStatusMap[dstReplicaName].Mode)
e.ReplicaStatusMap[dstReplicaName].Mode = types.ModeERR
if e.ReplicaStatusMap[dstReplicaName] != nil && e.ReplicaStatusMap[dstReplicaName].Mode != types.ModeERR {
e.log.WithError(err).Errorf("Engine failed to start replica %s rebuilding, will mark the rebuilding replica mode from %v to ERR", dstReplicaName, e.ReplicaStatusMap[dstReplicaName].Mode)
e.ReplicaStatusMap[dstReplicaName].Mode = types.ModeERR
}
updateRequired = true
}
}()
Expand Down

0 comments on commit 46dd200

Please sign in to comment.