Skip to content

Commit

Permalink
feat: disable constituents by default for workload detail performance…
Browse files Browse the repository at this point in the history
… templates (#2598)

* feat: disable constituents by default for workload detail performance templates
  • Loading branch information
rahulguptajss committed Jan 25, 2024
1 parent 9076ffb commit a29e662
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 16 deletions.
39 changes: 33 additions & 6 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/rs/zerolog"
"github.com/tidwall/gjson"
"path"
"regexp"
"strconv"
"strings"
"time"
Expand All @@ -38,6 +39,10 @@ const (
objWorkloadVolumeClass = "autovolume"
)

var (
constituentRegex = regexp.MustCompile(`^(.*)__(\d{4})$`)
)

var qosQuery = "api/cluster/counter/tables/qos"
var qosVolumeQuery = "api/cluster/counter/tables/qos_volume"
var qosDetailQuery = "api/cluster/counter/tables/qos_detail"
Expand Down Expand Up @@ -69,10 +74,11 @@ type counter struct {
}

type perfProp struct {
isCacheEmpty bool
counterInfo map[string]*counter
latencyIoReqd int
qosLabels map[string]string
isCacheEmpty bool
counterInfo map[string]*counter
latencyIoReqd int
qosLabels map[string]string
disableConstituents bool
}

type metricResponse struct {
Expand Down Expand Up @@ -126,7 +132,7 @@ func (r *RestPerf) Init(a *collector.AbstractCollector) error {
return err
}

if err = r.InitQOSLabels(); err != nil {
if err = r.InitQOS(); err != nil {
return err
}

Expand All @@ -137,7 +143,7 @@ func (r *RestPerf) Init(a *collector.AbstractCollector) error {
return nil
}

func (r *RestPerf) InitQOSLabels() error {
func (r *RestPerf) InitQOS() error {
if isWorkloadObject(r.Prop.Query) || isWorkloadDetailObject(r.Prop.Query) {
qosLabels := r.Params.GetChildS("qos_labels")
if qosLabels == nil {
Expand All @@ -155,6 +161,15 @@ func (r *RestPerf) InitQOSLabels() error {
r.perfProp.qosLabels[label] = display
}
}
if counters := r.Params.GetChildS("counters"); counters != nil {
refine := counters.GetChildS("refine")
if refine != nil {
withConstituents := refine.GetChildContentS("with_constituents")
if withConstituents == "false" {
r.perfProp.disableConstituents = true
}
}
}
return nil
}

Expand Down Expand Up @@ -1411,6 +1426,7 @@ func (r *RestPerf) pollInstance(records []gjson.Result, apiD time.Duration) (map
if len(records) == 0 {
return nil, errs.New(errs.ErrNoInstance, "no "+r.Object+" instances on cluster")
}

for _, instanceData := range records {
var (
instanceKey string
Expand All @@ -1421,6 +1437,17 @@ func (r *RestPerf) pollInstance(records []gjson.Result, apiD time.Duration) (map
continue
}

if isWorkloadObject(r.Prop.Query) || isWorkloadDetailObject(r.Prop.Query) {
// The API endpoint api/storage/qos/workloads lacks an is_constituent filter, unlike qos-workload-get-iter. As a result, we must perform client-side filtering.
// Although the api/private/cli/qos/workload endpoint includes this filter, it doesn't provide an option to fetch all records, both constituent and flexgroup types.
if r.perfProp.disableConstituents {
if constituentRegex.MatchString(instanceData.Get("volume").String()) {
// skip constituent
continue
}
}
}

// extract instance key(s)
for _, k := range instanceKeys {
var value gjson.Result
Expand Down
32 changes: 23 additions & 9 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ func (z *ZapiPerf) loadWorkloadClassQuery(defaultValue string) string {

func (z *ZapiPerf) updateWorkloadQuery(query *node.Node) {
// filter -> workload-class takes precedence over workload_class param at root level
// filter -> is-constituent takes precedence over refine -> with_constituents
workloadClass := ""
isConstituent := ""
counters := z.Params.GetChildS("counters")
if counters != nil {
filter := counters.GetChildS("filter")
Expand All @@ -294,20 +296,32 @@ func (z *ZapiPerf) updateWorkloadQuery(query *node.Node) {
if name == "workload-class" {
workloadClass = content
}
if name == "is-constituent" {
isConstituent = content
}
}
}
}
if workloadClass != "" {
return
if workloadClass == "" {
var workloadClassQuery string
if z.Query == objWorkloadVolume || z.Query == objWorkloadDetailVolume {
workloadClassQuery = z.loadWorkloadClassQuery(objWorkloadVolumeClass)
} else {
workloadClassQuery = z.loadWorkloadClassQuery(objWorkloadClass)
}
query.NewChildS("workload-class", workloadClassQuery)
}

var workloadClassQuery string
if z.Query == objWorkloadVolume || z.Query == objWorkloadDetailVolume {
workloadClassQuery = z.loadWorkloadClassQuery(objWorkloadVolumeClass)
} else {
workloadClassQuery = z.loadWorkloadClassQuery(objWorkloadClass)
if isConstituent == "" {
if counters != nil {
refine := counters.GetChildS("refine")
if refine != nil {
isConstituent = refine.GetChildContentS("with_constituents")
if isConstituent == "false" {
query.NewChildS("is-constituent", isConstituent)
}
}
}
}
query.NewChildS("workload-class", workloadClassQuery)
}

// load an int parameter or use defaultValue
Expand Down
3 changes: 2 additions & 1 deletion conf/restperf/9.12.0/workload_detail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ schedule:

counters:
- ^^id
- ^node.name => node
- service_time
- visits
- wait_time
- refine:
- with_constituents: false # The possible values are true or false. Setting this to true will include constituents in the results, while false will exclude them.

resource_map:
CPU_dblade: backend
Expand Down
2 changes: 2 additions & 0 deletions conf/restperf/9.12.0/workload_detail_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ counters:
- service_time
- visits
- wait_time
- refine:
- with_constituents: false # The possible values are true or false. Setting this to true will include constituents in the results, while false will exclude them.

resource_map:
CPU_dblade : backend
Expand Down
2 changes: 2 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload_detail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ counters:
- service_time
- visits
- wait_time
- refine:
- with_constituents: false # The possible values are true or false. Setting this to true will include constituents in the results, while false will exclude them.

resource_map:
CPU_dblade: backend
Expand Down
2 changes: 2 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload_detail_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ counters:
- service_time
- visits
- wait_time
- refine:
- with_constituents: false # The possible values are true or false. Setting this to true will include constituents in the results, while false will exclude them.

resource_map:
CPU_dblade : backend
Expand Down

0 comments on commit a29e662

Please sign in to comment.