Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom object template - panic if counter list item indent differs #704

Closed
mamoep opened this issue Nov 26, 2021 · 2 comments · Fixed by #710
Closed

Custom object template - panic if counter list item indent differs #704

mamoep opened this issue Nov 26, 2021 · 2 comments · Fixed by #710
Labels
bug Something isn't working status/done

Comments

@mamoep
Copy link

mamoep commented Nov 26, 2021

Describe the bug
I tried to create a custom object template via ansible with {{ item | to_nice_yaml(indent=2) }}. The generated output is valid yaml, but the list items under counter: are not indented as documented for harvest.

Example template (failing):

name: NetPort
object: net_port
query: net-port-get-iter
counters:
  net-port-info:
  - ^broadcast-domain => broadcast_domain
  - ^ifgrp-distribution-function => ifgrp_dist_func
  - ^ifgrp-mode => ifgrp_mode
  - ^ifgrp-port => ifgrp_port
  - ^is-administrative-up => admin_up
  - ^link-status => link_status
  - ^^node => node
  - ^operational-duplex => op_duplex
  - ^operational-speed => op_speed
  - ^^port => port
  - ^port-type => port_type
  - ^role => role
  - ^vlan-id => vlan_id
  - ^vlan-node => vlan_node
  - ^vlan-port => vlan_port
collect_only_labels: true
export_options:
  include_all_labels: true
plugins:
  LabelAgent:
    value_to_num: status link_status up up `0`

Example template (working):

name:   NetPort
query:  net-port-get-iter
object: net_port
counters:
  net-port-info:
    - ^broadcast-domain => broadcast_domain
    - ^ifgrp-distribution-function => ifgrp_dist_func
    - ^ifgrp-mode => ifgrp_mode
    - ^ifgrp-port => ifgrp_port
    - ^is-administrative-up => admin_up
    - ^link-status => link_status
    - ^^node => node
    - ^operational-duplex => op_duplex
    - ^operational-speed => op_speed
    - ^^port => port
    - ^port-type => port_type
    - ^role => role
    - ^vlan-id => vlan_id
    - ^vlan-node => vlan_node
    - ^vlan-port => vlan_port
collect_only_labels: true
plugins:
  LabelAgent:
    value_to_num: status link_status up up `0`
export_options:
  include_all_labels: true

Environment
Provide accurate information about the environment to help us reproduce the issue.

  • Harvest version: harvest version 21.11.0-1 (commit 66c5ce1) (build date 2021-11-08T08:32:01-0500) linux/amd64
  • Command line arguments used: bin/harvest start
  • OS: RHEL 7.9
  • Install method: rhel

To Reproduce
Steps to reproduce the behavior:
define custom template as described above

Expected behavior
Collect defined custom metrics

Actual behavior
Template is not picked up and metrics dont get collected

Possible solution, workaround, fix
Indent counter list entries.

Additional context
Log output

"level":"error","Poller":"clustername","collector":"Zapi:NetPort",
  "stack":[
    {"func":"New","line":"35","source":"errors.go"},
    {"func":"(*AbstractCollector).Start.func1","line":"259","source":"collector.go"},
    {"func":"gopanic","line":"1038","source":"panic.go"},
    {"func":"goPanicIndex","line":"90","source":"panic.go"},
    {"func":"(*Node).SearchChildren.func1","line":"438","source":"node.go"},
    {"func":"(*Node).SearchChildren","line":"452","source":"node.go"},
    {"func":"(*Zapi).PollInstance","line":"268","source":"zapi.go"},
    {"func":"(*task).Run","line":"61","source":"schedule.go"},
    {"func":"(*AbstractCollector).Start","line":"293","source":"collector.go"},
    {"func":"goexit","line":"1581","source":"asm_amd64.s"}
    ],
  "error":"goroutine panic => goroutine 504 [running]:\n
    runtime/debug.Stack()\n\t
    runtime/debug/stack.go:24 +0x65\ngoharvest2/cmd/poller/collector.(*AbstractCollector).Start.func1()\n\t
    goharvest2/cmd/poller/collector/collector.go:259 +0x85\n
    panic({0x98e6c0, 0xc0004be5b8})\n\t
    runtime/panic.go:1038 +0x215\n
    goharvest2/pkg/tree/node.(*Node).SearchChildren.func1(0xc000c79290, {0xe44d78, 0x0, 0x0})\n\t
    goharvest2/pkg/tree/node/node.go:438 +0x485\ngoharvest2/pkg/tree/node.(*Node).SearchChildren(0x9b2240, {0xe44d78, 0x0, 0x0})\n\t
    goharvest2/pkg/tree/node/node.go:452 +0xd9\ngoharvest2/cmd/collectors/zapi/collector.(*Zapi).PollInstance(0xc00012f400)\n\t
    goharvest2/cmd/collectors/zapi/collector/zapi.go:268 +0x4e5\n
    goharvest2/cmd/poller/schedule.(*task).Run(0xc0001f22d0)\n\t
    goharvest2/cmd/poller/schedule/schedule.go:61 +0x4e\n
    goharvest2/cmd/poller/collector.(*AbstractCollector).Start(0xc0000f4b60, 0xe13d50)\n\t
    goharvest2/cmd/poller/collector/collector.go:293 +0x40a\n
    created by main.(*Poller).Start\n\t
    ./poller.go:394 +0x2e5\n",
  "caller":"goharvest2/cmd/poller/collector/collector.go:259",
  "time":"2021-11-26T10:32:23+01:00",
  "message":"Collector panicked runtime error: index out of range [0] with length 0"
@rahulguptajss
Copy link
Contributor

@mamoep Thanks for reporting it. We are aware of this issue. We'll look into solving it.

@rahulguptajss rahulguptajss added bug Something isn't working and removed status/needs-triage labels Nov 26, 2021
cgrinds added a commit that referenced this issue Nov 29, 2021
cgrinds added a commit that referenced this issue Nov 29, 2021
cgrinds added a commit that referenced this issue Nov 30, 2021
* fix: improve template yaml parsing

Fixes #704

* fix: invalid yaml in testcases
* fix: remove earlier yaml parser
@cgrinds cgrinds self-assigned this Feb 10, 2022
@cgrinds
Copy link
Collaborator

cgrinds commented Feb 10, 2022

Verified using mamoep included failing netport.yaml. Poller starts and collects without error.
Verified on release/22.02.0 3d038fe

bin/harvest start u2 --foreground --collectors Zapi --objects NetPort
starting in foreground, enter CTRL+C or close terminal to stop poller
2:26PM INF ./poller.go:182 > log level used: info Poller=u2
2:26PM INF ./poller.go:183 > options config: ./harvest.yml Poller=u2
2:26PM INF ./poller.go:220 > started in foreground [pid=84870] Poller=u2
2:26PM INF goharvest2/cmd/poller/collector/helpers.go:122 > best-fit template [conf/zapi/cdot/9.8.0/netport.yaml] for [9.7.0] Poller=u2 collector=Zapi:NetPort
2:26PM INF ./poller.go:344 > Autosupport scheduled. Poller=u2 asupSchedule=24h
2:26PM INF ./poller.go:353 > poller start-up complete Poller=u2
2:26PM INF ./poller.go:501 > updated status, up collectors: 1 (of 1), up exporters: 1 (of 1) Poller=u2

@cgrinds cgrinds removed their assignment May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status/done
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants