Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSaleh authored Sep 10, 2021
2 parents bf31b93 + f31712c commit 530ef26
Show file tree
Hide file tree
Showing 52 changed files with 768 additions and 662 deletions.
6 changes: 3 additions & 3 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ pull_request_rules:
- label!=WIP
- approved-reviews-by=@fedora-infra/bodhi
- status-success=DCO
- status-success=f32-docs
- status-success=f32-unit
- status-success=f32-diff-cover
- status-success=f33-docs
- status-success=f33-unit
- status-success=f33-diff-cover
- status-success=f34-docs
- status-success=f34-unit
- status-success=f34-diff-cover
- status-success=pip-docs
- status-success=pip-flake8
- status-success=pip-mypy
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If you are interested in contributing to Bodhi, you can read the
IRC
===

Come join us on `Freenode <https://webchat.freenode.net/>`_! We've got two channels:
Come join us on `Libera <https://www.libera.chat/>`_! We've got two channels:

* #bodhi - We use this channel to discuss upstream bodhi development
* #fedora-apps - We use this channel to discuss Fedora's Bodhi deployment (it is more generally
Expand Down
9 changes: 5 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ end
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-32-1.6.x86_64.vagrant-libvirt.box"
config.vm.box = "f32-cloud-libvirt"
config.vm.box_download_checksum = "4b13243d39760e59f98078c440d119ccf2699f82128b89daefac02dc99446360"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-34-1.2.x86_64.vagrant-libvirt.box"
config.vm.box = "f34-cloud-libvirt"
config.vm.box_download_checksum = "3d9c00892253c869bffcf2e84ddd308e90d5c7a5928b3bc00e0563a4bec55849"
config.vm.box_download_checksum_type = "sha256"

# Forward traffic on the host to the development server on the guest.
Expand Down Expand Up @@ -112,7 +112,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# fsync() calls from the guest. Only do this if you are comfortable with the possibility of
# your development guest becoming corrupted (in which case you should only need to do a
# vagrant destroy and vagrant up to get a new one).
domain.volume_cache = "unsafe"
#domain.volume_cache = "unsafe"
domain.disk_driver :cache => 'unsafe'
end
end
end
6 changes: 5 additions & 1 deletion bodhi/messages/schemas/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ class UpdateReadyForTestingV1(BodhiMessage):
'type': 'string',
},
'agent': {
'description': 'Name of the person asking to re-trigger the tests.',
'description': 'Re-trigger request: name of requester, trigger on push: "bodhi".',
'type': 'string',
},
},
Expand Down Expand Up @@ -683,6 +683,10 @@ class UpdateReadyForTestingV1(BodhiMessage):
},
'required': ['type', 'id', 'issuer', 'component', 'nvr', 'scratch'],
}
},
're-trigger': {
'type': 'bool',
'description': 'This flag is True if the message is sent to re-trigger tests'
}
}

Expand Down
3 changes: 0 additions & 3 deletions bodhi/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,6 @@ class BodhiConfig(dict):
'initial_bug_msg': {
'value': '%s has been submitted as an update to %s. %s',
'validator': str},
'graphiql_enabled': {
'value': False,
'validator': _validate_bool},
'greenwave_api_url': {
'value': 'https://greenwave-web-greenwave.app.os.fedoraproject.org/api/v1.0',
'validator': _validate_rstripped_str},
Expand Down
1 change: 1 addition & 0 deletions bodhi/server/consumers/automatic_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def __call__(self, message: fedora_messaging.api.Message) -> None:
autokarma=False,
user=user,
status=UpdateStatus.pending,
critpath=Update.contains_critpath_component([build], rel.branch),
)

# Comment on the update that it was automatically created.
Expand Down
62 changes: 0 additions & 62 deletions bodhi/server/graphql_schemas.py

This file was deleted.

4 changes: 2 additions & 2 deletions bodhi/server/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def add_update(self, update):
pkg.epoch = '0'
pkg.arch = rpm['arch']

# TODO: how do we handle UpdateSuggestion.logout, etc?
pkg.reboot_suggested = update.suggest is UpdateSuggestion.reboot
pkg.reboot_suggested = update.suggest == UpdateSuggestion.reboot
pkg.relogin_suggested = update.suggest == UpdateSuggestion.logout

filename = '%s.%s.rpm' % (rpm['nvr'], rpm['arch'])
pkg.filename = filename
Expand Down
114 changes: 83 additions & 31 deletions bodhi/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from collections import defaultdict
from copy import copy
from datetime import datetime
from datetime import datetime, timedelta
from textwrap import wrap
import hashlib
import json
Expand Down Expand Up @@ -1749,8 +1749,6 @@ def get_changelog(self, timelimit=0, lastupdate=False):
timelimit = oldh['changelogtime']
if isinstance(timelimit, list):
timelimit = timelimit[0]
else:
return ""

str = ""
i = 0
Expand Down Expand Up @@ -2213,42 +2211,83 @@ def get_test_gating_info(self):
}
return util.greenwave_api_post(self._greenwave_api_url, data)

def _get_test_gating_status(self):
@property
def _greenwave_requirements_generator(self):
"""
Query Greenwave about this update and return the information retrieved.
Query Greenwave about this update and return satisfied and unsatisfied requirements.
Returns:
TestGatingStatus:
- TestGatingStatus.ignored if no tests are required
- TestGatingStatus.failed if policies are not satisfied
- TestGatingStatus.passed if policies are satisfied, and there
are required tests
generator: An iterable of 2-tuples of lists of requirement dicts from each request
batch: first tuple item satisfied requirements, second item unsatisfied requirements.
Either list or both may be empty.
Raises:
BodhiException: When the ``greenwave_api_url`` is undefined in configuration.
RuntimeError: If Greenwave did not give us a 200 code.
RuntimeError: If Greenwave did not give us a 200 code, including if no applicable
policies were found.
"""
# If an unrestricted policy is applied and no tests are required
# on this update, let's set the test gating as ignored in Bodhi.
status = TestGatingStatus.ignored
for data in self.greenwave_request_batches(verbose=False):
response = util.greenwave_api_post(self._greenwave_api_url, data)
if not response['policies_satisfied']:
return TestGatingStatus.failed

if status != TestGatingStatus.ignored or response['summary'] != 'no tests are required':
status = TestGatingStatus.passed

return status
satisfied = response.get('satisfied_requirements', [])
unsatisfied = response.get('unsatisfied_requirements', [])
yield (satisfied, unsatisfied)

@property
def _unsatisfied_requirements(self):
unsatisfied_requirements = []
for data in self.greenwave_request_batches(verbose=False):
response = util.greenwave_api_post(self._greenwave_api_url, data)
unsatisfied_requirements.extend(response['unsatisfied_requirements'])
"""Query Greenwave about this update and return all unsatisfied requirements.
Returns:
list: A list of unsatisfied requirement dicts.
Raises:
BodhiException: When the ``greenwave_api_url`` is undefined in configuration.
RuntimeError: If Greenwave did not give us a 200 code, including if no applicable
policies were found.
"""
ret = []
for (_, unsatisfied) in self._greenwave_requirements_generator:
ret.extend(unsatisfied)
return ret

def _get_test_gating_status(self):
"""
Query Greenwave about this update and return the information retrieved.
return unsatisfied_requirements
Returns:
TestGatingStatus:
- TestGatingStatus.ignored if no tests are required
- TestGatingStatus.passed if there are required tests and policies are satisfied
- TestGatingStatus.waiting if there are required tests that have not yet completed,
no required test has failed, and update was last modified less than 2 hours ago
- TestGatingStatus.failed otherwise (failed required tests, missing required
test results and last modified more than 2 hours ago)
Raises:
BodhiException: When the ``greenwave_api_url`` is undefined in configuration.
RuntimeError: If Greenwave did not give us a 200 code, including if no applicable
policies were found.
"""
gotsat = False
gotunsat = False
recent = datetime.utcnow() - self.last_modified < timedelta(hours=2)
for (satisfied, unsatisfied) in self._greenwave_requirements_generator:
if satisfied:
gotsat = True
if unsatisfied:
gotunsat = True
if not recent or not all(req.get('type', '') == 'test-result-missing'
for req in unsatisfied):
return TestGatingStatus.failed

if not gotsat and not gotunsat:
return TestGatingStatus.ignored

if gotsat and not gotunsat:
return TestGatingStatus.passed

# here, we have unsatisfied requirements but we never bailed early
# in the for loop, so they are all 'missing' and update was recently modified
return TestGatingStatus.waiting

@property
def install_command(self) -> str:
Expand Down Expand Up @@ -2373,12 +2412,17 @@ def new(cls, request, data):
log.debug(f"Triggering db commit for new update {up.alias}.")
db.commit()

# track whether to set gating status shortly...
setgs = config.get('test_gating.required')
# The request to testing for side-tag updates is set within the signed consumer
if not data.get("from_tag"):
log.debug(f"Setting request for new update {up.alias}.")
up.set_request(db, req, request.user.name)
if req == UpdateRequest.testing:
# set_request will update gating status if necessary
setgs = False

if config.get('test_gating.required'):
if setgs:
log.debug(
'Test gating required is enforced, marking the update as waiting on test gating')
up.test_gating_status = TestGatingStatus.waiting
Expand Down Expand Up @@ -3684,6 +3728,10 @@ def check_karma_thresholds(self, db, agent):
text = config.get('disable_automatic_push_to_stable')
self.comment(db, text, author='bodhi')
elif self.stable_karma and self.karma >= self.stable_karma:
if config.get('test_gating.required') and not self.test_gating_passed:
log.info("%s reached stable karma threshold, but does not meet gating "
"requirements", self.alias)
return
if self.autokarma:
log.info("Automatically marking %s as stable", self.alias)
self.set_request(db, UpdateRequest.stable, agent)
Expand Down Expand Up @@ -3993,7 +4041,7 @@ def comment_on_test_gating_status_change(target, value, old, initiator):
email_notification=notify,
)

def _build_group_test_message(self):
def _build_group_test_message(self, agent="bodhi", retrigger=False):
"""
Build the dictionary sent when an update is ready to be tested.
Expand All @@ -4003,7 +4051,11 @@ def _build_group_test_message(self):
by any CI system.
Args:
target (Update): The update that has had a change to its status attribute.
agent (str): For the case where the message is sent as a test
re-trigger request, the user who requested it. Otherwise,
'bodhi'.
retrigger (bool): Whether the message is sent as a test re-
trigger request.
Returns:
dict: A dictionary corresponding to the message sent
"""
Expand Down Expand Up @@ -4037,8 +4089,8 @@ def _build_group_test_message(self):
"artifact": artifact,
"generated_at": datetime.utcnow().isoformat() + 'Z',
"version": "0.2.2",
'agent': 'bodhi',
're-trigger': False,
'agent': agent,
're-trigger': retrigger,
}

@staticmethod
Expand Down
Loading

0 comments on commit 530ef26

Please sign in to comment.