689 Commits

Author SHA1 Message Date
Chenxiong Qi
6f1d0b3ad9 Return empty result if short=true is specified on empty list of builds
Fixes #1376

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-08-11 22:18:38 +08:00
Valerij Maljulin
e5735efc76 Skip prefix validation for modules in allowed_privileged_module_names and base_module_names
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-08-07 14:17:39 +02:00
Jan Kaluža
758cf9c112 Merge #1365 Allow components to be reused from module builds even if the buildrequires commit hashes changed for the changed-and-after rebuild strategy 2019-08-06 11:08:46 +00:00
mprahl
a6bf9f88dd Allow components to be reused from module builds even if the buildrequires commit hashes changed for the changed-and-after rebuild strategy
This behavior was not documented, and it was confusing to users since module builds
in a stream should always have a compatible API.
2019-08-05 09:23:44 -04:00
Chenxiong Qi
9c6c4da80f Rewrite import_mmd
* xmd/mbs is always set if it is not present in xmd, so move the code on
  the top of function. This change is also helpful for accessing keys
  under xmd/mbs.
* By setting xmd/mbs in the beginning, code is simplified to get
  disttag_marking and virtual_streams. The result is much straightforwar
  for getting a default value for them.
* Move disttag_marking validation code next to the line getting
  disttag_marking from xmd/mbs. As a result, the code structure is
  easier to read as getting disttag_marking and validate it, getting
  virtual_streams and validate.
* Rewrite the part of code for check_buildrequires. Always set
  xmd/mbs/buildrequires if it is not present and check_buildrequires is
  set to True, as it is required by
  ModuleBuild.get_buildrequired_base_modules.
* Using in operator instead of dict.get to check if key koji_tag exists.
  Using dict.get would be ambiguous because even if koji_tag exists
  under xmd/mbs, but due to its value is set to None occasionally, there
  is still a message logged to tell koji_tag is not set.
* Rwrite all lines of code for updating virtual streams. A new method
  update_virtual_streams is added to ModuleBuild. This also fixes
  FACTORY-4561.
* Tests are added for the rewrite of virtual streams update.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-08-05 16:10:57 +08:00
Jan Kaluža
8dd65a79fa Merge #1340 Added an REST endpoint to display log messages 2019-07-31 12:49:03 +00:00
Martin Curlej
c5d484fb81 Added an REST endpoint to display log messages
The issue is that users don't get feedback from MBS about why a
component was not reused. There was added logic which enables to
store log messages in the database and can be viewed through the
REST api of MBS.

Ticket-ID: #1284

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
2019-07-31 13:32:33 +02:00
Valerij Maljulin
5fb6a2f28a Check dependencies in reuse
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-07-31 11:23:52 +02:00
Chenxiong Qi
308f5bc7cf Serialize component build state trace correctly if state is None
Fixes #1179

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-29 15:56:30 +08:00
Jan Kaluža
26c816f04c Merge #1356 Refactor make_module for tests 2019-07-23 10:50:19 +00:00
Qixiang Wan
ab8abef058 Fix recover_orphaned_artifact for module-build-macros
When recover_orphaned_artifact is called for module-build-macros
and the module-build-macros is not tagged in the -build Koji tag,
then the tag_artifacts() is called to tag it there.

This is correct, but the issue is that module-build-macros need
to be added to "build" and "srpm-build" Koji tag groups, otherwise
it is not installed in the buildroot by default.
2019-07-23 16:11:27 +08:00
Chenxiong Qi
b242b12136 Remove handling of negative deps in _deps2reqs
Fixes #1338

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-22 15:24:07 +08:00
Chenxiong Qi
5017fbae7f Refactor make_module for tests
The original motivation for this refactor is to reuse make_module and
drop TestMMDResolver._make_mmd. Some tests require a modulemd created
and some tests also require those modulemd to be stored into database as
a module build. The problem is db_session has to be passed to
make_module even if no need to store into database.

Major changes in this patch:

* Argument db_session is optional.
* Arguments requires_list and build_requires_list are replaced by a
  single argument dependencies which is a list of group of requires and
  buildrequires
* A new make_module_in_db is created for creating and storing the new
  modulemd into database conveniently.
* Tests are updated with the new make_module and make_module_in_db.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-22 10:07:53 +08:00
Chenxiong Qi
f5717e3469 Fix incorrect error message and method call on ComponentRpm
When resubmitting a module build, if some component is found out that
its attributes have changed, MBS will raise an error to stop the work to
recording components. The problem is original code tells a module build
exists in database already rather than a component build, meanwhile
get_module_name() call on an ComponentRpm object is also incorrect.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 22:09:45 +08:00
Chenxiong Qi
26033bd8f7 Reuse ComponentBuild.from_component_name in tests
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 22:09:41 +08:00
Chenxiong Qi
3878affa41 Separate use of database sessions
This patch separates the use of database session in different MBS components
and do not mix them together.

