canonical / juju-lint

Run checks against a juju model
GNU General Public License v3.0
0 stars 4 forks source link

TypeError: '>=' not supported between instances of 'str' and 'int #234

Open zxhdaze opened 6 months ago

zxhdaze commented 6 months ago

During my testing of juju-lint on top of OpenStack bundle I hit following error.

x1:➜  juju-lint git:(master) ✗ juju-lint -c contrib/openstack-jammy-ovn.yaml -t openstack tests/resources/openstack-yoga-jammy-ovn-bundle.yaml                    
2023-06-01 08:53:29 [INFO] juju-lint version 1.0.7 starting...
        * Config directory: /home/rgildein/.config/juju-lint
        * Cloud type: openstack
        * Manual file: tests/resources/openstack-yoga-jammy-ovn-bundle.yaml
        * Rules files: ['contrib/openstack-jammy-ovn.yaml']
        * Log level: INFO

2023-06-01 08:53:29 [WARNING] Regex autodetection feature of the eq operator is deprecated. It will only check for equality in the future. Please use the search operator for regex checks.
2023-06-01 08:53:29 [INFO] [tests/resources/openstack-yoga-jammy-ovn-bundle.yaml] Linting manual file...
2023-06-01 08:53:29 [ERROR] [tests/resources/openstack-yoga-jammy-ovn-bundle.yaml] [manual/manual] Application ceph-mon has incorrect setting for 'nagios_additional_checks_critical': Expected True, got False
2023-06-01 08:53:29 [ERROR] [tests/resources/openstack-yoga-jammy-ovn-bundle.yaml] [manual/manual] Application ceph-mon has incorrect setting for 'nagios_additional_checks': Expected '{"ceph_slow_requests": "slow requests"}', got ''
2023-06-01 08:53:29 [ERROR] [tests/resources/openstack-yoga-jammy-ovn-bundle.yaml] [manual/manual] Application keystone has config for 'token-expiration' which is less than 86400: 3600
Traceback (most recent call last):
  File "/snap/juju-lint/91/bin/juju-lint", line 8, in <module>
    sys.exit(main())
  File "/home/rgildein/code/canonical/juju-lint/jujulint/cli.py", line 241, in main
    cli.audit_file(cli.manual_file, cloud_type=cli.cloud_type)
  File "/home/rgildein/code/canonical/juju-lint/jujulint/cli.py", line 157, in audit_file
    linter.lint_yaml_file(filename)
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 1395, in lint_yaml_file
    return self.do_lint(parsed_yaml)
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 1417, in do_lint
    self.check_configuration(parsed_yaml[applications])
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 603, in check_configuration
    self.check_config(
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 556, in check_config
    check_method(
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 397, in gte
    return self.check_config_generic(
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 487, in check_config_generic
    if operator.check(check_value, actual_value):
  File "/home/rgildein/code/canonical/juju-lint/jujulint/lint.py", line 388, in operator_gte_check
    return current >= expected
TypeError: '>=' not supported between instances of 'str' and 'int'         [0.57s]

After short debugging (running it w/ DEBUG log level) I found that in my bundle config option innodb-buffer-pool-size was set to 50% instead of exact number, e.g. 8G. Do we need to support both types of values? If not we should at-least provide better output and not failing.