Commit Graph

2702 Commits

Author SHA1 Message Date
mprahl
fd93c8f436 Force the Celery workers to run only one task at a time
This forces the tasks to be run serially.
2020-03-03 14:48:47 -05:00
mprahl
884d7fb79c Use double quotes to match the coding standard 2020-03-03 14:48:47 -05:00
Chenxiong Qi
e7a3e8a19e Schedule event handler to queue from internal
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Qixiang Wan
f2b57c7d91 Remove some default values from settings
Some of the config vars have default values, it is unncessary to keep
them in settings.

Note: Some vars are still in conf/config.py even they have the default
values, like the '*_url' vars, they're kept there just as placeholder
and reminder for changing while deploying the service.
2020-03-03 14:48:47 -05:00
Qixiang Wan
6907e02c13 Revert the config split change
Revert the changes in a207d97 and 9a2efb3, at this moment, some code
relies on both settings from frontend and backend, and it's inconvenient
to run unittests with config split up to frontend only and backend
only.
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
e87b39cfb0 Remove MBSProducer from entry points 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
Chenxiong Qi
e673f690a9 Add python3-celery to Vagrantfile
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:47 -05:00
Jan Kaluza
d5cb97b4b6 Allow building modules locally without fedmsg-hub.
We started using `events.scheduler` to plan fake events instead of internal
queue implemented by fedmsg-hub. Thanks to that, we can stop using fedmsg-hub
completely for local builds.

In this commit, the `scheduler.local.main` is rewritten to not use fedmsg-hub.
The original `scheduler.local.main` is still needed by test_build tests and
therefore it is moved there.
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
9049eea35c Register handlers as Celery tasks 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
b5bcc981f9 Add celery app instance with base config
This patch allows to schedule tasks and launch workers with basic
config. To launch a worker:

    celery -A module_build_service.celery_app -l info

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
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
Chenxiong Qi
5a883f6cc6 Access configured messaging backend directly
The accessible configured messaging backend is sigleton. This patch make
it possible to access the configured backend and avoid accessing a
"private" variable from module messaging.

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
3aae931382 Remove unused argument arches from add_default_modules
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-03-03 14:48:46 -05:00
Matt Prahl
8eb2301d43 Merge #1583 Add workaround for DNF fail-safe mechanism 2020-03-03 18:45:08 +00:00
Matt Prahl
02b11426e7 Merge #1590 Fix $PATH when running tests using podman 2020-03-03 18:43:23 +00:00
Martin Filip
22ebbad64b Add test_build_stream_collision.py and example config 2020-02-28 11:45:24 +00:00
Merlin Mathesius
5b6252b194 Fix $PATH when running tests using podman
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2020-02-17 14:27:52 -06:00
Michal Kovarik
7bae720b81 C3I: Fix permissions on new c3i project.
Allow service account used by pipeline-as-a-service to manage resources
in project created via c3i-as-a-service.
2020-02-14 07:21:38 +01:00
Hunor Csomortáni
401d8aa3b8 Merge #1582 Document integration test case and test environment design 2020-02-07 10:24:42 +00:00
Mike Bonnet
762cc5cfd6 typo in integration tests
Missing comma.
2020-02-06 11:43:13 -08:00
Michal Kovarik
07806dba2c C3I: Use new SERVICES_TO_DEPLOY parameter
Allows to whitelist services to be installed.
2020-02-06 01:14:44 +00:00
Brendan Reilly
0a0c1266a1 Updated koji tests for new mock option 2020-02-04 14:20:18 -05:00
Mikolaj Izdebski
2d1b056508 Add workaround for DNF fail-safe mechanism
Fixes #1525
2020-02-04 14:09:06 -05:00
Hunor Csomortáni
3ed1180669 Document integration test case and test environment design
Update the integration test README to explain the design of the test
case and test environment code. This should help future contributors.

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
2020-01-30 15:36:05 +01:00
Mike McLean
01a04ed793 Release v2.32.0 v2.32.0 2020-01-30 12:25:15 +01:00
Martin Filip
ae60a344b1 Add test_normal_build_conflict 2020-01-29 16:29:51 +01:00
Hunor Csomortáni
7f67c2f6f6 Merge #1567 Module Stream Expansion integration test 2020-01-23 13:28:24 +00:00
Mariana Ulaieva
fefeafa572 Implement the Stream Expansion scenario 2020-01-23 14:26:46 +01:00
Mariana Ulaieva
a5f6d8f136 Factor out packaging utility
Until now, it was assumed that the module-build command returned only
one build, so it was only one build_id. However, it is possible that
the module-build command will build more than one builds and therefore
a list of build_ids is needed. Also is needed to watch and cancel more
than one build.
For this reason run, watch, and cancel methods are methods of the
PackagingUtility class instead of Build class.  Run method returns list
of Build objects instead of build_id. And it's also possible to cancel
and to watch on all generated module builds.
2020-01-23 14:26:46 +01:00
Michal Kovarik
de9443a74a C3I: Rewrite test into bash to be re-usable
Move execution logic from groovy scripts to bash. To be possible to run
them from any environment.
Setup pipeline using provion endpoint.
2020-01-23 07:32:03 +01:00
Hunor Csomortáni
f35935c143 Add rpm-py-installer as a dependency for the integration tests
'rpm' is an optional dependency for kobo, which is required by the
integration tests.

Previously this dependency was implicitly satisfied by 'koji' pulling
in 'rpm-py-installer' which made sure 'rpm' is available. But
koji==1.20.0 made this dependency optional, so importing kobo.rpmlib
started failing.

Fix this by making 'rpm-py-installer' and explicit dependency for the
integration test environment.

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
2020-01-21 10:30:21 +01:00
Matt Prahl
66a2362a90 Merge #1552 Fix the provides of base modules 2020-01-16 19:38:55 +00:00
Brendan Reilly
c2561da405 Added unit tests for add_base_module_provides 2020-01-16 14:26:04 -05:00
Hunor Csomortáni
5f7442f8c1 Tests: Create a fixture for scenario configuration
Until now, to access the configuration of a scenario, the full path in
test_env had to be specified.

This might be cumbersome and error prone.

Create a scenario fixture, to make it easier to access the same
configuration.

Instead of

    test_env["testdata"]["my_scenario"]["my_config"]

one can use the following:

    scenario["my_config"]

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
2020-01-16 10:29:14 +01:00
Luiz Carvalho
351eb671f6 Merge #1546 No components integration test 2020-01-10 14:06:44 +00:00
Mariana Ulaieva
c35fe26e73 No components integration test
Implement the Module With No Components integration test.
2020-01-10 14:38:13 +01:00
Chenxiong Qi
3d771aac10 Fix a typo
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2020-01-10 16:08:33 +08:00
Matt Prahl
fef0ffaf53 Merge #1563 use gssapi if correct python-requests-kerberos is available 2020-01-09 16:38:00 +00:00
Brendan Reilly
c349946718 use gssapi if correct python-requests-kerberos is available 2020-01-09 10:01:36 -05:00
Brendan Reilly
df319e14ce Fix the provides of base modules when it has a stream version 2020-01-07 11:33:56 -05:00
Mike McLean
6b85a31e0d close dnf base instance after we're done with it 2019-12-20 09:55:09 -05:00
Mike McLean
1fae917fc3 error if repo metadata fails to load 2019-12-20 09:55:09 -05:00
Mike McLean
0d66e24a05 make dnf timeout configurable 2019-12-20 09:55:09 -05:00