595 Commits

Author SHA1 Message Date
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
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
Jan Kaluza
9a6646f27c Use the scrmod prefix also for build targets for scratch builds.
Currently, the Koji tags have properly set the scrmod- prefix, but
the build target still sets module- prefix even for scratch builds.

In this commit, build target has the scrmod- prefix too.
2019-03-14 13:10:47 +01: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
b570948484 Don't allow building modules with the same name as a base module (e.g. platform)
A user managed to build a module called "platform", which stopped dependency
resolution from working. This should stop that from happening again.
2019-03-12 14:58:28 -04:00
Jan Kaluza
57d5548105 Fix conversion to bytes in Python3 in tests. 2019-03-12 18:33:27 +00:00
Merlin Mathesius
244d873130 Always allow submitting yaml for scratch module builds.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-08 11:58:46 -06:00
Jan Kaluža
b38feb5deb Merge #1160 Fix the way how KojiContentGenerator computes filesize. 2019-03-07 15:44:43 +00:00
Jan Kaluza
04082047fe Fix the way how KojiContentGenerator computes filesize.
The current code reads the data, converts them to unicode string and
then uses the `len()` of that string as filesize. This is wrong,
because Koji expects filesize to be really number of bytes, not number
of characters.

Therefore, in this commit, the filesize is computed from raw data (bytes).
2019-03-07 15:29:16 +01:00
Jan Kaluza
c5a9a1b8af Allow auth.get_user() method to be called multiple times.
The `ImportModuleAPI` calls the `auth.get_user()` which auths the
user using Kerberos. the `ImportModuleAPI` later calls `SCMHandler`
which in its `__init__` method calls the `auth.get_user()` again.
This leads to traceback in GSSAPI, because the user is already
authed.

This commit fixes this by caching the auth results in `flask.g`,
which is reset after each request based on the Note in
http://flask.pocoo.org/docs/1.0/appcontext/#storing-data.

This commit also marks mutual auth as OPTIONAL in `mbs-cli`,
because MBS server currently does not do mutual auth.
2019-03-07 09:37:14 +01:00
Jan Kaluza
ac0bd8ceb8 Set time_completed before calling KojiContentGenerator.
The `KojiContentGenerator.finalize()` needs the `ModuleBuild.time_completed`.

We currently set `time_completed` once the module build transitions
into `done` state. But we have moved the `KojiContentGenerator` call
to end of `build` state, so right now it is called before the `time_completed`
is set. This leads to traceback.

In this commit, the `time_completed` is set before the `KojiContentGenerator`
call, so it is defined properly.
2019-03-04 10:03:47 +01: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
Merlin Mathesius
838feb4ecd Add scratch module build submit tests.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-01 10:27:04 -06:00
Merlin Mathesius
2bf7813446 Add 'scratch' and 'srpms' attributes to data model for module scratch builds,
and update tests accordingly.

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-01 10:27:04 -06:00
mprahl
d5f9c5872f Return an exception to the user if no dependency combination is determined 2019-02-27 14:08:15 +00:00
Valerij Maljulin
f6a4befefe Change exception information for errors when parsing modulemd file.
This fixes #1149

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-02-26 14:09:57 +01:00
Valerij Maljulin
687a78242e Change xmlrpclib importing way
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-02-25 16:56:30 +01:00
Jan Kaluža
9e56b60a1b Merge #1146 Update the ModuleBuild.time_modified in case the format_mmd takes long time. 2019-02-22 06:21:01 +00: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
Valerij Maljulin
eafa93037f Make finalization before changing state to done
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-02-15 15:19:59 +01:00
mprahl
776330a2bb Add the allowed_users configuration for service accounts to bypass the group membership check
This is required for monitoring use-cases, where we can have a Kerberos principal for a
service account but no associated account in LDAP to check group membership.
2019-02-14 11:11:18 -05: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
Jan Kaluza
7052ea0a11 Make init handler idempotent.
This fixes the issue when module build is cancelled in init state.
2019-02-14 14:18:54 +01:00
Filip Valder
38c0ea6147 Basic monitoring w/-o MBS-specific metrics 2019-02-12 16:08:41 +00:00
Jan Kaluza
130911bb49 Do not retry on 'git ls-remote' failure, but instead fallback to 'git clone'. 2019-02-11 15:27:07 +01:00
Mike Bonnet
e01b3fd077 handle different string representations of set() 2019-02-08 17:43:43 +00:00
Mike Bonnet
dcd38db5e0 hide the missing krbV module 2019-02-08 17:43:43 +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
Luiz Carvalho
5921c109f7 Add retire command to mbs-manager
With this command, admins can retire module builds that should no longer
be used as a dependency for other module builds.

Fixes #1021

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-01-18 10:58:26 -05: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
Valerij Maljulin
020315fa4e Removing tests for _check_upload as long as function was separated from pull-request
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-01-11 14:43:25 +01:00
Valerij Maljulin
436e0bef3f Fix for the test test_all_builds_in_batch_fail
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-01-10 15:22:37 +01:00
Valerij Maljulin
51a9892398 Unit tests for koji_import
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-01-10 15:22:37 +01:00
Jan Kaluza
3c7f8b7006 Handle lost message from Koji informing MBS about Component being tagged into Koji tag.
Adds new meethod checking the "tagged" and "tagged_in_final" attributes of
"complete" ComponentBuilds in the current batch of module builds
in "building" state against the Koji.

In case the Koji shows the build as tagged/tagged_in_final,
the fake "tagged" message is added to work queue.
2019-01-02 09:33:42 +01:00
Matt Prahl
8bb50cfe16 Merge #1093 List package name in failed state reason 2018-12-18 21:19:14 +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
Jan Kaluza
e17fdbdb5a Raise an exception in case getRPMHeaders return an empty dict or does not return the RPM license. 2018-12-18 16:28:47 +01:00
Jan Kaluža
f47cc39de9 Merge #1109 Fix creation of CG build without any RPM. 2018-12-18 09:38:28 +00:00
Chenxiong Qi
5c2b411309 List package name in failed state reason
Client tool like module-build-watch and `module-build --watch' could
output failed reason. However, original message "Some components failed
to buld" is not informative enough. Instead, list package names of
failed builds would be helpful.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2018-12-18 16:09:16 +08:00
Jan Kaluza
bcfead0809 In case module is stuck in 'init' state for more than 10 minutes, send fake MBSModule msg.
This fixes issues when UMB message delivery from frontend to backend fails
for whatever reason...

We do the same thing for 'wait' state already, so this commit just extends
it to 'init' state too.
2018-12-18 08:06:31 +01:00