In general, MBS components could be separated as the REST API (implemented
based on Flask) and non-REST API including the backend build workflow
(implemented as a fedmsg consumer on top of fedmsg-hub and running
independently) and library shared by them. As a result, there are two kind of
database session used in MBS, one is created and managed by Flask-SQLAlchemy,
and another one is created from SQLAclhemy Session API directly. The goal of
this patch is to make ensure session object is used properly in the right
place.

All the changes follow these rules:

* REST API related code uses the session object db.session created and
  managed by Flask-SQLAlchemy.
* Non-REST API related code uses the session object created with SQLAlchemy
  Session API. Function make_db_session does that.
* Shared code does not created a new session object as much as possible.
  Instead, it accepts an argument db_session.

The first two rules are applicable to tests as well.

Major changes:

* Switch tests back to run with a file-based SQLite database.
* make_session is renamed to make_db_session and SQLAlchemy connection pool
  options are applied for PostgreSQL backend.
* Frontend Flask related code uses db.session
* Shared code by REST API and backend build workflow accepts SQLAlchemy session
  object as an argument. For example, resolver class is constructed with a
  database session, and some functions accepts an argument for database session.
* Build workflow related code use session object returned from make_db_session
  and ensure db.session is not used.
* Only tests for views use db.session, and other tests use db_session fixture
  to access database.
* All argument name session, that is for database access, are renamed to
  db_session.
* Functions model_tests_init_data, reuse_component_init_data and
  reuse_shared_userspace_init_data, which creates fixture data for
  tests, are converted into pytest fixtures from original function
  called inside setup_method or a test method. The reason of this
  conversion is to use fixture ``db_session`` rather than create a
  new one. That would also benefit the whole test suite to reduce the
  number of SQLAlchemy session objects.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 21:26:50 +08:00
Jan Kaluža
64698fbde8 Merge #1348 Reset FakeModuleBuilder.on_get_task_info_cb properly for TestBuild 2019-07-18 10:48:48 +00:00
Jan Kaluža
1c76f1223e Merge #1335 Call _get_base_module_stream_overrides when the module is not the input module 2019-07-18 10:38:27 +00:00
Chenxiong Qi
f4c5334894 Reset FakeModuleBuilder.on_get_task_info_cb properly for TestBuild
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-17 22:12:41 +08:00
mprahl
1bcb40d4d0 Allow specifying a specific module build to reuse components from
This resolves #1296.
2019-07-16 11:40:59 +00:00
mprahl
0466ac394b Call _get_base_module_stream_overrides when the module is not the input module
This just simplifies the code. It doesn't change the functionality
at all. The tests had to be changed because it assumed that the
xmd.mbs.buildrequires section would be filled out for the input
module which isn't true.
2019-07-15 13:17:36 -04:00
mprahl
ec8946af05 Use get instead of filter_by in test_poller.py to be consistent
This is based on the feedback in PR #1341
2019-07-15 11:22:24 -04:00
mprahl
18def28d2b Fix the unit tests when running with Postgresql 2019-07-15 11:06:52 -04:00
Luiz Carvalho
e35596b6f2 Remove duplicated build refresh from tests
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
Luiz Carvalho
302e905f49 Rename trigger_new_repo_when_stalled accurately
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
Luiz Carvalho
9e50e9e268 Do not start newRepo task if one in progress
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>

