3076 Commits

Author SHA1 Message Date
Owen W. Taylor
80c7e20bfa resolver: remove unused state/states parameter to get_module()
BaseResolver.get_module() and DBResolver.get_module() to a state
parameter, MBSResolver took a states parameter - neither was used
anywhere.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
7d2e754f35 Fix handling of getting "modulemd: null" in MBS verbose response
The code made some half-hearted attemps to handle a MBS verbose query
missing the modulemd data, but it didn't do anything logically
consistent - fix it to consistently ignore such modules.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
960058fe9d MBSResolver: fix 'either...or' => 'both....and' 2022-04-29 15:47:08 -04:00
Owen W. Taylor
70ed42885e MBSResolver: local modules can't be metadata-only
A module added with --add-local-build  can't have koji_tag=None, since
koji_tag is set to the directory where the module is.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
7d6c7876b1 MBSResolver: fix a RuntimeError to not reference None 2022-04-29 15:47:08 -04:00
Owen W. Taylor
7e33935760 MBSResolver: remove non-functional handling of RPM filtering
Code in MBSResolver.resolve_requires() to compute filtered_rpms()
assumed the response from MBS has a "rpms" key with binary RPMS
from the build, but this was never implemented.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
abd731397f MBSResolver: use requests.Response.raise_for_status()
Simplify and avoid extra uncovered code paths.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
7788c4f3f7 local builds: provide a useful error message for a non-xyz base module
If allow_only_compatible_base_modules=True, then it's an error if the
module buildrequires a non-xyz base module stream. Give an error message
that says how to override the base module in the modulemd file.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
4026900f4f Add --buildrequires/--requires options to build_module_locally
Overriding the platform stream with, e.g, platform:el8.3.1
is necessary to correctly pick up the right build dependencies for some
configurations. Match the fedpkg/rhpkg module-build way of doing this by adding
--buildrequires and --requires options to build_module_locally.
2022-04-29 15:47:08 -04: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
c4230a352d LocalBuildConfiguration: Set ALLOW_ONLY_COMPATIBLE_BASE_MODULES = False
The default LocalBuildConfiguration builds against Fedora - which has
ALLOW_ONLY_COMPATIBLE_BASE_MODULES = False on the server side. Match that
to avoid warnings that f33 isn't in <stream>x.y.z form.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
e48983132c Clarify the meaning conf.allow_only_compatible_base_modules=False
config.allow_compatible_base_modules=False does different things for
build-requires selection and for module reuse. Clarify this in the config
key documentation.

(This config key is really: True: "do what RHEL expects"
False: "do what Fedora expects")
2022-04-29 15:47:08 -04:00
Owen W. Taylor
e5c51d924f Don't traceback on failed builds
Just failing a build isn't a reason to die with a traceback - exit with
a status instead.

Fixes: #1364
2022-04-26 17:20:49 -04:00
Owen W. Taylor
0d0d8091ac test_build: leave Control-C working
Two problems occurred with the moksha/twisted handling of SIGINT:

 * While KeyboardInterrupt caused the moksha loop to exit, it just
   left the test in a confused state, instead of triggering standard
   pytest behavior and aborting the entire test run.
 * The handler was left-over for remaining tests that prevent Control-C
   from working at all.

Fix that by using mock.patch to override moksha's signal handler with
our own signal handler that stores the KeyboardInterrupt in the
current EventTrap, and restores the default signal handler after
the loop ends.

Note that since the KeyboardInterrupt is always handled in the main thread,
we don't get a useful backtrace from the child thread.
2022-04-26 17:12:16 -04:00
Owen W. Taylor
4ddd3c2637 test_build: exit rather than hanging on event handler exception
Event handlers decorated with @celery_app_task don't raise an exception -
they just log the exception, leaving the Moksha hub running. This meant
that any failures in test_build would result in the test suite hanging
rather than failing usefully.

We solve this by adding a new class EventTrap which acts as a context
manager. Any exceptions that occur in event handlers are set on the
current EventTrap, and the test_build tests re-raise the exception.
2022-04-26 17:12:16 -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
4a3e6fb0fa start_build_component: add missing db_session parameter 2022-04-26 17:04:40 -04:00
Owen W. Taylor
3b8cdd342a Avoid deep recursion when handling a large queue of events
Because each event handler wrapper would call scheduler.run() at the end before
returning, with a queue of 100 events to process we'd end up
with:

 Event handler 1 wrapper
   scheduler.run()
     Event handler 2 wrapper
       scheduler.run()
         .....
            .... Event handler 100 wrapper

Which would eventually exhaust the Python stack limit. Fix this by making scheduler.run()
no-op if the scheduler is already processing the queue in the current thread.
2022-04-26 17:02:09 -04:00
Owen W. Taylor
a96774a1fd Go back to using a file-backed SQLite database for tests
Using a memory database causes tests/test_build to intermittently
fail, because using the same pysqlite3 connection object from multiple
threads - as was done so that the threads shared the same memory database
- is not, in the end, thread safe. One thread will stomp on the transaction
state of other threads, resulting in errors from starting a new transaction
when another is already in progress, or trying to commit a transaction
that is not in progress.

To avoid a significant speed penalty, the session-scope fixture sets up
a database in the pytest temporary directory, which will typically be on
tmpfs. Time to complete all tests:

 memory backend:               38 seconds
 file on tmpfs:                40 seconds
 file on nvme ssd with btrfs: 137 seconds

MBSSQLAlchemy, which attempted to make the memory backend work, is removed.

Session hooks are installed on the Session class rather than on the
scoped_session instance - this works better when we're changing from
one database to another at test setup time.
2022-04-26 16:59:59 -04:00
Owen W. Taylor
9c1fc386ff Improve test coverage for MockModuleBuilder
Test coverage for this file improves from 55% => 89%
2022-04-26 16:58:30 -04:00
Owen W. Taylor
48224c7853 MockModuleBuilder: fix an encoding error running under Python 2.7 2022-04-26 16:58:30 -04:00
Owen W. Taylor
f5c7c6b9f4 MockModuleBuilder.py: remove stale code to remove -srpm-stdout.log
This log is no longer generated, since the code was switched to use
Mock SCM.
2022-04-26 16:58:30 -04:00
Owen W. Taylor
0b3df48700 MockModuleBuilder.SCMBuilder: remove unused method 2022-04-26 16:58:30 -04:00
Owen W. Taylor
c35730cb33 MockModuleBuilder: move get_average_build_time() to the right class 2022-04-26 16:58:30 -04:00
Owen W. Taylor
5bb5733e82 MockModuleBuilder: fix repo_name for local repositories 2022-04-26 16:58:30 -04:00
Owen W. Taylor
e06a7e33cd Move 'Connecting to koji <url>' messages to debug 2022-04-25 12:27:02 -04:00
Owen W. Taylor
c1cc9a1a42 Local builds: Don't log 'Getting tag for %s:%s:%s'
Don't log about calling out to koji for a module tag when we don't
actually do so and just use a predictable format.
2022-04-25 12:27:02 -04:00
Owen W. Taylor
53d35e546d Local builds: avoid 'Hub not initialized. Queueing on the side' warnings
We don't need messages at all for local builds, so use a separate "drop"
backend and reserve the "in_memory" backend for tests, where we sometimes
want to inspect the messages. This avoids a warning for each published
message.
2022-04-25 12:27:01 -04:00
Owen W. Taylor
192eefb641 Squash 'Cannot find qpid python module' warnings from Moksha
Importing moksha causes a 'Cannot find qpid python module' warning if
it's not installed, but we don't need the QPid support.
2022-04-25 12:26:06 -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
Owen W. Taylor
c66eca6044 Local builds: fix logging to the module build log file
Ever since local builds were changed to call handlers directly
instead of going through the scheduler, the current module ID wasn't
set, causing no logs to be written to the module build log file.
2022-04-25 12:25:19 -04:00
Brendan Reilly
3a633967ec Merge #1737 Remove Greenwave Code 2022-04-14 19:50:11 +00:00
Brendan Reilly
6cd10004c8 Add default branch configuration option
Fixes: #1735
2022-04-13 10:42:53 -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
Brendan Reilly
3c0c7d3029 Also run bandit during py3 unit tests 2022-03-22 13:55:27 -04:00
Brendan Reilly
8ea54dbdb7 Allow siblings in the garbage state 2022-03-16 11:28:32 -04:00
Mike McLean
24e1efd394 PR#1733: Replace dashes with underscore in stream name integration test
Merges #1733
https://pagure.io/fm-orchestrator/pull-request/1733
2021-10-29 16:04:08 -04:00
Brendan Reilly
e7016b25ae Replace dashes with underscore in stream name integration test 2021-10-29 11:40:35 -04:00
Mike McLean
3f876ae5c7 PR#1732: clarify id in readme
Merges #1732
https://pagure.io/fm-orchestrator/pull-request/1732
2021-10-26 14:56:35 -04:00
Mike McLean
033acf9b38 clarify id in readme
Fixes https://pagure.io/fm-orchestrator/issue/1723
2021-10-20 13:27:49 -04:00
Mike McLean
6718bd72c5 PR#1729: don't filter runtime deps for packagerV3 case
Merges #1729
https://pagure.io/fm-orchestrator/pull-request/1729
2021-08-30 11:59:16 -04:00
Mike McLean
2f324d2ba1 fix unit test 2021-08-26 17:07:23 -04:00
Mike McLean
85e5b9c738 don't filter runtime deps for packagerV3 case
Fixes: https://pagure.io/fm-orchestrator/issue/1714
2021-08-26 15:54:10 -04:00
Mike McLean
d5d150da58 PR#1719: Clarify common 500 errors
Merges #1719
https://pagure.io/fm-orchestrator/pull-request/1719
2021-08-23 12:08:36 -04:00
Brendan Reilly
2cb057daf6 update 2021-08-12 15:53:53 -04:00
Brendan Reilly
39add4382c Clarify common 500 errors 2021-08-12 15:48:37 -04:00
Mike McLean
889a20990f PR#1726: Update handler name used by SQLAlchemy
Merges #1726
https://pagure.io/fm-orchestrator/pull-request/1726
2021-08-12 12:52:24 -04:00
Brendan Reilly
1883fa8567 Update handler name used by SQLAlchemy 2021-08-12 11:50:46 -04:00
Mike McLean
d115c86ec6 PR#1724: Improve error messaging for module submission.
Merges #1724
https://pagure.io/fm-orchestrator/pull-request/1724

Fixes: #1098
https://pagure.io/fm-orchestrator/issue/1098
[RFE] Improve the error messages when a user submits a module
2021-07-29 16:34:08 -04:00
Joe Talbott
06d31786e8 Improve error messaging for module submission.
Fixes: https://pagure.io/fm-orchestrator/issue/1098
2021-07-29 16:34:03 -04:00