Commit Graph

1541 Commits

Author SHA1 Message Date
Owen W. Taylor
debfd8a5c5 Combine mock stderr and stdout logs
Mock doesn't normally log anything to stdout - so it's confusing to mention
separate logs in the messages. Combine the two output streams together.
(This is what koji does as well.)
2023-03-20 10:55:28 -04:00
Owen W. Taylor
48c4c75d73 MockModuleBuilder: Share root cache between threads
The different build threads all are using the same basic build root
contents, so there's no reason to use separate caches - point the
root cache plugin for mock to a single location. (There's locking
inside Mock for updating the root cache.)
2023-03-17 18:55:29 +00:00
Owen W. Taylor
f09d7cfe7f MockModuleBuilder: manage timestamps on mock config files
The mod time for the mock configuration file is used to determine
whether the root cache is out-of-date or not, so we want to avoid
changing the configuration timestamps when we don't change content
when we're just writing a per-thread mock configuration file again
with no substantive changes.

We do this by only updating the master mock.cfg file when we're
actually adding content, and propagating its mod time to the
per-thread configuration files.
2023-03-17 18:55:29 +00:00
Owen W. Taylor
d74eeb3941 MockModuleBuilder: Don't rewrite mock config to add SCM options
When we want to pass in SCM options particular to a specific module build,
do that on the mock command line rather than by modifying mock.cfg - this
avoids invalidating the root cache.
2023-03-17 18:55:29 +00:00
Owen W. Taylor
433ddce11c MockModuleBuild: Avoid accumulating blank lines around yum.conf
Every time we read-and-rewrote mock.cfg, we'd add another set of
blank lines around the yum configuration.
2023-03-16 13:19:03 +00:00
Owen W. Taylor
0a8160a91c MockModuleBuilder: add missing kwarg to tag_artifacts 2023-03-16 13:19:03 +00:00
Owen W. Taylor
9c1f0edd0e MockModuleBuilder: fix a typo in a comment 2023-03-16 13:19:03 +00:00
Owen W. Taylor
14597fb1a7 MockModuleBuilder: don't accidentally remove log files from other threads
The _purge_useless_log_files() method, if run at the wrong time, would
remove log files that other threads were still creating.
2023-03-16 13:19:03 +00:00
Owen W. Taylor
35086174ba Pass koji_tag to get_built_rpms_in_module_build()
For local builds, required modules are not necessarily in the local
database, so the method of looking up the build to find the koji tag
doesn't work reliably. However, the caller has the koji_tag - so just
pass it in.
2023-03-15 17:53:38 +00:00
Owen W. Taylor
646b0590ee MBSConsoleHandler: show status of ongoing repository downloads
When downloading files from Koji to make a local repository, display
a temporary status of which files are being displayed to the console
appended after any log messages. Updates are done by erasing the status
that was written, adding a log message, then writing the status again.
2023-03-15 17:16:24 +00:00
Owen W. Taylor
f5100609aa Filter console output through a special handler
When running in local mode, add a special handler that filters log
messages to the console to produce attractive output. Implemented
behaviors include:

 - INFO level messages are only displayed if done through
   MBSLogger.console() rather than MBSLogger.info().
 - Timestamps and thread names are omitted unless the local build
   is started with the -d option
 - Warning/error messages have the level highlighted in red
 - Special handling can be added to log messages, initially:
    - Long running operations can be displayed to the console as
      "Doing foo ... <pause>done"
2023-03-15 17:16:24 +00:00
Owen W. Taylor
4f3c60c808 batches.py: Fix handling of "changed-and-after"
all_reused_in_prev_batch should only check components in the previous
batch, not components in all batches including future batches. This
was accidentally regressed by some code refactoring in c36bd7ebac.
2023-03-07 21:08:55 +00:00
Owen W. Taylor
a276a33969 LocalBuildConfiguration: log to <build_dir>/build.log not <build_dir>/build-2.log
Since the build log is already within the a build-specific directory, we
don't need to put the build ID (which ends up always being "2") into the
build log filename.
2023-03-07 18:33:30 +00:00
Owen W. Taylor
1c8e2a07d8 Local builds: buffer up initial logs and replay to the module build file
Logging during a build that occurs before the build directory is created
used to be logged to the console, but not retained in the build log
file. This made referring to the build log file confusing. Solve this
by buffering logs in memory until the log file is created and replaying
them.

A little bit of hackery is needed to avoid saving dangling references to
libsolv objects.
2023-03-07 18:33:30 +00:00
jmicanek
8709c632b0 Allow krb ccache to be configured
Access to the kernel keyring may be restricted in containers. Allow users to specify non keyring ccache for kerberos.
2023-02-27 18:35:53 +01: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
2e373d2fe0 local.py: Pass state to modules_failed_handler() correctly
Handlers take a state integer rather than a string
2023-02-16 18:10:00 +00:00
Owen W. Taylor
b6c11f83d8 Improve handling of configuration file
* Allow MBS_CONFIG_FILE="" to entirely suppress loading any configuration
   file (useful for running tests and avoiding loading a system-wide
   configuration file.)
 * When loading the configuration file:
   * If the default configuration file path doesn't exist, silently fall back
     to the default configuration
   * For any other OSError, print the exact error
   * Let any other exception throw through, to allow people to debug their
     configuration file
2023-01-23 18:39:25 -05:00
Brendan Reilly
6b43180229 Replace deprecated getargspec with getfullargspec 2022-12-19 13:45:46 -05:00
Brendan Reilly
ac2a338786 Add workaround for upgradedb entrypoint 2022-12-15 15:11:47 -05:00
Brendan Reilly
f12fc9c969 Use click instead of flask script 2022-12-13 13:31:56 -05:00
Mike McLean
a014f20f15 handle default_ref recursively for module components 2022-11-21 15:17:30 -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
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
bcb62004ca Merge #1747 Architecture limited module builds fail to build locally 2022-10-11 13:33:55 +00:00
Brendan Reilly
79e3eae43e Add delay to missed new repo check 2022-09-02 12:01:34 -04:00
Brendan Reilly
d4c213d678 Resolve issues reported by bandit 2022-07-21 09:09:12 -04:00
Brendan Reilly
fedbfc37e1 Pass connect args to sqlalchemy 2022-06-22 13:59:44 -04: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
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
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