Skip to content

Commit

Permalink
Remove subject_type attribute supports_remote_rule
Browse files Browse the repository at this point in the history
Currently, setting `supports_remote_rule` or setting it to `false` means
that any `RemoteRule` (even with specified sources/URLs) in policies is
ignored for that subject type. In most cases, this is confusing
unexpected behavior.

The change is to drop the attribute completely and rely on presence of
`RemoteRule` in policies (it should not be present if the subject type
the policy uses does not support it).

JIRA: RHELWF-10561
  • Loading branch information
hluk committed Jan 29, 2024
1 parent 19f759f commit 56fa7e2
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 23 deletions.
3 changes: 0 additions & 3 deletions conf/subject_types/brew-build-group.yaml

This file was deleted.

1 change: 0 additions & 1 deletion conf/subject_types/koji_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ aliases:
- brew-build
is_koji_build: true
is_nvr: true
supports_remote_rule: true
item_key: "original_spec_nvr"
result_queries:
# {"type": "koji_build,brew-build", "item": ITEM}
Expand Down
1 change: 0 additions & 1 deletion conf/subject_types/redhat-container-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ id: redhat-container-image
product_version: rhel-8
is_koji_build: true
is_nvr: true
supports_remote_rule: true
item_key: "nvr"
result_queries:
- item_key: "nvr"
Expand Down
1 change: 0 additions & 1 deletion conf/subject_types/redhat-module.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--- !SubjectType
id: redhat-module
product_version: rhel-8
supports_remote_rule: true
6 changes: 3 additions & 3 deletions docs/decision_requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ To waive this, use the test case name "invalid-gating-yaml".
Missing remote rule
-------------------

If the requested policy contains a ``RemoteRule`` with ``required`` attribute
set to ``true``, this unsatisfied requirement is created for each subject that
supports remote rule files and the file is missing for requested subject.
This unsatisfied requirement is created if the requested policy contains a
``RemoteRule`` with ``required`` attribute set to ``true`` but the remote file
is missing.

To waive this, use test case name "missing-gating-yaml".

Expand Down
1 change: 0 additions & 1 deletion functional-tests/test_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,6 @@ def test_installed_subject_types(requests_session, greenwave_server):
assert len(data['subject_types'])
assert [x['id'] for x in data['subject_types']] == [
'bodhi_update',
'brew-build-group',
'compose',
'koji_build',
'redhat-container-image',
Expand Down
3 changes: 0 additions & 3 deletions greenwave/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,6 @@ def _get_sub_policies(self, policy, subject):
and answers (including FetchedRemoteRuleYaml, MissingRemoteRuleYaml,
InvalidRemoteRuleYaml, FailedFetchRemoteRuleYaml).
"""
if not subject.supports_remote_rule:
return [], []

remote_policies_urls = []
remote_policies_url = None
response = None
Expand Down
4 changes: 0 additions & 4 deletions greenwave/subjects/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ def product_versions(self):
def is_koji_build(self):
return self.subject_type.is_koji_build

@property
def supports_remote_rule(self):
return self.subject_type.supports_remote_rule

@property
def ignore_missing_policy(self):
return self.subject_type.ignore_missing_policy
Expand Down
3 changes: 0 additions & 3 deletions greenwave/subjects/subject_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class SubjectType(SafeYAMLObject):
# version can be parsed for identifier.
'is_nvr': SafeYAMLBool(optional=True),

# Subject type can be used with RemoteRule only if value is True.
'supports_remote_rule': SafeYAMLBool(optional=True, default=False),

# Omit responding with HTTP 404 if there is no applicable policy.
'ignore_missing_policy': SafeYAMLBool(optional=True, default=False),

Expand Down
1 change: 0 additions & 1 deletion greenwave/tests/test_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ def test_subject_types(client):
assert len(data['subject_types'])
assert [x['id'] for x in data['subject_types']] == [
'bodhi_update',
'brew-build-group',
'compose',
'koji_build',
'redhat-container-image',
Expand Down
1 change: 0 additions & 1 deletion greenwave/tests/test_subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def test_subject_create_generic(app):
assert subject.short_product_version is None
assert subject.product_versions == []
assert subject.is_koji_build
assert not subject.supports_remote_rule


def test_subject_koji_build_result_queries(app):
Expand Down
1 change: 0 additions & 1 deletion greenwave/tests/test_subjects_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_subject_type_create(subject_types):
assert subject_type.aliases == ['brew-build']
assert subject_type.is_koji_build
assert subject_type.is_nvr
assert subject_type.supports_remote_rule
assert subject_type.item_key == 'original_spec_nvr'


Expand Down

0 comments on commit 56fa7e2

Please sign in to comment.