Commit Graph

130 Commits

Author SHA1 Message Date
Valerij Maljulin
95bacc4e15 Add greenwave query to done handler
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-05-17 16:10:06 +02:00
mprahl
d0f03daf61 Raise a ValidationError when buildonly or buildafter are set
This can be reverted when #1216 is implemented.
2019-05-13 13:40:37 -04:00
mprahl
67ad5dded7 Clean up test_format_mmd 2019-05-13 13:40:37 -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
37e4c718d9 Simplify format_mmd since scm.commit is always set or returns an exception 2019-05-06 15:13:24 +00:00
Valerij Maljulin
1b486b1625 Greenwave query class and configuration update
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-04-29 18:15:23 +02: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
mprahl
16091b7d86 Revert "Allow getting the latest stream of base module."
This reverts commit bc4a019e7d.

The approach taken causes MBS to submit module builds for every platform
stream, which is incorrect.
2019-04-25 13:04:18 -04:00
Chenxiong Qi
1146bb3043 Reuse function load_mmd
GenericResolver.extract_modulemd is not removed, but deprecated. Call of it
will result in a deprecation message printed. Any new code should call
load_mmd.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-04-25 17:05:43 +08:00
Matt Prahl
4858e64d96 Merge #1210 Allow passing --platform-id (-p) to build_module_locally. 2019-04-11 17:19:22 +00:00
Jan Kaluza
40ed1cbfdc Allow passing --platform-id (-p) to build_module_locally.
Currently, the PLATFORM_ID is parsed from the `/etc/os-release`. This
is good default value, but sometimes you want to build module locally
against the different platform stream.

For example building on platform:f29 against the platform:f30 modules. In
that case, we need to be able to override the host PLATFORM_ID and
set it manually chosen value.
2019-04-11 14:45:15 +02:00
Jan Kaluza
3cfefd7e0b Allow importing MMD without xmd["buildrequires"].
When importing modules for offline local builds from local repositories,
the XMD section does not have to be set at all - it gets removed during
the compose and is also MBS specific.

We need to be able to import such MMDs using the `import_mmd` method
in order to make --offline local builds working.

This commit adds new `check_buildrequires` bool kwarg in `import_mmd`
method to disable `xmd["buildrequires"]` checks to fix this.
2019-04-11 06:45:53 +02:00
Jan Kaluza
bc4a019e7d Allow getting the latest stream of base module.
If base module name:stream is not found, consider `stream` as virtual stream
and return the latest (the one with highest stream_version) base module with
that virtual stream.
2019-04-04 17:21:49 +00:00
mprahl
9512a49631 Allow whitelisted buildrequires with xmd.mbs.disttag_marking set to influnece the disttag 2019-04-04 09:12:27 -04:00
mprahl
1570db8a7e Don't allow a user to set the xmd.mbs field in their modulemd 2019-04-04 09:12:27 -04:00
mprahl
f1480feec2 Allow importing modules without a Koji tag
These module builds will basically act as metadata-only module builds.
This will be more useful as additional features stem from these types
of builds.
2019-04-04 09:09:38 -04:00
mprahl
bc2a1e8d3c Fix the unit tests 2019-04-03 14:40:52 -04:00
Owen W. Taylor
da57146bf2 GenericBuilder: Add a boolean 'succeeded' parameter to finalize
Previously MockModuleBuilder was checking the module state to see if
it should run a final createrepo, but since eafa93037f, finalize() is
called before changing the module state; add an explicit boolean to
GenericBuilder.finalize() to avoid worrying about ordering.
2019-04-03 18:12:57 +00:00
Jan Kaluza
67a5a9d1b0 Allow building module in --offline module with dependencies from local repositories.
There are following changes introduced in this commit:

- The `koji_tag` of module builds imported from the local repositories
  is now in `repofile:///etc/yum.repos.d/some.repo` format to store the
  repository from which the module was imported to local MBS DB.
- The `koji_tag` of fake base module is set to empty `repofile://`
  and in `MockModuleBuilder` the `conf.base_module_repofiles` list
  is used as source for the repositories defining platform. We can't
  simply use single repository, because there might be fedora.repo
  and fedora-update.repo and so on.
- The list of default .repo files for platform are passed using the
  `-r` switch in `build_module_locally` `mbs-manager` command.
- The LocalResolver (subclass of DBResolver) is added which is used
  to resolve the build dependencies when building modules offline
  locally.
- The `MockModuleBuilder` enables the buildrequired modules and
  repositories from which they come in the mock config.

With this commit, it is possible to build testmodule locally
without any external infra.
2019-04-01 13:13:08 +00:00
Jan Kaluza
e43d979bc8 Import modules found in the local repositories to MBS database for Offline local builds.
This is the first PR in many for Offline local builds. This PR:

- Adds --offline flag to build_module_locally mbs-manager command to enable
  offline local builds.
- If this flag is used, new `import_builds_from_local_dnf_repos` method is
  called which uses DNF API to get all the available installable modulemd
  files and imports each module into MBS local SQLite database.
- It also adds fake "platform:stream" module based on the /etc/os-release,
  so the buildrequirements of the imported modules are satisfied.

The idea here is that in upcoming commits, I will create LocalResolver
which will be similar to DBResolver with some extra rules to resolve
local module builds. This new LocalResolver will still be based on
the models.ModuleBuild methods and therefore we need the modules
imported in database.
2019-04-01 13:13:08 +00:00
Jan Kaluza
780ed117b4 Find compatible base modules based on the virtual streams.
Before this commit, the compatible base modules for Module Stream Expansion
have been found without any limitation, just based on the stream version.
It was therefore possible that `platform:lp29.0.0` was found as compatible
module for `platform:f29.1.0` although those platform streams are not
compatible at all.

In this commit, the module can be treated as compatible only if it has
the same virtual stream as the input module. The idea behind this
is that both `platform:f29.0.0` and `platform:f29.1.0` should include
the `virtual_streams: [f29]` in their XMD section which tells MBS
that they are actually compatible. The `lp29` stream will not
have the same virtual stream (most likely it won't have any virtual
stream at all).

The `virtual_streams` is already used for this use-case in `MMDResolver`,
but it was not used to limit the inputs to `MMDResolver` which is what
this commit is doing.

This commit also fixes the issue in `get_last_builds_in_stream_version_lte`
which was simply broken if multiple stream_versions of single base module
existed and their builds had different version. In this case, only
builds with single (randomly chosen) version were returned.
2019-03-25 16:53:54 +01:00
mprahl
275e7e4509 Remove the concept of required and optional parameters
Since the required parameters vary based on if the modulemd
comes from SCM or a direct submission, the concept of optional
parameters doesn't really apply.
2019-03-19 08:02:39 -04:00
mprahl
40e534ff9d Don't allow a dash in the value that will be used for an RPM disttag
When importing a base module, we must ensure the value that will be
used in the RPM disttags doesn't contain a dash since a dash isn't
allowed in the release field of the NVR.
2019-03-15 13:14:25 -04:00
mprahl
6bb41e786c Add the ability to override the base module marking used in the RPM disttags
MBS uses the base module's stream that was buildrequired by the module
in the RPM disttags for that module build. The stream name may not be
ideal for all situations, so now this is customizable by setting the
xmd['mbs']['disttag_marking'] in the base module's modulemd.
2019-03-15 13:14:25 -04:00
Merlin Mathesius
152419f376 Module scratch build fixups per PR review feedback:
- Keep scratch module builds in the 'done' state.
- Make koji tagging for scratch modules unique so the same
  commit can be resubmitted.
- Use alternate prefix for scratch module build components so they can
  be identified later.
- Prevent scratch build components from being reused.
- Assorted code and comment cleanup.

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-01 10:27:04 -06:00
Jan Kaluza
efaaea66e0 Update the ModuleBuild.time_modified in case the format_mmd takes long time.
In case there is lot of components in a module build or there are some
networking issues and we need to retry the "git clone" commands, the
`format_mmd` method can take long time.

If it takes more than 10 minutes, the poller can produce fake event,
because it seems the module build is stuck. This is wrong, because
it would lead to another unexpected init handler call.

In this commit, the `format_mmd` updates the `ModuleBuild.time_modified`
method regularly to prevent poller from sending the unexpected fake
init message.
2019-02-15 15:20:34 +01:00
Jan Kaluza
40f23b65e4 Fix the handling of modulemd files with unicode characters.
This commit introduces new to_text_type helper method and calls it
for return value of all mmd.dumps() calls. That way, we always
end up with proper unicode string represntation on both python
major versions.

This commit also adds unicode character to description of all
the yaml files we use in the tests so we can be sure MBS can
handle unicode characters properly.

This might be temporary fix, depending on the result of discussion
at https://github.com/fedora-modularity/libmodulemd/issues/184.
2019-02-14 13:42:47 +00:00
Mike Bonnet
0f76fd5591 fix unicode/str/bytes inconsistencies 2019-02-08 17:43:42 +00:00
Mike Bonnet
a44e1fe4b0 fix cases where dict views could not be used in place of lists 2019-02-08 17:43:42 +00:00
Jan Kaluza
642c8406ca Allow setting context in the imported MMD file.
We always set the "context" to DEFAULT_MODULE_CONTEXT from the historical
reasons - the context was not stored in the database before and we stored
just the build_context/runtime_context. But this is no longer true for
some time.

In this commit, the context is respected and stored in the database when
importing module using the `import_mmd` method. If the context is not set
in the imported MMD, the DEFAULT_MODULE_CONTEXT is used.
2019-01-28 12:16:07 +01:00
Jan Kaluza
26d707cb8e Allow resubmiting the very same module build in case it results in new MSE build.
This is needed for Fedora branching, but it is generally useful.

For example, there is a module buildrequiring "platform:[]". In the time
this module has been built, only platform:f29 existed, so it has been built
just against platform:f29.

After a while, the platform:f30 is released and the maintainer needs
to rebuild the module against platform:f30. Right now, he needs to create
new commit in the module and submit the build, but this will result in useless
rebuild of the module also against platform:f29.

In this commit, MBS allows to resubmit the module build in a case
there are new MSE builds to build. MBS will send all the module builds
back to the user - so the existing builds will be already marked as
"ready" and the newly submitted builds will have the "init" state in
the REST API response.

However, in case when there are no new MSE builds to build, MBS still
sends back the Conflict error as it used to. This is done for backwards
compatibility and also to not confuse the users in case when no new build
has been submitted.
2019-01-28 10:53:37 +01:00
mprahl
9f9a025958 Use the https protocol to clone dist-git repos instead of the git protocol
You can read about this at:
https://fedoraproject.org/wiki/Infrastructure/HTTPS-commits

The bug was reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=1666257
2019-01-16 19:00:25 +00: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
9604da1b22 Fix a flake8 error 2018-12-05 09:13:26 -05:00
Chenxiong Qi
5579a0e72b Init event handler handles module stream collision
Fixes: FACTORY-3616

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-12-05 18:25:14 +08:00
Chenxiong Qi
41481afc75 Remove unuseful topurl from tests
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-11-27 11:06:34 +08:00
Chenxiong Qi
1cd64d336a Fix some minor issues
* Fix failure test after rebasing on master branch.
* Fix some grammar issues.
* Only check stream collision modules on new created module build.
* Logging message properly.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-11-27 11:06:34 +08:00
Chenxiong Qi
d517a72de9 Add _get_module in DBResolver and fix _record_ursine_rpms
_record_ursine_rpms needs to get each collision module's koji_tag and
then get built RPMs from that koji_tag eventually. _get_module on each
individual resolver is called to get module metadata accordingly. So,
when running a local build, module metadata is got from remote MBS, and
for a MBS instance, connected database is queried.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-11-27 11:06:34 +08:00
Chenxiong Qi
5d3ea762c6 Make external repo URL prefix configurable
Not both Fedora and internal Brew uses config topurl as the external
repo's URL prefix. Hence, make it configurable to fulfill this
difference.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-11-27 11:06:34 +08:00
Chenxiong Qi
917c06ad0c Resolve stream collision with modules added to ursine content
This resolve the stream collision by adding specific RPMs to
module-build-macros SRPM as Conflicts.

