Skip to content

Commit

Permalink
PWX-28654 Add quorum member flag to the StorageNode SDK object
Browse files Browse the repository at this point in the history
This field is populated from cluster database's NonQuorumMember field.
Which in turn is calculated in QuorumMember() listener function impl in
PX. It looks at the storage devices in the metadata store.

Signed-off-by: Piyush Nimbalkar <[email protected]>
  • Loading branch information
Piyush Nimbalkar authored and piyush-nimbalkar committed Oct 25, 2023
1 parent 416f35f commit bd3d3ce
Show file tree
Hide file tree
Showing 8 changed files with 3,987 additions and 3,941 deletions.
6 changes: 6 additions & 0 deletions SDK_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

## Releases

### v0.169.0 - (10/24/2023)

* Add quorum member flag to StorageNode

### v0.168.0 - (09/14/2023)

* Add new field cpu cores to api Node

### v0.167.0 - (09/14/2023)

* Add new field verbose to fastpath configuration

### v0.166.0 - (09/01/2023)
Expand Down
6 changes: 5 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"time"

"github.com/golang/protobuf/ptypes"
"github.com/libopenstorage/openstorage/pkg/auth"
"github.com/mohae/deepcopy"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"

"github.com/libopenstorage/openstorage/pkg/auth"
)

// Strings for VolumeSpec
Expand Down Expand Up @@ -281,6 +282,8 @@ type Node struct {
SecurityStatus StorageNode_SecurityStatus
// SchedulerTopology topology information of the node in scheduler context
SchedulerTopology *SchedulerTopology
// Flag indicating whether the node is a quorum member or not
NonQuorumMember bool
}

// FluentDConfig describes ip and port of a fluentdhost.
Expand Down Expand Up @@ -1030,6 +1033,7 @@ func (s *Node) ToStorageNode() *StorageNode {
HWType: s.HWType,
SecurityStatus: s.SecurityStatus,
SchedulerTopology: s.SchedulerTopology,
NonQuorumMember: s.NonQuorumMember,
}

node.Disks = make(map[string]*StorageResource)
Expand Down
7,879 changes: 3,947 additions & 3,932 deletions api/api.pb.go

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,11 @@ message StorageNode {
SecurityStatus security_status = 19;
// Topology information of the node in scheduler context
SchedulerTopology scheduler_topology = 20;
// Flag indicating whether the node is a quorum member or not. Using inverse value
// to handle intialization and upgrades. Node will always be counted as a quorum member
// when initializing until it reaches a point where we can definitely determine whether
// it is a quorum member or not.
bool non_quorum_member = 22;
}

// StorageCluster represents the state and information about the cluster
Expand Down Expand Up @@ -5494,7 +5499,7 @@ message SdkVersion {
// SDK version major value of this specification
Major = 0;
// SDK version minor value of this specification
Minor = 168;
Minor = 169;
// SDK version patch value of this specification
Patch = 0;
}
Expand Down
6 changes: 5 additions & 1 deletion api/server/sdk/api/api.swagger.json

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

11 changes: 9 additions & 2 deletions api/server/sdk/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"testing"
"time"

"github.com/libopenstorage/openstorage/api"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/libopenstorage/openstorage/api"
)

func TestSdkNodeEnumerateNoNodes(t *testing.T) {
Expand Down Expand Up @@ -153,6 +154,7 @@ func TestSdkNodeEnumerateWithFilters(t *testing.T) {
"foo": "bar",
},
},
NonQuorumMember: true,
},
},
}
Expand All @@ -170,6 +172,7 @@ func TestSdkNodeEnumerateWithFilters(t *testing.T) {
"foo": "bar",
},
},
NonQuorumMember: true,
}

s.MockCluster().EXPECT().Enumerate().Return(cluster, nil).Times(1)
Expand Down Expand Up @@ -240,7 +243,8 @@ func TestSdkNodeInspect(t *testing.T) {
NodeLabels: map[string]string{
"hello": "world",
},
HWType: api.HardwareType_VirtualMachine,
HWType: api.HardwareType_VirtualMachine,
NonQuorumMember: true,
}
s.MockCluster().EXPECT().Inspect(nodeid).Return(node, nil).Times(1)

