Uploaded image for project: 'Red Hat OpenStack Services on OpenShift'
  1. Red Hat OpenStack Services on OpenShift
  2. OSPRH-5573

observabilityclient cli table formatter doesn't work for metrics with varying number of labels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • openstack-aodh
    • None
    • 1
    • False
    • Hide

      None

      Show
      None
    • False
    • ?
    • ?
    • ?
    • ?
    • 2
    • CloudOps 2024 Sprint 7
    • Low
    • CloudOps

      The following command wouldn't work when using the default table formatter:

      [stack@osp-cloudops-03 ~]$ oc rsh openstackclient-sample openstack metric show up --disable-rbac --format value
      up alertmanager web 10.217.0.180:9093 alertmanager-self openstack alertmanager-metric-storage-0 metric-storage-alertmanager 1
      up prometheus web 10.217.1.51:9090 prometheus-self openstack prometheus-metric-storage-0 metric-storage-prometheus 1
      up proxy-httpd 10.217.1.53:3000 ceilometer-internal openstack ceilometer-0 ceilometer-internal 1
      up 192.168.122.100:9100 scrapeConfig/openstack/metric-storage-tls 1
      up 192.168.122.101:9100 scrapeConfig/openstack/metric-storage-tls 1

      The way the code works right now when using the table formatter is, that it'll go from the first line and create the headers for each column from that. This works when all of the metrics have the same labels. You can see in the output, that the rows at the bottom have less labels, which ends up in the following error:

      [stack@osp-cloudops-03 ~]$ oc rsh openstackclient-sample openstack --debug metric show up --disable-rbac
      ...
      http://metric-storage-prometheus.openstack.svc:9090 "GET /api/v1/query?query=last_over_time%28up%5B5m%5D%29 HTTP/1.1" 200 350
      Row has incorrect number of values, (actual) 8!=9 (expected)
      Traceback (most recent call last):
        File "/usr/lib/python3.9/site-packages/cliff/app.py", line 410, in run_subcommand
          result = cmd.run(parsed_args)
        File "/usr/lib/python3.9/site-packages/osc_lib/command/command.py", line 39, in run
          return super(Command, self).run(parsed_args)
        File "/usr/lib/python3.9/site-packages/cliff/display.py", line 120, in run
          self.produce_output(parsed_args, column_names, data)
        File "/usr/lib/python3.9/site-packages/cliff/lister.py", line 122, in produce_output
          self.formatter.emit_list(
        File "/usr/lib/python3.9/site-packages/cliff/formatters/table.py", line 96, in emit_list
          self.add_rows(x, column_names, data)
        File "/usr/lib/python3.9/site-packages/cliff/formatters/table.py", line 85, in add_rows
          table.add_row(_format_row(row))
        File "/usr/lib/python3.9/site-packages/prettytable.py", line 818, in add_row
          raise Exception("Row has incorrect number of values, (actual) %d!=%d (expected)" %(len(row),len(self._field_names)))
      Exception: Row has incorrect number of values, (actual) 8!=9 (expected)
      clean_up Show: Row has incorrect number of values, (actual) 8!=9 (expected)

            rh-ee-jwysogla Jaromir Wysoglad
            rh-ee-jwysogla Jaromir Wysoglad
            rhos-dfg-cloudops
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: