esunar / test4

GNU General Public License v3.0
0 stars 0 forks source link

KeyError for 'machine-status' while lint against juju status oputput from python-libjuju #162

Closed esunar closed 1 year ago

esunar commented 1 year ago

ouput from model.get_status in python-libjuju doesn't have machine-status in it, while juju status --format json does. Using it for juju-lint will fail with KeyError:

2020-01-22 07:28:59 [ERROR] OpenStack charm 'openstack-dashboard' not found
Traceback (most recent call last):
  File "/usr/bin/juju-lint", line 11, in <module>
    load_entry_point('juju-lint===1.0.0.dev2-201910310005-ubuntu18.04.1', 'console_scripts', 'juju-lint')()
  File "/usr/lib/python3/dist-packages/jujulint.py", line 453, in main
    lint(filename, lint_rules)
  File "/usr/lib/python3/dist-packages/jujulint.py", line 421, in lint
    check_statuses(j, applications)
  File "/usr/lib/python3/dist-packages/jujulint.py", line 340, in check_statuses
    check_status_pair(machine_name, "machine", juju_status["machines"][machine_name])
  File "/usr/lib/python3/dist-packages/jujulint.py", line 330, in check_status_pair
    check_status("%s %s" % (status_type.title(), name), data_d[primary],
KeyError: 'machine-status'
juju-lint failed with the following error: Command '['juju-lint', '--config', '/usr/share/juju-lint/contrib/canonical-openstack-rules.yaml', '--override-subordinate', '', '--loglevel', 'INFO', '--logfile', '', '/var/lib/juju-lint/juju-status.json']' returned non-zero exit status 1.

Issue has been reported on python-libjuju side:

https://github.com/juju/python-libjuju/issues/387

In the meanwhile, we can also avoid such KeyError from juju-lint itself.


Imported from Launchpad using lp2gh.

esunar commented 1 year ago

(by guoqiao)

esunar commented 1 year ago

(by guoqiao)

esunar commented 1 year ago

(by guoqiao) Above 2 json file are from same juju model. First one doesn't have "machine-status" while second one does.

esunar commented 1 year ago

(by guoqiao) Just noticed juju-status is missing too.

esunar commented 1 year ago

(by ec0) This should have been handled by the refactor, please reopen a new bug if you find additional key errors.