219 Commits

Author SHA1 Message Date
Brendan Reilly
b175c827cf Nudge non-scratch builds stuck in done
Fixes #1783
2025-03-18 15:59:22 -04:00
Mike McLean
f6dcf6c346 switch to using gssapi_login for koji
Fixes https://pagure.io/fm-orchestrator/issue/1777

koji recently dropped this old call
https://pagure.io/koji/pull-request/3599

Previously, koji was ignoring the ctx arg and wrapping gssapi_login,
so this change is completely equivalent to the old behavior.
2023-02-22 10:22:53 -05:00
Owen W. Taylor
8ab293dc9e test_start_next_batch_build_repo_building: actually try to start the batch 2023-02-21 16:47:24 +00:00
Brendan Reilly
79e3eae43e Add delay to missed new repo check 2022-09-02 12:01:34 -04:00
Brendan Reilly
c24038198e Merge #1672 Don't pass SQLAlchemy objects between threads 2022-05-13 16:47:07 +00:00
Brendan Reilly
6b76877d6d Merge #1661 MBSResolver - caching, tests, fixes 2022-05-03 16:42:22 +00:00
Owen W. Taylor
7761bbf5b4 Tweak behavior of get_compatible_base_module_modulemds
Fix some oddities in the DBResolver implementation of
get_compatible_base_module_modulemds() and make the MBSResolver version -
which was previously just buggy - match that. (Tests for the MBSResolver
version are added in a subsequent commit.)

 * If an empty virtual_streams argument was passed in, *all* streams
   were considered compatible. Throw an exception in this case - it
   should be considered an error.
 * If stream_version_lte=True, but the stream from the base module
   wasn't in the form FOOx.y.z, then throw an exception. This was
   previously treated like stream_version_lte=False, which is just
   a recipe for confusion and mistakes.

test_get_reusable_module_use_latest_build() is rewritten to
comprehensively test all possibilities, including the case that changed
above.

test_add_default_modules_compatible_platforms() is changed to run
under allow_only_compatible_base_modules=False, since it expected
Fedora-style virtual streams (versions not in FOOx.y.z form, all
share the same stream), which doesn't make sense with
allow_only_compatible_base_modules=True.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
5dcd63ebf9 batches.py: Don't pass SQLAlchemy objects between threads
SQLAlchemy objects can't be used from multiple threads - so when starting
threads for builds, pass the ComponentBuild id rather than the object.
(Note that despite the comment that the threads were sharing a session,
they weren't - what was passed to the thread was a scoped_session that
acts as a separate thread-local session per-thread.)

BUILD_COMPONENT_DB_SESSION_LOCK - a threading.Lock() object that was used
in a few places - but not nearly enough places to effectively lock usage
of a shared session - is removed.
2022-04-26 17:04:40 -04:00
Owen W. Taylor
1f2fbca7d4 Check dnf version before skipping base module conflicts
The base module conflict generation was skipped for local builds
in 6b2e5be93a because libdnf wasn't ported to libmodulemd yet -
that was done in libdnf-0.45, so only warn and skip for versions of
dnf too old to require libdnf-0.45.

(Don't just unconditionally skip check/warning in case someone is
doing local module builds on RHEL 8.)
2022-04-25 12:25:19 -04:00
Brendan Reilly
4a30847bea Remove Greenwave Code
No implementations of MBS are using Greenwave, and there are no current plans
to do so. Koji Resolver will be sufficient for any usecase dependent on gating.
2022-03-30 14:27:34 -04:00
Jan Kaluza
bfd9a13205 Allow overriding RPM components refs while submitting the module build.
There is a need to rebuild the module builds done in CentOS 9 Stream
internally in MBS to include them in RHEL. This is currenly a hard task,
because the RPM components included in a module are usually
taken from HEAD of the branch defined by their `ref` value.

For the rebuild task, it means we would have to ensure that the HEAD
of all RPM components points to right commit hash right before we start
rebuilding CentOS 9 Stream module in internal MBS. This is very hard
and fragile thing to do, especially if there are two different modules
using the RPM component from the same branch. This is prone to race
condition and makes the rebuilds quite complex and in some cases
not possible to do without force pushes to RPM component repositories
which is not acceptable by internal dist-git policy.

This commit fixes it by allowing overriding the commit hash while
submitting the module build. This helps in the mentioned situation,
because we can keep internal RPM components branches in 1:1 sync with
CentOS 9 Stream branches and HEAD can always point to the same commit
in both internal and CentOS 9 Stream repositories.

When the module rebuild is submitted in internal MBS,
we can use this new feature to override the `ref` for each RPM component
so it points to particular commit and the requirement for HEAD to point
to this commit is no longer there.

The `ref` is overriden only internally in MBS (but it is recorded in logs
and in XMD section), so the input modulemd file is not altered. This is
the same logic as used for other overrides (`buildrequire_overrides` or
`side_tag`).

This does not bring any security problem, because it is already possible
to use commit hash in `ref`, so the package maintainer can already change
the commit hash to any particular commit by using this `ref` value.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2021-07-28 08:48:12 +02:00
Mike McLean
af97a23bca additional unit tests for strict_module_state_transitions 2021-06-15 15:05:06 -04:00
Mike McLean
fcd662468f fix unit tests 2021-06-15 15:05:06 -04:00
Brendan Reilly
ed86a2ca72 Do not add conflicts when builds are identical
Fixes: #1660
2020-11-11 16:03:52 -05:00
jobrauer
c584d84b76 JIRA: RHELBLD-257,RHELBLD-310 - refactor clean_database
Replace clean_database calls with cheaper truncate operation.
Remove duplicate calls of clean_database.
Extract clean_database/init_data into fixtures.
2020-05-15 16:06:42 +02:00
Brendan Reilly
25cdfbbd22 Add the ability to limit arches 2020-04-01 17:02:51 +00:00
mprahl
244f29f25f Make record_module_build_arches idempotent
This function could get called multiple times if the init handler
runs more than once. This can happen if the build failed in the
init handler due to external infrastructure being down and the
user resumes their build.
2020-03-23 20:22:57 +00:00
Merlin Mathesius
de2a776226 Skip git ref checks for rpm components with srpm overrides
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2020-03-10 14:02:11 +00:00
Merlin Mathesius
ab90c7b710 Clean up unused test code to avoid confusion
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2020-03-10 14:02:11 +00:00
mprahl
d2b3eace3d Handle when a message parser returns None
mbs-messaging-umb is such a parser that returns None if a message
does not match the schema it is validating against.
2020-03-04 16:11:25 -05:00
Chenxiong Qi
1c0715662a Cleanup module_build_service/__init__.py
Most of the code are moved to dedicated subpackages, but some others
can't due to the cycle dependencies.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:48 -05:00
Chenxiong Qi
1e5ed864c9 Avoid to handle a late init message
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Chenxiong Qi
81b36b1d6e Add indexes to ModuleBuild and ComponentBuild
Tests are updated accordingly as well.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Chenxiong Qi
b70c632a70 Send module build state change message after commit to database
In MBS, there are two cases to send a message when a module build moves
to a new state. One is to create a new module build, with
ModuleBuild.create particularly, when user submit a module build.
Another one is to transition a module build to a new state with
ModuleBuild.transition. This commit handles these two cases in a little
different ways.

For the former, existing code is refactored by moving the publish call
outside ModuleBuild.create.

For the latter, message is sent in a hook of SQLAlchemy ORM event
after_commit rather than immediately inside the ModuleBuild.transition.

Both of these changes ensure the message is sent after the changes are
committed into database successfully. Then, the backend can have
confidence that the database has the module build data when receive a
message.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
mprahl
352ca36c88 Remove the sys.modules patches in the tests
This is no longer needed since
https://pagure.io/fm-orchestrator/pull-request/1563
2020-03-03 14:48:47 -05:00
mprahl
5ecde6dc5f Use a context manager to patch sys.modules
When not using the context manager, it causes the pytest process
to not close after the tests have completed when the tests are
run using Python 3.
2020-03-03 14:48:47 -05:00
mprahl
81f2bffdda Rearrange the imports to meet the style guide
This also includes `from __future__ import absolute_import`
in every file so that the imports are consistent in Python 2 and 3.
The Python 2 tests fail without this.
2020-03-03 14:48:47 -05:00
mprahl
c10a6769ed Move scm.py to common/scm.py 2020-03-03 14:48:47 -05:00
mprahl
4b32612002 Move route.py to scheduler/route.py 2020-03-03 14:48:47 -05:00
mprahl
9ddb35b8d3 Move models.py to common/models.py and views.py to web/views.py 2020-03-03 14:48:47 -05:00
mprahl
d9f32bff9d Move errors.py to common/errors.py 2020-03-03 14:48:47 -05:00
mprahl
18dd43926c Move messaging.py to common/messaging.py 2020-03-03 14:48:47 -05:00
mprahl
b16cb88bc3 Move db_session.py to scheduler/db_session.py 2020-03-03 14:48:47 -05:00
mprahl
98b54d211e Move config.py to common/config.py 2020-03-03 14:48:47 -05:00
mprahl
96b0c85927 Split utils/submit.py
This moves the code used by the backend and API to common/submit.py,
the code used just by the API to web/submit.py, and the code used
just by the backend to scheduler/submit.py.
2020-03-03 14:48:47 -05:00
mprahl
85e3a2c496 Move utils/reuse.py to scheduler/reuse.py 2020-03-03 14:48:47 -05:00
mprahl
a1dfeeb7e3 Move utils/ursine.py to scheduler/ursine.py 2020-03-03 14:48:47 -05:00
mprahl
b0a27081f4 Split utils/general.py
This puts backend specific code in either the builder or scheduler
subpackage. This puts API specific code in the new web subpackage.
Lastly, any code shared between the API and backend is placed in the
common subpackage.
2020-03-03 14:48:47 -05:00
mprahl
84901c9ba5 Move utils/greenwave.py to scheduler/greenwave.py 2020-03-03 14:48:47 -05:00
mprahl
1f8a1b1d3d Rename test_greenwave.py to test_greenwave_handler.py 2020-03-03 14:48:47 -05:00
mprahl
81ab984b1f Move utils/batches.py to scheduler/batches.py 2020-03-03 14:48:47 -05:00
Qixiang Wan
938a3b9557 Ignore koji_build_change event without task_id 2020-03-03 14:48:47 -05:00
mprahl
8e7a43d5ff Move get_session and retry to separate modules to reduce circular imports 2020-03-03 14:48:47 -05:00
mprahl
f6bcdfa932 Simplify how MBS is configured
This merges the configuration from conf/config.py to
module_build_service/config.py. This also greatly simplifies the logic
in `init_config`. Additionally, `init_config` is no longer aware of
Flask. This will allow us to eventually break up the configuration
between the API and the backend.
2020-03-03 14:48:47 -05:00
Qixiang Wan
510eb908c5 Remove unused handler arguments
The following handler arguments are not used at all:

1. `build_id` in handlers/components.py:build_task_finalize
2. `build_name` in handlers/tags.py:tagged
2020-03-03 14:48:47 -05:00
Qixiang Wan
e904626fc5 Rename handler.repos.done argument name "repo_tag" to "tag_name"
This to make it same as the `tag_name` argument in
`handlers.tags.tagged`, so we can handle it easily while inspecting the
function signatures.
2020-03-03 14:48:47 -05:00
Chenxiong Qi
0607f2079c Convert the Poller to be Celery periodic tasks
Poller methods within original class MBSProducer become module level
functions and are registered as Celery periodic tasks.

Code logging the size of fedmsg-hub queue are removed from log_summary.

process_open_component_builds is still kept there and not converted to a
periodic task.

There are some small refactor:

* do not format string in logging method call.
* reformat some lines of code doing SQLAlchemy database query to make
  them more readable.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Qixiang Wan
9049eea35c Register handlers as Celery tasks 2020-03-03 14:48:47 -05:00
Chenxiong Qi
b939d53c57 Pass event info arguments to event handler directly
This patch drops message objects, defined by class BaseMessage and its
subclasses, and pass event info arguments to event handler directly.
Different event handler requires different arguments to handle a kind of
specific event. The event info is parsed from the raw message received
from message bus.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Chenxiong Qi
55612d7baf Remove config argument from event handlers
For the purpose of migrating to Celery to run event handler inside a
worker, Config object is not serializable. And from the usage of config
argument, every event handler can just access module_build_service.conf
directly. This removal would make the migration easier.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00