Expand All @@ -265,6 +269,7 @@ func TestSdkNodeInspect(t *testing.T) {
assert.Equal(t, rn.GetAvgLoad(), int64(node.Avgload))
assert.Equal(t, rn.GetStatus(), node.Status)
assert.Equal(t, rn.GetHWType(), node.HWType)
assert.Equal(t, node.NonQuorumMember, rn.NonQuorumMember)

// Check Disk
assert.Len(t, rn.GetDisks(), 2)
Expand Down Expand Up @@ -354,6 +359,7 @@ func TestSdkNodeInspectCurrent(t *testing.T) {
"foo": "bar",
},
},
NonQuorumMember: true,
}

cluster := api.Cluster{
Expand Down Expand Up @@ -385,6 +391,7 @@ func TestSdkNodeInspectCurrent(t *testing.T) {
assert.Equal(t, rn.GetAvgLoad(), int64(node.Avgload))
assert.Equal(t, rn.GetStatus(), node.Status)
assert.Equal(t, rn.GetHWType(), node.HWType)
assert.Equal(t, node.NonQuorumMember, rn.NonQuorumMember)

// Check Disk
assert.Len(t, rn.GetDisks(), 1)
Expand Down
4 changes: 2 additions & 2 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"errors"
"time"

"github.com/libopenstorage/openstorage/pkg/diags"
"github.com/portworx/kvdb"

"github.com/libopenstorage/gossip/types"
"github.com/libopenstorage/openstorage/api"
"github.com/libopenstorage/openstorage/objectstore"
"github.com/libopenstorage/openstorage/osdconfig"
"github.com/libopenstorage/openstorage/pkg/auth"
"github.com/libopenstorage/openstorage/pkg/clusterdomain"
"github.com/libopenstorage/openstorage/pkg/diags"
"github.com/libopenstorage/openstorage/pkg/job"
"github.com/libopenstorage/openstorage/pkg/nodedrain"
sched "github.com/libopenstorage/openstorage/schedpolicy"
"github.com/libopenstorage/openstorage/secrets"
"github.com/portworx/kvdb"
)

const (
Expand Down
9 changes: 7 additions & 2 deletions cluster/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (
"sync/atomic"
"time"

"github.com/portworx/kvdb"
"github.com/sirupsen/logrus"

"github.com/libopenstorage/gossip"
"github.com/libopenstorage/gossip/types"
"github.com/libopenstorage/openstorage/api"
Expand All @@ -36,8 +39,6 @@ import (
sched "github.com/libopenstorage/openstorage/schedpolicy"
"github.com/libopenstorage/openstorage/secrets"
"github.com/libopenstorage/systemutils"
"github.com/portworx/kvdb"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -287,6 +288,7 @@ func (c *ClusterManager) getNodeEntry(nodeID string, clustDBRef *cluster.Cluster
n.NodeLabels = v.NodeLabels
n.HWType = v.HWType
n.SecurityStatus = v.SecurityStatus
n.NonQuorumMember = v.NonQuorumMember
} else {
logrus.Warnf("Could not query NodeID %v", nodeID)
// Node entry won't be refreshed form DB, will use the "offline" original
Expand Down Expand Up @@ -746,6 +748,7 @@ func (c *ClusterManager) joinCluster(
selfNodeEntry.NonQuorumMember =
selfNodeEntry.Status == api.Status_STATUS_DECOMMISSION ||
!c.quorumMember()
c.selfNode.NonQuorumMember = selfNodeEntry.NonQuorumMember
if selfNodeEntry.NonQuorumMember != prevNonQuorumMemberState {
if !selfNodeEntry.NonQuorumMember {
logrus.Infof("This node now participates in quorum decisions")
Expand Down Expand Up @@ -1251,6 +1254,7 @@ func (c *ClusterManager) initListeners(
selfNodeEntry.NonQuorumMember =
selfNodeEntry.Status == api.Status_STATUS_DECOMMISSION ||
!c.quorumMember()
c.selfNode.NonQuorumMember = selfNodeEntry.NonQuorumMember
if !selfNodeEntry.NonQuorumMember {
logrus.Infof("This node participates in quorum decisions")
} else {
Expand Down Expand Up @@ -1638,6 +1642,7 @@ func (c *ClusterManager) nodes(clusterDB *cluster.ClusterInfo) []*api.Node {
node.Hostname = n.Hostname
node.NodeLabels = n.NodeLabels
node.SecurityStatus = n.SecurityStatus
node.NonQuorumMember = n.NonQuorumMember
}
nodes = append(nodes, &node)
}
Expand Down

0 comments on commit bd3d3ce

Please sign in to comment.