For more information about module stream collision, please refer to
docstring in utils/ursine.py

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-11-27 11:06:34 +08:00
Valerij Maljulin
8adce7593b set module build state to 'failed' imediately
Fixes #1009

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2018-11-15 17:13:34 +01:00
mprahl
1633e55917 Remove duplicate modulemds returned in utils.mse._get_base_module_mmds 2018-10-26 14:39:54 -04:00
Jan Kaluza
f2a236bc74 Pass buildrequired modules built against all compatible base module streams to MMDResolver.
Imagine we have "platform:f29.0.0" and "platform:f29.1.0" base modules.
We also have "DBI" module we want to build agaisnt "platform:f29.1.0".
This "DBI" module depends on "perl" module which is only build against
"platform:f29.0.0".

Currently, DBI build would fail to resolve the dependencies, because
it wouldn't find "perl" module, because it is built against different
platform stream.

This PR changes the MSE code to include buildrequired module builds built
against all the compatible platform streams.

It does so by introducing following changes:

- MSE code uses new get_base_module_mmds() method to find out all the
  compatible platform modules. This needed new methods in DBResolver
  and MBSResolver.
- For each buildrequired module defined by name:stream, the MSE code then
  finds particular NSVC built against each compatible platform module.

Side effect of these code changes is that every module now must buildrequire
some base module.
2018-10-26 14:02:36 +02:00
Chenxiong Qi
db4dbe3b25 Remove unused parameter session
_get_mmds_from_requires does not do anything against db.session. Hence,
remove parameter session from it and
get_mmds_required_by_module_recursively.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-10-22 11:48:04 +08:00
Chenxiong Qi
20de3d2e94 Make _make_module reusable
TestUtilsModuleStreamExpansion._make_module is moved to
tests/__init__.py so that other tests could reuse this to create a
module build.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-10-19 15:58:47 +08:00
Jan Kaluza
192eaae012 Support Virtual Streams in MMDResolver.
Modularity team needs to be able to define multiple streams for single "platform"
module. They need it to express that "platform:el8.1.0" also provides "platform:el8".

This needs changes in a way how MMDResolver resolves dependencies between modules.

For example, if we are building module against platform:el8.1.0, the MMDResolver must
not return buildrequired module built against platform > el8.1.0, but it can for example
return (cherry-pick) buildrequired module from platform:el8.0.0 if there is no such
module built for platform:el8.1.0.

The way how it is implemented is following:

  - MMDResolver reads list of virtual streams from xmd["mbs"]["virtual_streams"] when
    creating Solvable from MMD and adds additional Provides for these virtual streams.
    We expect these to be set mainly on base modules. The versions of such provides
    are based on "stream version" number, so we can compare them.
  - The base module ("platform") buildrequires of MMDs added to MMDResolver are overriden
    to mark particular platform "stream version". For example, if module "foo" buildrequires
    "platform:el8" in MMD file, but was in fact built against platform:el8.1.0, it will
    be treated as if it would really buildrequire "platform:el8.1.0". This is needed
    to not include buildrequired modules built against newer platform than what we want.
  - MMDResolver resolves all the valid combinations of buildrequires, but we are only
    interested in the one with latest versions of buildrequired module. Therefore the
    solve() method is changed to find out combinations which have the latest versions
    for each alternative name:stream buildrequires.
2018-10-18 15:06:04 +02:00
Valerij Maljulin
8ee7168017 get_reusable_component now checks the architecture
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2018-10-16 13:44:18 +02:00
Valerij Maljulin
7f60db545a renaming koji_arches to arches
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2018-10-15 15:29:50 +02:00
Valerij Maljulin
924a0951fb add architectures support for format_mmd 2018-10-15 15:29:50 +02:00
mprahl
117791ee16 Prefix the component disttag with the platform stream 2018-10-04 07:19:07 -04:00