Commit graph

300 commits

Author SHA1 Message Date
sanne
5a9d8c792b cloudapi: V2
V2 is compliant with api.openshift.com design guidelines.

Errors are predefined, have codes, and are queryable.

All requests have an operationId set: a unique identifier which is
sortable by time. This is added to the response in case of an error.

All returned objects have the href, id, and kind field set.
2021-09-14 15:32:21 +02:00
dependabot[bot]
961fef25ff build(deps): bump github.com/Azure/azure-sdk-for-go
Bumps [github.com/Azure/azure-sdk-for-go](https://github.com/Azure/azure-sdk-for-go) from 57.1.0+incompatible to 57.2.0+incompatible.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/v57.1.0...v57.2.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-14 08:41:10 +02:00
dependabot[bot]
e136434bdf build(deps): bump github.com/aws/aws-sdk-go from 1.40.37 to 1.40.38
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.37 to 1.40.38.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.40.37...v1.40.38)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-08 09:37:47 +02:00
dependabot[bot]
5ea512da3e build(deps): bump gopkg.in/ini.v1 from 1.62.1 to 1.63.0
Bumps [gopkg.in/ini.v1](https://github.com/go-ini/ini) from 1.62.1 to 1.63.0.
- [Release notes](https://github.com/go-ini/ini/releases)
- [Commits](https://github.com/go-ini/ini/compare/v1.62.1...v1.63.0)

---
updated-dependencies:
- dependency-name: gopkg.in/ini.v1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-07 19:26:10 +02:00
Ondřej Budai
19a3bdf450 go: update most dependencies to the latest version
It's a lot of work for dependabot for our outdated deps, let's
help it by making one huge manual update.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-09-05 12:50:02 +01:00
dependabot[bot]
08a937c9c1 build(deps): bump google.golang.org/api from 0.36.0 to 0.56.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.36.0 to 0.56.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/master/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.36.0...v0.56.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-05 11:17:29 +02:00
dependabot[bot]
137819b9cd build(deps): bump github.com/vmware/govmomi from 0.23.0 to 0.26.1
Bumps [github.com/vmware/govmomi](https://github.com/vmware/govmomi) from 0.23.0 to 0.26.1.
- [Release notes](https://github.com/vmware/govmomi/releases)
- [Changelog](https://github.com/vmware/govmomi/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vmware/govmomi/compare/v0.23.0...v0.26.1)

---
updated-dependencies:
- dependency-name: github.com/vmware/govmomi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-05 08:48:07 +02:00
dependabot[bot]
aab7bff174 build(deps): bump github.com/Azure/azure-storage-blob-go
Bumps [github.com/Azure/azure-storage-blob-go](https://github.com/Azure/azure-storage-blob-go) from 0.13.0 to 0.14.0.
- [Release notes](https://github.com/Azure/azure-storage-blob-go/releases)
- [Changelog](https://github.com/Azure/azure-storage-blob-go/blob/master/ChangeLog.md)
- [Commits](https://github.com/Azure/azure-storage-blob-go/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-storage-blob-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-04 19:42:10 +02:00
dependabot[bot]
cad77a25d1 build(deps): bump github.com/labstack/echo/v4 from 4.1.11 to 4.5.0
Bumps [github.com/labstack/echo/v4](https://github.com/labstack/echo) from 4.1.11 to 4.5.0.
- [Release notes](https://github.com/labstack/echo/releases)
- [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/labstack/echo/compare/v4.1.11...v4.5.0)

---
updated-dependencies:
- dependency-name: github.com/labstack/echo/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-04 15:46:13 +02:00
Ondřej Budai
636a713745 go: fix vendoring
#1717 broke the source preparedness check. This was probably caused by the
fact that the PR wasn't rebased on top of the latest main when it was merged.
I guess that some other PR made some incompatible changes in the meantime.

This commit is just a rerun of tools/prepare-source.sh

Merge trains are a nice idea, right?

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-09-04 12:59:29 +02:00
sanne
4a057bf3d5 auth: OpenID/OAUth2 middleware
2 configurations for the listeners are now possible:
- enableJWT=false with client ssl auth
- enableJWT=true with https

Actual verification of the tokens is handled by
https://github.com/openshift-online/ocm-sdk-go.

An authentication handler is run as the top level handler, before any
routing is done. Routes which do not require authentication should be
listed as exceptions.

Authentication can be restricted using an ACL file which allows
filtering based on JWT claims. For more information see the inline
comments in ocm-sdk/authentication.

As an added quirk the `-v` flag for the osbuild-composer executable was
changed to `-verbose` to avoid flag collision with glog which declares
the `-v` flag in the package `init()` function. The ocm-sdk depends on
glog and pulls it in.
2021-09-04 02:48:52 +02:00
dependabot[bot]
23f1526160 build(deps): bump github.com/Azure/go-autorest/autorest
Bumps [github.com/Azure/go-autorest/autorest](https://github.com/Azure/go-autorest) from 0.10.0 to 0.11.20.
- [Release notes](https://github.com/Azure/go-autorest/releases)
- [Changelog](https://github.com/Azure/go-autorest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Azure/go-autorest/compare/autorest/v0.10.0...autorest/v0.11.20)

---
updated-dependencies:
- dependency-name: github.com/Azure/go-autorest/autorest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-03 23:23:09 +02:00
dependabot[bot]
3ccdf85295 build(deps): bump github.com/golang/protobuf from 1.4.3 to 1.5.2
Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.4.3 to 1.5.2.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](https://github.com/golang/protobuf/compare/v1.4.3...v1.5.2)

---
updated-dependencies:
- dependency-name: github.com/golang/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Ondřej: I also fixed a deprecated call.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-09-03 18:23:54 +02:00
dependabot[bot]
839a708755 build(deps): bump github.com/gophercloud/gophercloud
Bumps [github.com/gophercloud/gophercloud](https://github.com/gophercloud/gophercloud) from 0.11.0 to 0.20.0.
- [Release notes](https://github.com/gophercloud/gophercloud/releases)
- [Changelog](https://github.com/gophercloud/gophercloud/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gophercloud/gophercloud/compare/v0.11.0...v0.20.0)

---
updated-dependencies:
- dependency-name: github.com/gophercloud/gophercloud
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-03 09:18:42 +02:00
dependabot[bot]
d0bf28fbaf build(deps): bump github.com/google/uuid from 1.1.2 to 1.3.0
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.2 to 1.3.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.1.2...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-02 10:25:43 +02:00
dependabot[bot]
9ceeaa1dfd build(deps): bump github.com/jackc/pgtype from 1.7.0 to 1.8.1
Bumps [github.com/jackc/pgtype](https://github.com/jackc/pgtype) from 1.7.0 to 1.8.1.
- [Release notes](https://github.com/jackc/pgtype/releases)
- [Changelog](https://github.com/jackc/pgtype/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jackc/pgtype/compare/v1.7.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgtype
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-01 16:17:14 +02:00
Martin Sehnoutka
1ada606ed8 internal/rhsm: introduce package that handles subscriptions
The problem: osbuild-composer used to have a rather uncomplete logic for
selecting client certificates and keys while fetching data from
repositories that use the "subscription model". In this scenario, every
repo requires the user to use a client-side TLS certificate. The problem
is that every repo can use its own CA and require a different pair of
a certificate and a key. This case wasn't handled at all in composer.

Furthermore, osbuild-composer can use remote workers which complicates
things even more.

Assumptions: The problem outlined above is hard to solve in the general
case, but Red Hat Subscription Manager places certain limitations on how
subscriptions might be used. For example, a subscription must be tight to
a host system, so there is no way to use such a repository in osbuild-composer
without it being available on the host system as well.

Also, if a user wishes to use a certain repository in osbuild-composer it
must be available on both hosts: the composer and the worker. It will come
with different pair of a client certificate and a key but otherwise, its
configuration remains the same.

The solution: Expect all the subscriptions to be registered in the
/etc/yum.repos.d/redhat.repo file. Read the mapping of URLs to certificates
and keys from there and use it. Don't change the manifest format and let
osbuild guess the appropriate subscription to use.
2021-08-09 12:40:23 +02:00
Chloe Kaubisch
29af662bf8 cloudapi: replace chi with echo
standardize middleware by replacing chi with echo
2021-08-03 13:09:13 +02:00
Lars Karlitski
9c2c92f729 jobqueue: Introduce jobqueue backed by a postgres database
Co-authored-by: sanne <sanne.raymaekers@gmail.com>
2021-07-28 21:52:31 +01:00
Chloe Kaubisch
4c800f29a7 worker: add metrics
use prometheus to gather metrics
2021-07-23 21:54:28 +02:00
Ondřej Budai
2e39d629a9 worker: add azure image upload target
This commit adds and implements org.osbuild.azure.image target.

Let's talk about the already implemented org.osbuild.azure target firstly:
The purpose of this target is to authenticate using the Azure Storage
credentials and upload the image file as a Page Blob. Page Blob is basically
an object in storage and it cannot be directly used to launch a VM. To achieve
that, you need to define an actual Azure Image with the Page Blob attached.

For the cloud API, we would like to create an actual Azure Image that is
immediately available for new VMs. The new target accomplishes it.
To achieve this, it must use a different authentication method: Azure OAuth.
The other important difference is that currently, the credentials are stored
on the worker and not in target options. This should lead to better security
because we don't send the credentials over network. In the future, we would
like to have credential-less setup using workers in Azure with the right
IAM policies applied but this requires more investigation and is not
implemented in this commit.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-06 15:40:48 +00:00
Tomas Hozza
ff95059748 internal/upload: Add support for upload to GCP and CLI tool using it
Add new internal upload target for Google Cloud Platform and
osbuild-upload-gcp CLI tool which uses the API.

Supported features are:
- Authenticate with GCP using explicitly provided JSON credentials
  file or let the authentication be handled automatically by the
  Google cloud client library. The later is useful e.g. when the worker
  is running in GCP VM instance, which has associated permissions with
  it.
- Upload an existing image file into existing Storage bucket.
- Verify MD5 checksum of the uploaded image file against the local
  file's checksum.
- Import the uploaded image file into Compute Node as an Image.
- Delete the uploaded image file after a successful image import.
- Delete all cache files from storage created as part of the image
  import build job.
- Share the imported image with a list of specified accounts.

GCP-specific image type is not yet added, since GCP supports importing
VMDK and VHD images, which the osbuild-composer already supports.

Update go.mod, vendor/ content and SPEC file with new dependencies.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-25 18:44:21 +00:00
Martin Sehnoutka
f98e231f64 cloudapi: extend the API spec with /version and /openapi.json
These endpoints are useful for clients while exploring the API. They are
also required for deploying the service into clouddot.
2021-02-12 14:25:19 +01:00
Ondřej Budai
2b41190cf3 go.mod: bump azure-storage-blob-go/azblob
Due to https://github.com/Azure/azure-storage-blob-go/issues/236 , we had to
use a weird version of this library (see 1b051922).

A new release came out yesterday that's tagged correctly so let's use it
so we can remove the hack from go.mod.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-03 12:36:04 +01:00
Ondřej Budai
f2318f8c5f go: bump to 1.14
The oldest distros we support are Fedora 32 and RHEL 8.3. As both have
Go 1.14, we're safe to upgrade.

Also, I had to change prepare-source.sh because go fmt now refuses to run on
a project which has issues in go.mod, go.sum or modules.text. I think this
should be a harmless change.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-01 15:32:58 +01:00
Ondřej Budai
2241a8d9ed go: vendor the oapi-codegen cmd
See the comment in tools.go, I cannot fully explain what's happening here.
Somehow, Go 1.14 wants to use the vendored version of oapi-codegen but
without this file, oapi-codegen isn't vendored so the generation fails.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-01 15:32:58 +01:00
Ondřej Budai
1b05192298 upload/azure: use the new azure/azblob API on Fedora 33+ & RHEL
Fedora 33 and rawhide got an updated version of the azblob library. Sadly, it
introduced a non-compatible API change. This commit does the same thing as
a67baf5a did for kolo/xmlrpc:

We now have two wrappers around the affected part of the API. Fedora 32 uses
the wrapper around the old API, whereas Fedora 33 and 34 (and RHEL with its
vendored deps) use the wrapper around the new API. The switch is implemented
using go build flags and spec file magic.

See a67baf5a for more thoughts.

Also, there's v0.11.1-0.20201209121048-6df5d9af221d in go.mod, why?

The maintainers of azblob probably tagged a wrong commit with v0.12.0 which
breaks go. The long v0.11.1-.* version is basically the proper v0.12.0 commit.
See https://github.com/Azure/azure-storage-blob-go/issues/236 for more
information.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-01-06 16:31:28 +01:00
Ondřej Budai
a67baf5a4d upload/koji: use the new API of kolo/xmlrpc by default
Fedora 33 ships the new API so let's do the switch now.

But... this would break older Fedoras because they only have the old API,
right?

We have the following options:

1) Ship xmlrpc compat package to Fedora 33+. This would mean that we delay the API switch till F32 EOL. This would be the most elegant solution, yet it has two issues: a) We will surely not be able to deliver the compat package before F33 Final Freeze. b) It's an extra and annoying work.

2) Downstream patch. No.

3) Use build constraints and have two versions of our code for both different
   API.

I chose solution #3. It has an issue though:

%gobuild macro already passes -tags argument to go build. Therefore the
following line fails because it's not possible to use -tags more than once:

%gobuild -tags kolo_xmlrpc_oldapi ...

Therefore I had to come up with manual tinkering with the build constraints
in the spec file. This is pretty ugly but I like that:

1) Go code is actually clean, no weird magic is happening there.
2) We can still ship our software to Fedora/RHEL as we used to
   (no downstream patches)
3) All downstreams can use the upstream spec file directly.

Note that this doesn't affect RHEL in any way as it uses vendored libraries.
2020-10-14 16:44:26 +02:00
Lars Karlitski
18e5b2e448 go.mod: update 2020-09-22 14:13:06 +02:00
Tom Gundersen
6bab73f378 kojiapi: move from chi to echo
Follow the worker API so we standardise on one library. This simplifies
the code quite a bit.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-21 11:18:45 +01:00
Tom Gundersen
b6f06da1a7 upload/koji/uploadChunk: fix compilation errors
The API of kolo/xmlrpc changed after the commit that is shipped in
Fedora. Pin the vendored version to that and adjust the API usage.

This should make the RPM compile in both RHEL and Fedora.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
67e4182ba4 kojiapi: add a server/client implementation of the OpenAPI spec
This just translates between the OpenAPI spec and our internal
API.

This still lacks tests, but a follow-up commit adds integration tests.

`internal/kojiapi/openapi.gen.go` was automatically generated from
`internal/kojiapi/openapi.yml`. To regenerate use `go generate ./...`.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Lars Karlitski
ad11ceecf4 worker: use openapi spec and generated code
Write an openapi spec for the worker API and use `deepmap/oapi-codegen`
to generate scaffolding for the server-side using the `labstack/echo`
server.

Incidentally, echo by default returns the errors in the same format that
worker API always has:

    { "message": "..." }

The API itself is unchanged to make this change easier to understand. It
will be changed to better suit our needs in future commits.
2020-09-06 18:42:23 +01:00
Ondřej Budai
05fd221bd4 upload/koji: add support for GSSAPI/Kerberos auth
Prior this commit we only had support for username/password authentication
in the koji integration. This wasn't particularly useful because this
auth type isn't used in any production instance.

This commit adds the support for GSSAPI/Kerberos authentication.
The implementation uses kerby library which is very lightweight wrapper
around C gssapi library.

Also, the koji unit test and the run-koji-container script were modified
so the GSSAPI auth is fully tested.
2020-08-27 17:29:57 +01:00
Ondřej Budai
360bf2aa04 rerun prepare-source after a bad merge
#932 bumped the minimal Go version to 1.13. Prepare-source script had to be
rerun because of some changes in vendoring.

Unfortunately, while this PR was waiting to merged, #797 also touching
vendoring was merged. This "commit race condition" led to a failing check
on master branch because of bad vendoring.

This commit reruns the prepare-source script to fix the vendoring once again.
2020-08-25 11:16:12 +02:00
Ondřej Budai
d3f98a4b40 prepare sources for Go 1.13
Vendoring differs a bit betweem Go 1.12 and 1.13. This commit is a rerun of
tools/prepare-source.sh for Go 1.13
2020-08-25 10:42:21 +02:00
Alexander Todorov
9cce43d384 tests: upload & test in vCenter. Closes #338 2020-08-20 21:59:54 +02:00
Alexander Todorov
f7c4dca5d5 tests: upload & boot image in OpenStack. Closes #339 2020-06-23 16:17:30 +02:00
Tom Gundersen
76515066a8 upload/koji: add helpers to upload to koji
This does not yet actually upload the image, and it only supports empty
images. You need to place a an empty file named <filename>, with a valid
extension (e.g., .qcow2) in /mnt/koji/work/<directory>/.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-19 13:54:53 +02:00
Ondřej Budai
10c016edca vendor Azure SDK
This should actually be a part of the next commit, but that would make the
review hard, so I decided to create a separate commit just for vendoring.
2020-04-27 20:34:20 +02:00
Jakub Rusz
32844d605a vendor: add github.com/stretchr/testify/suite 2020-04-24 11:46:13 +02:00
Alexander Todorov
869bb2afd7 tests: Use the require/assert package and replace cmp.Diff 2020-04-19 18:20:57 +02:00
Martin Sehnoutka
ebeecfaf33 github/workflows: downgrade golang to 1.12
We currently declare compatibility with golang 1.12 so we should also
use it in our CI. Once we agree that we would benefit from some features
in golang 1.13 or 1.14 we can bump it back.
2020-04-15 10:34:32 +02:00
Brian C. Lane
644a14d5f5 Update go.mod and vendor for require package 2020-03-17 21:10:00 +01:00
Tom Gundersen
538a16bf27 vendor: add missing directory
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Ondřej Budai
b4a7bc6467 tests/image: add booting tests
This commit makes the osbuild-image-tests binary doing the same set of tests
like the old test/run script.

Changes from test/run:
- qemu/nspawn are now killed gracefully. Firstly, SIGTERM is sent.
  If the process doesn't exit till the timeout, SIGKILL is sent.
  I changed this because nspawn leaves some artifacts behind when killed
  by SIGKILL.
- the unsharing of network namespace now works differently because of
  systemd issue #15079
2020-03-13 18:06:56 +01:00
Ondřej Budai
886c3c858e add missing packages to vendor directory 2020-03-13 16:00:29 +01:00
Alexander Todorov
b81580081b Use asserts in tests. Refs #309 2020-03-13 14:01:18 +01:00
Brian C. Lane
58839cf927 Use semver to enforce blueprint version numbers
This changes osbuild-composer's behavior to match lorax-composer when
encountering invalid versions. Instead of leaving them as-is it will
return a BlueprintError explaining the problem. eg.

"errors": [
    {
        "id": "BlueprintsError",
        "msg": "Invalid 'version', must use Semantic Versioning:  is not in dotted-tri format"
    }
]

This is enforced on new blueprints (including the workspace). If a
previously stored blueprint has an invalid version and a new one is
pushed it will use the new version number instead of trying to bump the
invalid one.

This also moves the version bump logic into blueprint instead of store,
and adds an Initialize function that will make sure that the blueprint
has sane default values for any missing fields.

This includes tests for the Initialize and BumpVersion functions.
2020-02-25 09:00:35 +01:00
Lars Karlitski
6703055925 go: include vendored modules
RHEL requires the source code for dependencies to be included in the
srpm. The spec file already expects that, but we've only included the
vendored modules (i.e., the `vendor` directory) in the `rhel-8.2.`
branch. Move vendoring to master, so that we can build RHEL packages
from it as well.

This commit is the result of running `go mod vendor`, which includes the
vendored sources and updates go.mod and go.sum files.

Fedora requires the opposite: dependencies should not be vendored. The
spec file already ignores the `vendor` directory by default.
2020-02-17 16:09:17 +01:00