Skip to content

Commit

Permalink
PWX-39064: Allow force option to be passed to CanNodeRemove (libopens…
Browse files Browse the repository at this point in the history
…torage#2485)

Signed-off-by: Priyanshu Pandey <[email protected]>
  • Loading branch information
pp511 authored Sep 20, 2024
1 parent 24e88ce commit 6a0a59b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ type ClusterListenerNodeOps interface {
CanNodeJoin(node *api.Node, clusterInfo *ClusterInfo, nodeInitialized bool) error

// CanNodeRemove test to see if we can remove this node
CanNodeRemove(node *api.Node) (string, error)
CanNodeRemove(node *api.Node, forceRemove bool) (string, error)

// MarkNodeForRemoval instructs the listeners that the ClusterManager
// is going ahead with the node removal. The API does not expect any
Expand Down Expand Up @@ -481,7 +481,7 @@ func (nc *NullClusterListener) Remove(node *api.Node, forceRemove bool) error {
return nil
}

func (nc *NullClusterListener) CanNodeRemove(node *api.Node) (string, error) {
func (nc *NullClusterListener) CanNodeRemove(node *api.Node, forceRemove bool) (string, error) {
return "", nil
}

Expand Down
2 changes: 1 addition & 1 deletion cluster/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ func (c *ClusterManager) Remove(nodes []api.Node, forceRemove bool) error {
logrus.Infof("Remove node: ask cluster listener: "+
"can we remove node ID %s, %s",
nodes[i].Id, e.Value.(cluster.ClusterListener).String())
additionalMsg, err := e.Value.(cluster.ClusterListener).CanNodeRemove(&nodes[i])
additionalMsg, err := e.Value.(cluster.ClusterListener).CanNodeRemove(&nodes[i], forceRemove)
if err != nil && !(err == cluster.ErrRemoveCausesDataLoss && forceRemove) {
msg := fmt.Sprintf("Cannot remove node ID %s: %s.", nodes[i].Id, err)
if additionalMsg != "" {
Expand Down
8 changes: 4 additions & 4 deletions cluster/mock/cluster_listener.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a0a59b

Please sign in to comment.