c06ed0c Allow querying multiple decision contexts in a single decision (#95)

6 files Authored by adamwill 2 years ago, Committed by GitHub 2 years ago,
    Allow querying multiple decision contexts in a single decision (#95)
    
    When Greenwave was designed we never really envisaged a use for

    querying multiple decision contexts at once. We assumed it'd

    only ever make sense to care about exactly one context for

    whatever decision you're trying to make.

    

    However, we wound up using multiple decision contexts to solve

    the problem of wanting different policies for the same gating

    point depending on the contents of the thing being gated.

    For a specific example, when gating Fedora updates, we have

    a `bodhi_update_push_testing` context that we always query for

    any update being pushed to testing, but we also have a

    `bodhi_update_push_testing_critpath` context that we only query

    for critical path updates (because it requires some tests that

    are only *run* on critical path updates). A pending Bodhi pull

    request - https://github.com/fedora-infra/bodhi/pull/4759 -

    would make Bodhi query even more decision contexts for critical

    path updates.

    

    Currently when Bodhi wants to query multiple decision contexts,

    it has to ask for one decision per context. This is pretty

    inefficient. It actually turns out to be quite easy to just

    allow the `decision_context` value to be a list of strings as

    well as a single string; all that really needs to be done to

    handle this is a fairly small tweak to `Policy.matches()`. Since

    we already iterate over every policy, I don't think this even

    has any significant performance impact, it should be about as

    fast to check every policy against a list of decision contexts

    as it is to check it against a single context.

    

    Signed-off-by: Adam Williamson <awilliam@redhat.com>
        
file modified
+22 -3
file modified
+13 -5
file modified
+5 -2