336 Commits

Author SHA1 Message Date
Owen W. Taylor
e776a77048 Redirect createrepo_c output to the build logs
It's more useful to have the createrepo_c output in the build logs
than cluttering the build stdout.
2023-03-20 10:58:59 -04:00
Owen W. Taylor
cff90e587a builder/utils/execute_cmd: remove useless return value and add a test
Since we never pass in subprocess.PIPE for stdin/stdout/stderr,
subprocess.communicate() does nothing, and the return out/err tuple
was always empty.
2023-03-20 10:57:52 -04:00
Owen W. Taylor
728b96133d local builds: Don't call mock with -v
Verbose output from mock is not useful for someone trying to figure out
why their module build failed, and in fact makes it harder by adding
quite a bit of extraneous noise.
2023-03-20 10:55:28 -04:00
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
Brendan Reilly
d4c213d678 Resolve issues reported by bandit 2022-07-21 09:09:12 -04:00
Brendan Reilly
1da34c1649 Merge #1662 Improve test coverage for MockModuleBuilder 2022-05-03 16:43:27 +00: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
Mike McLean
865296b8c7 fix flake8 issues 2021-04-21 14:41:23 -04:00
Mike McLean
df5733d05d devel modules require non-devel, not themselves
Fixes https://pagure.io/fm-orchestrator/issue/1676
2021-02-08 19:59:02 -05:00
Brendan Reilly
169e5aa3b5 Do not login when getting final mmds 2020-06-23 14:09:52 -04:00
Brendan Reilly
db70560d2d Add API call to get final modulemds of builds 2020-06-22 11:31:05 -04:00
Brendan Reilly
e68f5c4c26 Use repo id instead of latest symlink
Fixes https://pagure.io/fm-orchestrator/issue/1581
2020-04-02 12:12:13 -04: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
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
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
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
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
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
1ab8aabd75 Remove outdated TODO comments in builder/base.py 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
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
Chenxiong Qi
e40fea9b1b Remove unused import from MockModuleBuilder.py
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Qixiang Wan
b782304487 Partially revert the change of split config (a207d97)
It turns out we still have some backend code relies on the flask app,
so revert the change to init_config, and make minor change to create
config object for frontend and backend with the same function.
2020-03-03 14:48:47 -05:00
Qixiang Wan
81d9554af3 Create config for frontend or backend seperately
1. init_web_config: create Config object for frontend, load
   configuration from `web_config.py`.
2. init_backend_config: create Config for backend, load configuration
   from `backend_config.py`.

And two new classes inherit from `Config` in config.py:

1. WebConfig: representing the orchestrator frontend web configuration
2. BackendConfig: representing the orchestrator backend workers
                  configuration

Before calling init_{web,backend}_config, check sys.argv, if
"fedmsg-hub*", "celery" or "build_module_locally" is present, it's
running as backend.
2020-03-03 14:48:47 -05:00
Jan Kaluza
f8079308b1 Replace further work by Scheduler class based on the "sched" module.
To support multiple backend, we need to get rid of `further_work` concept
which is used in multiple places in the MBS code. Before this commit, if
one handler wanted to execute another handler, it planned this work by
constructing fake message and returning it. MBSConsumer then planned
its execution by adding it into the event loop.

In this commit, the new `events.scheduler` instance of new Scheduler
class is used to acomplish this. If handler wants to execute another
handler, it simply schedules it using `events.scheduler.add` method.

In the end of each handler, the `events.scheduler.run` method is
executed which calls all the scheduled handlers.

The idea is that when Celery is enabled, we can change the
`Scheduler.run` method to execute the handlers using the Celery, while
during the local builds, we could execute them directly without Celery.

Use of Scheduler also fixes the issue with ordering of such calls. If
we would call the handlers directly, they could have been executed
in the middle of another handler leading to behavior incompatible
with the current `further_work` concept. Using the Scheduler, these
calls are executed always in the end of the handler no matter when
they have been scheduled.
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
db20065e74 Clear up module_build_service.messaging
Message classes and FedmsgMessageParser are moved into dedicated Python module
under scheduler/ directory.

FedmsgMessageParser is decoupled from messaging.py by initializing a parser
object with known fedmsg services. This decouple avoids cycle import between
parser.py and messaging.py.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Chenxiong Qi
3d771aac10 Fix a typo
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-01-10 16:08:33 +08:00
Brendan Reilly
c349946718 use gssapi if correct python-requests-kerberos is available 2020-01-09 10:01:36 -05:00
mprahl
3051596166 Remove the koji.ClientSession backport
See https://pagure.io/koji/pull-request/1187 for context.
2019-12-02 12:07:40 -05:00
Matt Prahl
f487da140b Merge #1524 Gracefully handle builds without a koji tag 2019-11-22 16:26:12 +00:00