Skip to content

Commit

Permalink
fix: handled non exported qtrees in template (#3107)
Browse files Browse the repository at this point in the history
* fix: handled non exported qtrees in template
  • Loading branch information
cgrinds authored Aug 14, 2024
1 parent 8faaeba commit 8213a69
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 26 deletions.
5 changes: 2 additions & 3 deletions cmd/collectors/zapi/plugins/qtree/qtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (q *Qtree) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.
request, response *node.Node
quotas []*node.Node
ad, pd time.Duration // Request/API time, Parse time, Fetch time
err error
numMetrics int
)

Expand Down Expand Up @@ -177,8 +176,8 @@ func (q *Qtree) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.
quotaIndex := 0

for {
responseData := q.client.InvokeBatchRequest(request, tag, q.testFilePath)
if responseData.Err != nil {
responseData, err := q.client.InvokeBatchRequest(request, tag, q.testFilePath)
if err != nil {
return nil, nil, err
}
response = responseData.Result
Expand Down
10 changes: 4 additions & 6 deletions cmd/collectors/zapiperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ func (d *Disk) getDisks() error {
var (
result *node.Node
disks []*node.Node
err error
)

query := "storage-disk-get-iter"
Expand All @@ -456,8 +455,8 @@ func (d *Disk) getDisks() error {
request.AddChild(desired)

for {
responseData := d.client.InvokeBatchRequest(request, tag, "")
if responseData.Err != nil {
responseData, err := d.client.InvokeBatchRequest(request, tag, "")
if err != nil {
return err
}
result = responseData.Result
Expand Down Expand Up @@ -530,7 +529,6 @@ func (d *Disk) getAggregates() error {
var (
result *node.Node
aggrs []*node.Node
err error
)

query := "aggr-get-iter"
Expand All @@ -551,8 +549,8 @@ func (d *Disk) getAggregates() error {
request.AddChild(desired)

for {
responseData := d.client.InvokeBatchRequest(request, tag, "")
if responseData.Err != nil {
responseData, err := d.client.InvokeBatchRequest(request, tag, "")
if err != nil {
return err
}
result = responseData.Result
Expand Down
5 changes: 2 additions & 3 deletions cmd/collectors/zapiperf/plugins/flexcache/flexcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (f *FlexCache) getFlexCaches() (*set.Set, error) {
result *node.Node
flexCaches []*node.Node
flexCacheSet *set.Set
err error
)

flexCacheSet = set.New()
Expand All @@ -87,8 +86,8 @@ func (f *FlexCache) getFlexCaches() (*set.Set, error) {
request.AddChild(desired)

for {
responseData := f.client.InvokeBatchRequest(request, tag, "")
if responseData.Err != nil {
responseData, err := f.client.InvokeBatchRequest(request, tag, "")
if err != nil {
return nil, err
}
result = responseData.Result
Expand Down
5 changes: 2 additions & 3 deletions cmd/collectors/zapiperf/plugins/volumetag/volumetag.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func (v *VolumeTag) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *u
var (
result *node.Node
volumes []*node.Node
err error
)

data := dataMap[v.Object]
Expand All @@ -58,8 +57,8 @@ func (v *VolumeTag) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *u
request.AddChild(desired)

for {
responseData := v.client.InvokeBatchRequest(request, tag, "")
if responseData.Err != nil {
responseData, err := v.client.InvokeBatchRequest(request, tag, "")
if err != nil {
return nil, nil, err
}
result = responseData.Result
Expand Down
8 changes: 4 additions & 4 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1556,11 +1556,9 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {

for {
apiT = time.Now()
responseData := z.Client.InvokeBatchRequest(request, batchTag, z.testFilePath)
results = responseData.Result
batchTag = responseData.Tag
responseData, err := z.Client.InvokeBatchRequest(request, batchTag, z.testFilePath)

if responseData.Err != nil {
if err != nil {
if errors.Is(err, errs.ErrAPIRequestRejected) {
z.Logger.Info().
Str("request", request.GetNameS()).
Expand All @@ -1576,6 +1574,8 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {
break
}

results = responseData.Result
batchTag = responseData.Tag
apiD += time.Since(apiT)
parseT = time.Now()

Expand Down
13 changes: 6 additions & 7 deletions pkg/api/ontapi/zapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type Response struct {
Tag string
Rd time.Duration
Pd time.Duration
Err error
}

func New(poller *conf.Poller, c *auth.Credentials) (*Client, error) {
Expand Down Expand Up @@ -264,8 +263,8 @@ func (c *Client) invokeZapi(request *node.Node, handle func([]*node.Node) error)
err error
)

responseData := c.InvokeBatchRequest(request, tag, "")
if responseData.Err != nil {
responseData, err := c.InvokeBatchRequest(request, tag, "")
if err != nil {
return err
}
result = responseData.Result
Expand Down Expand Up @@ -333,17 +332,17 @@ func (c *Client) Invoke(testFilePath string) (*node.Node, error) {
// Else -> will issue API requests in series, once there
// are no more instances returned by the server, returned results will be nil
// Use the returned tag for subsequent calls to this method
func (c *Client) InvokeBatchRequest(request *node.Node, tag string, testFilePath string) Response {
func (c *Client) InvokeBatchRequest(request *node.Node, tag string, testFilePath string) (Response, error) {
if testFilePath != "" && tag != "" {
testData, err := tree.ImportXML(testFilePath)
if err != nil {
return Response{Result: nil, Tag: "", Rd: time.Second, Pd: time.Second, Err: err}
return Response{}, err
}
return Response{Result: testData, Tag: "", Rd: time.Second, Pd: time.Second, Err: nil}
return Response{Result: testData, Tag: "", Rd: time.Second, Pd: time.Second}, nil
}
// wasteful of course, need to rewrite later @TODO
results, tag, rd, pd, err := c.InvokeBatchWithTimers(request, tag)
return Response{Result: results, Tag: tag, Rd: rd, Pd: pd, Err: err}
return Response{Result: results, Tag: tag, Rd: rd, Pd: pd}, err
}

// InvokeBatchWithTimers does the same as InvokeBatchRequest, but it also
Expand Down

0 comments on commit 8213a69

Please sign in to comment.