46 Commits

Author SHA1 Message Date
Brendan Reilly
f4040c09f4 Merge #1670 Go back to using a file-backed SQLite database for tests 2022-05-03 18:35:13 +00: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
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
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
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
c7c650a4f0 Move logger.py to common/logger.py 2020-03-03 14:48:47 -05:00
mprahl
7a42d89ba7 Move proxy.py to web/proxy.py 2020-03-03 14:48:47 -05:00
mprahl
e6b1372d5d Move 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
98b54d211e Move config.py to common/config.py 2020-03-03 14:48:47 -05:00
mprahl
f6bcdfa932 Simplify how MBS is configured
This merges the configuration from conf/config.py to
module_build_service/config.py. This also greatly simplifies the logic
in `init_config`. Additionally, `init_config` is no longer aware of
Flask. This will allow us to eventually break up the configuration
between the API and the backend.
2020-03-03 14:48:47 -05:00
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
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
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
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
mprahl
8c6cfb702d Use small license headers in the Python files
This also removes the outdated comments around authorship of each
file. If there is still interest in this information, one can just
look at the git history.
2019-10-03 08:47:24 -04:00
mprahl
14098cea08 Migrate to libmodulemd v2
This also moves the methods load_mmd and load_mmd_file to
module_build_service.utils.general.

This also removes some MSE unit tests with a mix of positive and
negative streams since this is not supported in libmodulemd v2. The
user will be presented with a syntax error if they try to submit
such a modulemd file.
2019-05-13 13:40:37 -04:00
mprahl
66c3f82160 Format the coding style across the codebase using "black" and manual tweaks
The main benefit of this commit is that the use of double quotes
is now consistent.
2019-04-26 00:32:13 -04:00
Valerij Maljulin
b39f92b820 Categorize log messages
This fixes #1064

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-03-13 13:38:08 +01:00
mprahl
25122cb53e Modify MBS to use a separate Kerberos context per thread so both threads can use the thread keyring to store the Kerberos cache
This commit includes the backport of the changes to `krb_login` in
https://pagure.io/koji/pull-request/1187. This change is required
for our separate threads to use a separate Kerberos context per thread.
2018-12-18 16:05:55 -05:00
mprahl
7f82275114 Force the use of a separte Kerberos cache per thread
When using a single Kerberos cache that is shared among threads,
Koji logins start failing because the cache gets corrupt. This uses
the Linux kernel keyring to store a Kerberos cache per MBS thread.

See https://web.mit.edu/kerberos/krb5-1.12/doc/basic/ccache_def.html
2018-12-12 19:04:00 -05:00
Jan Kaluza
a10abcdbcc Return string representation of exception instead of e.args[0] in Flask error handlers. 2018-08-21 11:21:04 +02:00
mprahl
19db295795 Fix flake8 errors 2018-04-03 09:58:57 -04:00
mprahl
5b278211e6 Add API v2 which will return a list of modules on build submissions based on module stream expansion 2018-04-03 09:58:57 -04:00
Jan Kaluza
1d46b332b3 Requires version 1.0 of Modulemd 2018-04-03 09:58:57 -04:00
Jan Kaluza
e5e9a24fce Allow adding bool to XMD. Fix flake8 issues. 2018-04-03 09:58:57 -04:00
Jan Kaluza
4001d3c488 Use in-memory SQLite database in tests to make them 40% faster. 2018-02-08 08:01:24 +01:00
Ralph Bean
56d01be3b0 Set an explicit log level on our per-build file handler.
This is a bit of a stab in the dark.

In some environments, our build.log files have little to no contents.  This
might be because we don't have an explicit log level set, but maybe not.
2017-12-15 16:24:27 -05:00
Jakub Kadlcik
f098e6e3b7 Make the module build log name configurable 2017-11-07 00:04:14 +01:00
Martin Curlej
60b3d97c97 flake8 cleanup
Signed-off-by: Martin Curlej <mcurlej@redhat.com>

removed some noqa tags
2017-10-25 12:13:59 +02:00
mprahl
6165fd5088 Add an API that exposes information about the MBS server 2017-09-19 16:48:28 -04:00
Filip Valder
1775d33f63 Fix/remove app recreation when used by Flask-Script (Manager) 2017-08-16 11:49:09 +02:00
Filip Valder
31b0e525c4 Fix #620: Support for log flags in mbs-manager and mbs-build 2017-08-04 15:27:23 +02:00
Filip Valder
7ef2975984 PEP8 fixes 2017-07-17 18:29:10 +02:00
Jan Kaluza
93092a43be Add per-module-build logging feature 2017-06-30 16:30:47 +02:00
Jan Kaluza
830b1dd111 Add tests for 'continue' part of start_next_batch and component resubmit 2017-03-16 11:20:51 +01:00
Filip Valder
13b7bcd03e Support for state tracing of modules and components
- DB migration scripts.
- Models: ComponentBuildTrace, ModuleBuildTrace.
- ModuleBuild.state_trace method for querying for a particular module's
state history.
- SQLAlchemy before commit session event handler for recording
module/component state changes.
- REST API verbose mode for getting state trace of a particular module.
- Tests use make_session, so that event handlers are in effect.
- Short info in README about verbose mode.
- Tests verifying whether state trace information about a module appears
in verbose mode.
- Other minor fixes (RidaBase -> MBSBase, PEP8...)
2017-02-28 16:15:43 +01:00
Ralph Bean
1cf582e866 Allow MBS to run behind a reverse proxy.
This fixes #352.
2017-02-24 10:23:35 -05:00
Ralph Bean
d13c7991ed Cleanup in preparation for package review.
I'm taking on #235.  This is all stuff that came up while doing a
cursory package review myself.

- The source files all state that they are MIT, but the specfile and
  repo claimed to be GPL.  I switched everything to MIT (even though I
  favor GPL.. the source was MIT first before it was incorrectly
  labelled GPL).
- There are various bugs and lint issues in the specfile fixed here.
- Notably, the systemd service file is missing from the 1.0.0 tarball on
  PyPI, so I'll need to do a new release after this.
2016-12-12 15:09:58 -05:00
Jan Kaluza
9eff11fdb0 Use timeout for build tests to prevent hanging, import queue from six.moves, fix init_logging import for jenkins 2016-12-06 11:33:15 +01:00
Filip Valder
88e6ddf953 configuration logic goes to config.py 2016-11-21 22:54:18 +01:00
Ralph Bean
d83f210297 Get tests of the retry decorator working in the test suite. 2016-11-18 10:19:41 -05:00
Jan Kaluza
966a73251a Add support for modulemd-1.0 backward-incompatible changes like commit being replaced by ref 2016-11-14 15:32:51 +01:00
Matt Prahl
b4082dc551 Rename module from rida to module_build_service
Rename routes from /rida/1/module-builds/ to /module-build-service/1/module-builds/
2016-10-24 10:30:23 -04:00