#603 Unexpected result with a policy with RemoteRule
Closed: Fixed 3 years ago by vmaljulin. Opened 3 years ago by lholecek.

When requested policy contains only single rule and it has RemoteRule type and the gating.yaml for given build doesn't contain given decision subject, Greenwave summary is "cannot find any applicable policies" but expected is "no tests are required".

Example:

❯ curl 'https://greenwave.fedoraproject.org/api/v1.0/decision' -H 'Content-Type: application/json' --data-raw '{"product_version":"fedora-34","decision_context":"bodhi_update_push_stable","subject":[{"item":"tmt-1.1-1.fc34","type":"koji_build"},{"item":"FEDORA-2020-bf0d8f3492","type":"bodhi_update"}],"verbose":true}'
{"message":"Cannot find any applicable policies for koji_build subjects at gating point bodhi_update_push_stable in fedora-34"}

The affected policy:

❯ curl https://greenwave.fedoraproject.org/api/v1.0/policies | jq '.policies[] | select((.subject_type == "koji_build") and (.decision_context == "bodhi_update_push_stable") and (.product_versions[] | contains("fedora-34")))'
{
  "blacklist": [],
  "decision_context": "bodhi_update_push_stable",
  "decision_contexts": [],
  "excluded_packages": [],
  "id": "taskotron_release_critical_tasks_for_stable",
  "packages": [],
  "product_versions": [
    "fedora-rawhide",
    "fedora-eln",
    "fedora-34",
    "fedora-33",
    "fedora-32",
    "fedora-31",
    "fedora-30",
    "fedora-29"
  ],
  "relevance_key": null,
  "relevance_value": null,
  "rules": [
    {
      "rule": "RemoteRule"
    }
  ],
  "subject_type": "koji_build"
}

Remote gating.yaml with missing decision context.

❯ curl https://src.fedoraproject.org/rpms/tmt/raw/df1266227d77bf500972bd36785811bc7343d297/f/gating.yaml
--- !Policy
product_versions:
  # note rawhide not yet supported properly :(
  - fedora-34
decision_context: bodhi_update_push_testing
subject_type: koji_build
rules:
  - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0-tf.functional}

Metadata Update from @lholecek:
- Issue tagged with: bug

3 years ago

Is that a scenario we really want to have? If we'd make such a change and someone had mistyped something in the gating.yaml, Greenwave would always say, that anything is fine, cause "no tests are required", but the reality will be completely different...
For me, it sounds like a very strange situation when someone queries 'gating.yaml' just to find that there's nothing in this gating.yaml.

Is that a scenario we really want to have? If we'd make such a change and someone had mistyped something in the gating.yaml, Greenwave would always say, that anything is fine, cause "no tests are required", but the reality will be completely different...
For me, it sounds like a very strange situation when someone queries 'gating.yaml' just to find that there's nothing in this gating.yaml.

Remote rule file is optional, same as defining rules for a policy in remote file. More specifically, RemoteRule in policy (on Greenwave side) doesn't mean that a policy with same decision_context needs to be defined in remote rule file and it doesn't fail if the file is not found (unless required: true is set).

BTW, this is currently problem in Fedora and internally and people complain that there is something unexpected happening.

Documentation was updated regarding this issue.

Documentation was updated regarding this issue.

@vmaljulin The documentation is not updated: https://docs.pagure.org/greenwave/policies.html

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #621 Merged 3 years ago
  • #618 Closed 3 years ago