Check task status on producer - to be squashed

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
mprahl
82ec6944c6 Prevent overlapping RPMs from buildrequired base modules from being available when using default modules
When using default modules, this feature will add conflicts to
module-build-macros for every RPM in a buildrequired base module
that overlaps with RPMs in the buildrequired modules. This will
prevent them from being available in the buildroot, and thus
ensure that the RPMs from the buildrequired modules (non-base
modules) are used even if they have a lower NVR.
2019-07-11 09:21:09 -04:00
Jan Kaluža
b3c32ec859 Merge #1294 Allow modules built against platform in 'garbage' state to be used as build dependency. 2019-07-10 09:21:30 +00:00
Jan Kaluza
e9f5b4e2db Fix unreliable test in test_module_init.py. 2019-07-09 11:26:02 +02:00
Jan Kaluza
95febc2e1b Allow modules built against platform in 'garbage' state to be used as build dependency. 2019-07-09 07:35:01 +02:00
mprahl
96d44d049e Add the ability to automatically buildrequire default modules defined by the buildrequired base module
A base module can set xmd.mbs.default_modules_url, which contains a
URL to a list of modules in the format of name:stream separated by
new lines. When a module buildrequires this base module, the list
of default modules are added as buildrequires of the module automatically
unless there are conflicting streams or the default module is not
in the MBS database.
2019-07-05 14:52:50 -04:00
mprahl
9f55ce724d Add a global requests session with retry logic configured
This also replaces the usage of other request sessions.
2019-07-03 09:00:49 -04:00
mprahl
db03f0a7f5 Promote resolver._get_module to a public method 2019-07-02 10:45:31 -04:00
Chenxiong Qi
16bf4e945b Reuse ModuleBuild.get_by_id
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-02 20:52:12 +08:00
Chenxiong Qi
c15a7cadf3 Reuse function read_staged_data
In addition, reuse staged_data_filename to construct file and directory name.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-02 20:52:12 +08:00
Chenxiong Qi
e49f69f7b5 Fix tests in order to run with PostgreSQL
Most of the issues are caused by the use of SQLAlchemy database session. Some
inline comments describe the issues in detail.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-06-28 14:48:37 +08:00
Valerij Maljulin
f0dc0b851d Add state_reason on GW failure
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-06-25 17:39:40 +02:00
Martin Curlej
ed24ca870a Module builds now remember what module they reused for building.
There was a race condition, when 2 builds where build in the same time.
There was an issue that after one has finished the other reused the new build
for reuse and not the one it started with.

Ticket-ID: FACTORY-3862

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
2019-06-25 11:09:33 +02:00
Jan Kaluza
c9d2b77167 When no architecture is set in Koji tag, fallback to conf.arches 2019-06-19 14:32:10 +02:00
mprahl
1a17d655ee Accept floats when filtering by stream_version_lte on the API 2019-06-18 10:19:00 -04:00
Jan Kaluža
5794c4375d Merge #1281 Allow buildrequiring modules built against all platform streams. 2019-06-17 05:27:32 +00:00
Jan Kaluza
2778c39765 Allow buildrequiring modules built against all platform streams.
This commit fixes issue with following situation:

Module `foo` has been built with `buildrequires: platform: [f28]`
and `requires: platform: []`. It can therefore be used as a buildrequirement
on any platform stream. But if you want to build module `app` which
buildrequires `foo` on `platform:f30`, the MBS won't pull-in the `foo`
module build, because MBS currently limits the modules by the platform
they have been built for.

This commit adds new config option to allow including modules built
against any platform stream.
2019-06-17 07:25:50 +02:00
sarah256
0d3655c2a8 Invalid scmurl on import should yield status 400 2019-06-12 10:21:13 -04:00
Jan Kaluza
511cad8c14 Check if buildopts.get_rpm_whitelist() is really set before using it.
This fixes module builds which sets the `buildopts` for something else
than the RPM whitelist.

Before this commit, when `buildopts` was set, the RPM whitelist was
always taken from the buildopts even if it was not defined there.
This resulted in empty `rpm_whitelist` and therefore no pkglist set
in Koji tag.

In this commit, MBS uses whitelist from `buildopts` only if it is
really set by the module maintainer.
2019-06-12 14:17:26 +02:00
Jan Kaluža
d34118cae4 Merge #1277 Take the list of arches for -build Koji tag from buildrequired modules. 2019-06-07 13:36:48 +00:00
Jan Kaluza
bf0bcaff57 Take the list of arches for -build Koji tag from buildrequired modules.
Currently, we are using just `conf.arches` and `conf.base_module_arches`
to define the list of arches for which the RPMs in a submitted module are
built. This is not enough, because RCM needs to generate modules based
on the base modules which should use different arches.

This commit changes the MBS to take the list of arches from the buildrequired
module build. It checks the buildrequires for "privileged" module or base
module and if it finds such module, it queries the Koji to find out the list
of arches to set for the module.

The "privileged" module is a module which can override base module arches
or disttag. Previously, these modules have been defined by
`allowed_disttag_marking_module_names` config option. In this commit,
this has been renamed to `allowed_privileged_module_names`.

The list of arches are stored per module build in new table represented
by ModuleArch class and are m:n mapped to ModuleBuild.
2019-06-07 13:16:31 +02:00
mprahl
4aeabc0f9b Set the test data in test_submit_build_automatic_z_stream_detection to match the actual use-case 2019-06-04 09:29:37 -04:00
Valerij Maljulin
52a600be40 Make sync_koji_build_tags poller working only with the builds that are in build state for some time
This fixes #1271

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-05-30 18:01:18 +02:00
Valerij Maljulin
13afde0124 Fix for test_sync_koji_build_tags
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-05-30 12:53:25 +02:00
Jan Kaluza
222f0417cf Use single session object in greenwave handler and call commit() in the end. 2019-05-29 13:45:08 +02:00