Skip to content

Commit

Permalink
core: retry other pvc if active client not found
Browse files Browse the repository at this point in the history
retry other cephfs/rbd pvc if there
are no active clients found on ceph cluster.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Feb 14, 2024
1 parent eb97390 commit 4f23c17
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pkg/operator/ceph/cluster/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package cluster
import (
"context"
"encoding/json"
stderrors "errors"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -54,6 +55,7 @@ type clientCluster struct {
var (
nodesCheckedForReconcile = sets.New[string]()
networkFenceLabel = "cephClusterUID"
errActiveClientNotFound = stderrors.New("active client not found")
)

// drivers that supports fencing, used in naming networkFence object
Expand Down Expand Up @@ -243,6 +245,10 @@ func (c *clientCluster) fenceNode(ctx context.Context, node *corev1.Node, cluste
if err == nil {
break
}
// continue to fence next rbd volume if active client not found
if stderrors.Is(err, errActiveClientNotFound) {
continue
}

if i == len(rbdPVList)-1 {
return pkgerror.Wrapf(err, "failed to fence rbd volumes")
Expand Down Expand Up @@ -275,6 +281,10 @@ func (c *clientCluster) fenceNode(ctx context.Context, node *corev1.Node, cluste
break
}

// continue to fence next rbd volume if active client not found
if stderrors.Is(err, errActiveClientNotFound) {
continue
}
if i == len(cephFSPVList)-1 {
return pkgerror.Wrapf(err, "failed to fence cephFS volumes")
}
Expand Down Expand Up @@ -401,11 +411,14 @@ func (c *clientCluster) fenceRbdImage(
if err != nil {
return pkgerror.Wrapf(err, "failed to unmarshal rbd status output")
}
if len(ips) != 0 {
err = c.createNetworkFence(ctx, rbdPV, node, cluster, ips, rbdDriver)
if err != nil {
return pkgerror.Wrapf(err, "failed to create network fence for node %q", node.Name)
}
if len(ips) == 0 {
logger.Infof("no active rbd clients found for rbd volume %q", rbdPV.Name)
return errActiveClientNotFound

}
err = c.createNetworkFence(ctx, rbdPV, node, cluster, ips, rbdDriver)
if err != nil {
return pkgerror.Wrapf(err, "failed to create network fence for node %q", node.Name)
}

return nil
Expand Down Expand Up @@ -444,7 +457,7 @@ func (c *clientCluster) fenceCephFSVolume(

if len(ips) == 0 {
logger.Infof("no active mds clients found for cephfs volume %q", cephFSPV.Name)
return nil
return errActiveClientNotFound
}

err = c.createNetworkFence(ctx, cephFSPV, node, cluster, ips, cephfsDriver)
Expand Down

0 comments on commit 4f23c17

Please sign in to comment.