3011 Commits

Author SHA1 Message Date
Brendan Reilly
e4dba5e242 Release 3.8.0 3.8.0 2022-12-07 13:06:00 -05:00
Mike McLean
407b93f9af Merge #1760 use branch name as default component ref 2022-11-22 14:40:09 +00:00
Mike McLean
a014f20f15 handle default_ref recursively for module components 2022-11-21 15:17:30 -05:00
Mike McLean
9287297943 fix unit test 2022-11-08 19:23:33 -05:00
Mike McLean
46f4f449a8 partial work 2022-11-08 14:39:24 -05:00
Mike McLean
1236fed8b8 bugfix 2022-11-08 14:39:24 -05:00
Mike McLean
79648cf188 use submitted branch as default ref for components 2022-11-08 14:39:24 -05:00
Mike McLean
d1180871de fix unit test 2022-11-08 14:39:24 -05:00
Mike McLean
879e3befae combine code for noting params in xmd 2022-11-08 14:39:24 -05:00
Brendan Reilly
1ff8f66c02 Merge #1743 Allow siblings in the garbage state 2022-11-03 14:56:39 +00:00
Brendan Reilly
9460b56f69 Release 3.7.0 3.7.0 2022-10-28 13:48:16 -04:00
Brendan Reilly
84b4199e7a Release 3.7.0 2022-10-28 13:37:53 -04:00
Brendan Reilly
bcb62004ca Merge #1747 Architecture limited module builds fail to build locally 2022-10-11 13:33:55 +00:00
Brendan Reilly
18cbd2d022 Merge #1758 Add delay to missed new repo check 2022-09-21 16:44:07 +00:00
Brendan Reilly
79e3eae43e Add delay to missed new repo check 2022-09-02 12:01:34 -04:00
Mike McLean
7f6f58401d Merge #1757 install mbs in the container images using pip 2022-08-24 21:54:07 +00:00
Mike Bonnet
ecf7da7aa3 install mbs in the container images using pip
Removing the requirement to build the rpm as part of the image build simplifies the
build process and reduces fragility introduced by trying to keep the rpm build and
image builds in sync.
2022-08-24 12:03:08 -07:00
Brendan Reilly
d676e06396 Merge #1745 Resolve issues reported by bandit 2022-07-21 13:10:10 +00:00
Brendan Reilly
d4c213d678 Resolve issues reported by bandit 2022-07-21 09:09:12 -04:00
Brendan Reilly
5066752004 Merge #1753 Pass connect args to sqlalchemy 2022-07-12 20:23:39 +00:00
Brendan Reilly
fedbfc37e1 Pass connect args to sqlalchemy 2022-06-22 13:59:44 -04:00
Brendan Reilly
3111c70f8a Merge #1744 Also run bandit during py3 unit tests 2022-05-25 15:57:17 +00:00
Brendan Reilly
3231d3584c Merge #1675 Don't traceback on failed builds 2022-05-19 18:30:20 +00:00
Brendan Reilly
687191681d Merge #1673 Improve exception and SIGINT handling for tests/test_build 2022-05-16 18:33:59 +00:00
Tomas Popela
31839917bc Architecture limited module builds fail to build locally
We use module builds as an intermediate build for building flatpaked
applications on Fedora. As Flatpaks in Fedora are officially supported
only on aarch64 and x86_64 we wanted to limit the builds just to these
architectures to save Fedora resources. We were able to do with commit
https://src.fedoraproject.org/modules/flatpak-common/c/65a01f which
works perfectly in koji/mbs, but doesn't work when run locally as the
build fails with following errors and exceptions:

info: Getting tag for flatpak-common:f36:3620220516070452
info: Start to handle flatpak-common:f36:3620220516070452:cab77b58 which is in init state.
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/handlers/modules.py", line 182, in init
    record_module_build_arches(mmd, build)
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/submit.py", line 150, in record_module_build_arches
    arches = get_build_arches(mmd, conf)
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/submit.py", line 95, in get_build_arches
    new_arches = _check_buildopts_arches(mmd, arches)
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/submit.py", line 131, in _check_buildopts_arches
    print(arches not in unsupported_arches, file=sys.stderr)
TypeError: unhashable type: 'list'
info: State transition: 'init' -> 'failed', <ModuleBuild flatpak-common, id=2, stream=f36, version=3620220516070452, scratch=False, state 'failed', batch 0, state_reason 'An unknown error occurred while validating the modulemd'>
warning: Note that retrieved module state 4 doesn't match message module state 'failed'
Traceback (most recent call last):
  File "/usr/bin/mbs-manager", line 33, in <module>
    sys.exit(load_entry_point('module-build-service==3.6.1', 'console_scripts', 'mbs-manager')())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/flask/cli.py", line 596, in main
    return super().main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/flask/cli.py", line 440, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/module_build_service/manage.py", line 171, in build_module_locally
    module_build_service.scheduler.local.main(module_build_ids)
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/local.py", line 57, in main
    raise_for_failed_build(module_build_ids)
  File "/usr/lib/python3.10/site-packages/module_build_service/scheduler/local.py", line 39, in raise_for_failed_build
    raise ValueError("Local module build failed.")
ValueError: Local module build failed.

The problem is that the code as it's now will fail to proceed if it will
detect any unsupported architecture - in this case the aarch64 even
tough the local x86_64 is supported. The check should be redone so if
there's an unsupported architecture detected, we should check that isn't
not the local one and proceed with the build, otherwise fail (the local
hardware doesn't support any of the specified architectures).
2022-05-16 14:18:22 +02:00
Brendan Reilly
17819cf6a6 Merge #1671 Avoid deep recursion when handling a large queue of events 2022-05-13 16:56:00 +00:00
Brendan Reilly
c24038198e Merge #1672 Don't pass SQLAlchemy objects between threads 2022-05-13 16:47:07 +00:00
Brendan Reilly
f4040c09f4 Merge #1670 Go back to using a file-backed SQLite database for tests 2022-05-03 18:35:13 +00:00
Brendan Reilly
a06d1a678d Merge #1746 Add default branch configuration option 2022-05-03 16:48:24 +00:00
Brendan Reilly
1da34c1649 Merge #1662 Improve test coverage for MockModuleBuilder 2022-05-03 16:43:27 +00:00
Brendan Reilly
6b76877d6d Merge #1661 MBSResolver - caching, tests, fixes 2022-05-03 16:42:22 +00:00
Brendan Reilly
9e8e296667 Merge #1658 Log cleanups for local builds 2022-05-03 16:41:17 +00:00
Owen W. Taylor
d050108d13 MBSResolver: cache results of MBS queries
Use dogpile.cache to avoid repeatedly making the same queries to the MBS.

We frequently query a list of modules, and then later in the build go
back and ask for details of those modules again by nsvc, so special case
querying a single module by nsvc and prime the cache for this from lists
of results.
2022-04-29 15:49:19 -04:00
Owen W. Taylor
c27e77c59d MBSResolver: improve efficiency of querying latest version
Only get 5 results at a time, and if we see that we're already
retrieving an old versions, stop requesting more pages.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
31fca9a962 100% test coverage for MBSResolver.py
Add new tests and modify existing tests so that test_mbs.py entirely
covers MBSResolver.py. To make the tests simpler, change from
explicitly expectations about the MBS API request => response sequence
to a stub local implementatin of the MBS API.
2022-04-29 15:47:08 -04:00
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