Skip to content

Commit

Permalink
Add cpu cores to storage node (#2352)
Browse files Browse the repository at this point in the history
Adds cpu core number as api.Node field for telemetry. 

JIRA: PWX-34038

Signed-off-by: dahuang <[email protected]>
  • Loading branch information
dahuang-purestorage authored Oct 4, 2023
1 parent fa1889f commit da05f16
Show file tree
Hide file tree
Showing 7 changed files with 4,035 additions and 4,009 deletions.
3 changes: 3 additions & 0 deletions SDK_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Releases

### 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

Expand Down
7 changes: 5 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ type Node struct {
SchedulerNodeName string
// Cpu usage of the node.
Cpu float64 // percentage.
// Number of CPU cores
CpuCores int
// Total Memory of the node
MemTotal uint64
// Used Memory of the node
Expand Down Expand Up @@ -336,7 +338,8 @@ type CredUpdateRequest struct {

// StatPoint represents the basic structure of a single Stat reported
// TODO: This is the first step to introduce stats in openstorage.
// Follow up task is to introduce an API for logging stats
//
// Follow up task is to introduce an API for logging stats
type StatPoint struct {
// Name of the Stat
Name string
Expand Down Expand Up @@ -746,7 +749,6 @@ type CapacityUsageResponse struct {
Error error
}

//
// DriverTypeSimpleValueOf returns the string format of DriverType
func DriverTypeSimpleValueOf(s string) (DriverType, error) {
obj, err := simpleValueOf("driver_type", DriverType_value, s)
Expand Down Expand Up @@ -1016,6 +1018,7 @@ func (s *Node) ToStorageNode() *StorageNode {
Id: s.Id,
SchedulerNodeName: s.SchedulerNodeName,
Cpu: s.Cpu,
CpuCores: int64(s.CpuCores),
MemTotal: s.MemTotal,
MemUsed: s.MemUsed,
MemFree: s.MemFree,
Expand Down
8,015 changes: 4,013 additions & 4,002 deletions api/api.pb.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,8 @@ message StorageNode {
string id = 1;
// Cpu usage of the node
double cpu = 2;
// Number of Cpu Cores
int64 cpu_cores = 21;
// Total memory of the node
uint64 mem_total = 3;
// Used memory of the node
Expand Down Expand Up @@ -5492,7 +5494,7 @@ message SdkVersion {
// SDK version major value of this specification
Major = 0;
// SDK version minor value of this specification
Minor = 167;
Minor = 168;
// SDK version patch value of this specification
Patch = 0;
}
Expand Down
7 changes: 6 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.

2 changes: 1 addition & 1 deletion cli/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *clusterClient) status(context *cli.Context) {
}

fmt.Fprintln(w, n.Id, "\t", n.MgmtIp, "\t", status, "\t",
n.Cpu, "\t", humanize.Bytes(n.MemTotal), "\t",
n.Cpu, "\t", n.CpuCores, "\t", humanize.Bytes(n.MemTotal), "\t",
humanize.Bytes(n.MemFree))
}

Expand Down
6 changes: 4 additions & 2 deletions cluster/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"path"
"runtime"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -409,6 +410,7 @@ func (c *ClusterManager) getCurrentState() *api.Node {
c.selfNode.Timestamp = time.Now()

c.selfNode.Cpu, _, _ = c.system.CpuUsage()
c.selfNode.CpuCores = runtime.NumCPU()
c.selfNode.MemTotal, c.selfNode.MemUsed, c.selfNode.MemFree = c.system.MemUsage()
if c.selfNode.HWType == api.HardwareType_UnknownMachine {
c.selfNode.HWType = c.config.HWType
Expand Down Expand Up @@ -2180,13 +2182,13 @@ func (c *ClusterManager) CreateRebalanceSchedule(
return c.storagePoolProvider.CreateRebalanceSchedule(context, request)
}

func (c *ClusterManager) GetRebalanceSchedule(
func (c *ClusterManager) GetRebalanceSchedule(
context context.Context, request *api.SdkGetRebalanceScheduleRequest) (
*api.SdkGetRebalanceScheduleResponse, error) {
return c.storagePoolProvider.GetRebalanceSchedule(context, request)
}

func (c *ClusterManager) DeleteRebalanceSchedule(
func (c *ClusterManager) DeleteRebalanceSchedule(
context context.Context, request *api.SdkDeleteRebalanceScheduleRequest) (
*api.SdkDeleteRebalanceScheduleResponse, error) {
return c.storagePoolProvider.DeleteRebalanceSchedule(context, request)
Expand Down

0 comments on commit da05f16

Please sign in to comment.