Commit Graph

637 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
4b5618f079 Add scratch to the short JSON
This is needed for the MBS-UI PR:
https://github.com/release-engineering/mbs-ui/pull/10
2019-05-16 15:44:09 +00:00
mprahl
85f1228b76 Remove an unnecessary print statement in the tests 2019-05-15 13:47:32 -04:00
mprahl
ea838a9855 Set nullable=False on the ModuleBuild.context column model to match the migration
The context column was added in d83e6897ca. The
migration set `nullable=False`, but the model kept the default of `nullable=True`.
This caused `mbs-manager db migrate` to create a migration for setting the context
collumn to `nullable=True`.
2019-05-15 11:14:05 -04: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
mprahl
771fad6d50 Resolve the commit in the SCM.commit property method instead of the constructor
This will prevent the need to call `SCM.get_latest` in the constructor,
since not all SCM objects need the commit to the branch. It also fixes
the situation where a component's git repo doesn't have a "master" branch.

See https://pagure.io/fm-orchestrator/issue/1224
2019-05-06 15:13:24 +00:00
Jan Kaluza
c5d000e900 Do not overwrite stream kwarg in build_module_locally.
When `default_streams` is set, the current code overwrites `stream`
kwarg in the `for` loop handling the `default_streams`.

In this commit, the `stream` kwarg is not overwritten.
2019-04-30 08:42:59 +02: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
Jan Kaluza
5d346f8dd3 Fix -debuginfo/-debugsource packages handling in KojiContentGenerator.
Our current code has following issues with -debuginfo/-debugsource handling:

- The foo-debuginfo is included in the MMD only when foo is included there,
  but some special packages contain custom -debuginfo sub-packages like
  foo-common-debuginfo without matching foo-common sub-package. With our
  current code, the foo-common-debuginfo is never included in the final MMD.
- The foo-debugsource is included in the MMD only when foo.src.rpm,
  but some special packages contain custom -debuginfo sub-package.

This commit changes the handling of -debuginfo/-debugsource like this:

- The RPMs to include in the final MMD are evaluated in particular order now.
  At first we evaluate non-debug RPMs and then debug RPMs.
- When handling the foo-debuginfo/foo-debugsource RPM, we include it in
  final MMD only in one of these cases:
  - The "foo" is included in the MMD file (it means it is not filtered out).
  - The "foo" package does not exist at all (it means only foo-debuginfo exists
    and we need to include this package unless filtered out) and in the same time
    the SRPM from which this -debuginfo/-debugsource RPM has been built is included
    in a final MMD (it means that there is at least some package from this build
    included - this handles case when only foo.src.rpm and foo-debugsource.rpm
    would be included in a final MMD, which would be wrong.)

We also respect filters here, so it is possible to explicitely filter out also
-debuginfo/-debugsource packages.
2019-04-26 15:18:50 +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
f5d634efec Fix a deprecation warning in the unit tests by using yaml.safe_load instead of yaml.load 2019-04-25 13:15:27 -04:00
mprahl
2fda8cdbfd Expose the stream version of a module in the API 2019-04-25 13:15:27 -04:00
mprahl
7b8947f660 Allow buildrequring a virtual stream of a base module 2019-04-25 13:15:27 -04:00
mprahl
00daedccfd Allow the virtual streams of a base module to be queryable in the database and API 2019-04-25 13:15:27 -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
mprahl
d0aea40788 Support the stream_version_lte filter in the API 2019-04-25 08:12:49 -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
Chenxiong Qi
808b7beec8 Refactor code style of code creating test data
This patch proposes another code style to create module builds and associated
component builds. The major purpose to make this refactor is to make it easier
to follow up the lines of code and understand the test data and the
relationship between module builds and component builds.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-04-24 17:06:38 +08:00
mprahl
0217496d1f Refactor the API ordering to accept multiple order keyword arguments of the same direction
This also improves how a column is determined to be valid for ordering.
2019-04-23 08:37:12 -04:00
Chenxiong Qi
7c993f9165 Handle streams in base module stream
A base module's stream (the platform for RHEL) could have Z-stream suffix, e.g.
el8.0.0.z, this patch handles this Z-stream suffix and other potential streams
by returning the stream version as a float with configured suffix value. For
example, el8.1.0.z would be parsed as 080100.1. Note that, the 0.1 is totally
configured in config and it actually could be any value according to concrete
cases in practice.

Config STREAM_SUFFIXES is enabled in TestConfiguration so that tests depending
on the return value from ModuleBuild.get_stream_version are covered.

Part fixture of test TestMMDResolver.test_solve_virtual_streams is updated by
adding Z-stream suffix to platform:el8.2.0 in order to ensure this patch does
not break the MMD resolver.

Addresses FACTORY-4307

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-04-23 11:21:46 +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
Valerij Maljulin
e564edc808 Build counters
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-04-09 15:44:45 +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
f348def71f Fix a log message 2019-04-04 13:16:33 -04:00
mprahl
730871ddfd Fix the test_submit_br_metadata_only_module unit test on Python 3 2019-04-04 09:28:42 -04: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
Merlin Mathesius
06e903c3c1 Fixes and test improvements based on review feedback.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-04-03 18:15:59 +00:00
Merlin Mathesius
cd76a1dca5 Update scratch context uniqueness suffix character from '.' to '_'.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-04-03 18:15:59 +00:00
Merlin Mathesius
663b7fc4d0 Allow resubmitting the same NSV for scratch module builds.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-04-03 18:15:59 +00: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
Chenxiong Qi
0ee801877b Move module build to ready from done according to Greenwave
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-04-02 16:11:43 +08: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
d1f6631f3b Fix traceback in MMDResolver when transitive dependency cannot be satisfied.
This fixes problems from #1184 when new platform stream is added and the
input module depends on another module which is not built against this
new platform, but in the same time the input module wants to be built
against this new platform stream. See the unit-test for more info.

The problem is that `MMDResolver.solve()` method sets the `alternative`
to an empty list and stores the data there only if the alternative
is found valid. If the alternative is not found valid, then it stays
set to an empty list, but the code using `alternative` later expects
it to only contains valid alternatives.

This commit fixes this by setting the `alternative` only in a case
we found it is valid alternative.
2019-03-27 06:36:43 +01:00
mprahl
9651891d74 Support base modules with x.y.z versioning and no virtual streams 2019-03-25 15:59:06 +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
a8a8913bbc Add the ability to override a buildrequired module stream based on a module's branch
This moves the functionality that was in rpkg to MBS. See the following
PRs for more context:
https://pagure.io/rpkg/pull-request/390
https://pagure.io/rpkg/pull-request/420
2019-03-19 16:45:00 -04:00
mprahl
998084b441 Don't default the module name to "unnamed" on a direct modulemd submission
The module name should either be set in the modulemd file or provided
by the `module_name` parameter.
2019-03-19 08:31:33 -04: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
Merlin Mathesius
a46a4ec470 Accept modulemd for scratch module builds as a parameter in the submitted JSON.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-19 11:56:47 +00:00
Jan Kaluza
765e640129 Allow setting the Koji tag extra options using the conf.koji_tag_extra_opts.
The Koji tag extra options used to be hard-coded and to change them,
we had to release new MBS version.

We do not change them often, but right now fedora-infra is requesting
to use new `mock.new_chroot` option and we need to release new MBS
because of that.

This commit makes such changes easier in the future.
2019-03-18 17:27:57 +00: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