canonical / hotsos

Software analysis toolkit. Define checks in high-level language and leverage library to perform analysis of common Cloud applications.
Apache License 2.0
30 stars 37 forks source link

requires/types: introduce expression type (expr.py) #913

Open mustafakemalgilor opened 1 week ago

mustafakemalgilor commented 1 week ago

expression is a new requirement type that allows users to express a requirement in human-readable, SQL-like syntax. It has proper grammar to allow users to write checks in as easily digestible manner, which will improve the QOL for scenario writers and code reviewers. The grammar is constructed using the pyparsing library.

Example:

checks:
  not_using_iommu_passthrough_for_suitable_amd: |
    (@hotsos.core.plugins.kernel.sysfs.CPU.vendor == 'authenticamd') AND
    (@hotsos.core.plugins.system.SystemBase.virtualisation_type == None) AND
    NOT('iommu=pt' IN @hotsos.core.plugins.kernel.KernelBase.boot_parameters)    

The current grammar supports the following constructs:

Also, the following changes have been made:

This patch rewrites some of the scenario checks in the new expression syntax to demonstrate the difference and provide examples.

mustafakemalgilor commented 1 week ago

IDK why the "Test / test (3.8, ubuntu-20.04) (pull_request)" job is failing, all tests are green in my env. I'll re-run them in a py3.8 environment and get to the bottom of it.

mustafakemalgilor commented 5 days ago

@dosaboy fixed CI issues, ready for review. please feel free to ping me should you need to ask anything.

mustafakemalgilor commented 2 days ago

This feature is intended to be used in conjunction with the aliasing feature: https://github.com/canonical/hotsos/pull/929