Skip to content

Commit

Permalink
snapshot: do not restore on offline nodes
Browse files Browse the repository at this point in the history
A node may be offline. Since we select only one node, we should ensure it is
not offline.

Signed-off-by: Moritz Wanzenböck <[email protected]>
  • Loading branch information
WanzenBug authored and rck committed Oct 25, 2024
1 parent 64ad184 commit 4e80adf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed an issue that caused the node publish call to attempt to resize a block volume: block volumes are now never
attempted to be resized.
- Ensure that snapshot restore requests are tried on nodes that are actually available.

## [1.6.3] - 2024-06-28

Expand Down
16 changes: 14 additions & 2 deletions pkg/client/linstor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1317,15 +1317,27 @@ func (s *Linstor) reconcileSnapshotResources(ctx context.Context, snapshot *volu

// Optimize the node we use to restore. It should be one of the preferred nodes, or just the first with a snapshot
// if no preferred nodes match.
selectedNode := snap.Nodes[0]

var selectedNode string
for _, snapNode := range snap.Nodes {
if err := s.NodeAvailable(ctx, snapNode); err != nil {
logger.WithField("selected node candidate", snapNode).WithError(err).Debug("node is not available")
continue
}

if slice.ContainsString(preferredNodes, snapNode) {
// We found a perfect candidate.
selectedNode = snapNode
break
} else if selectedNode == "" {
// Set a fallback if we have no candidate yet.
selectedNode = snapNode
}
}

if selectedNode == "" {
return fmt.Errorf("no node [%s] available for snapshot '%s'", strings.Join(snap.Nodes, ","), snap.Name)
}

logger.WithField("selected node", selectedNode).Debug("restoring snapshot on one node")

restoreConf := lapi.SnapshotRestore{ToResource: targetRD, Nodes: []string{selectedNode}}
Expand Down

0 comments on commit 4e80adf

Please sign in to comment.