Commit graph

11 commits

Author SHA1 Message Date
sanne
d25ae71fef worker: Configurable timeout for RequestJob
This is backwards compatible, as long as the timeout is 0 (never
timeout), which is the default.

In case of the dbjobqueue the underlying timeout is due to
context.Canceled, context.DeadlineExceeded, or net.Error with Timeout()
true. For the fsjobqueue only the first two are considered.
2021-10-19 00:12:18 +01:00
sanne
2f328b0e97 workers: Backwards compatible api.openshift.com spec compliance
The main changes are:
- Kind, Href, Id fields for every object returned
- Attach operationIds to each request, return it for errors
- Errors are predefined and queryable
2021-09-27 13:10:05 +01:00
Lars Karlitski
9008a1defc worker: require workers to pass their architecture
Jobs are scheduled with type "osbuild:{arch}", to ensure that workers
only get jobs with the right architecture assigned.
2020-09-23 14:28:52 +01:00
Lars Karlitski
ba6a480e32 worker: require workers to declare job types they accept
For now, workers must send `[ "osbuild" ]`.
2020-09-23 14:28:52 +01:00
Lars Karlitski
ca35f25fcf worker/client: expose server errors
The worker API returns errors of the form:

  { "message": "..." }

Print the message of those errors when receiving an error on the client.

This adds an `Error` type to openapi.yml and marks all routes as
returning it on 4XX and 5XX.
2020-09-11 14:23:24 +01:00
Lars Karlitski
b03e1254e9 worker/api: remove token in favor of callback URLs
Instead of sending a `token` to workers, send back to URLs:

 1. "location": URL at which the job can be inspected (GET) and updated
    (PATCH).
 2. "artifact_location": URL at which artifacts should be uploaded to.

The actual URLs remain the same, but a client does not need to stitch
them together manually (except appending the artifact's name).

Unfortunately, the client code generated by `deepmap` does not lend
itself to this style of APIs. Use standard http.Client again, which is a
partial revert of 0962fbd30.
2020-09-11 14:23:24 +01:00
Lars Karlitski
26b36ba704 worker/api: introduce job tokens
Don't give out job ids to workers, but `tokens`, which serve as an
indirection. This way, restarting composer won't confuse it when a stray
worker returns a result for a job that was still running. Also,
artifacts are only moved to the final location once a job finishes.

This change breaks backwards compatibility, but we're not yet promising
a stable worker API to anyone.

This drops the transition tests in server_test.go. These don't make much
sense anymore, because there's only one allowed transition, from running
to finished. They heavily relied on job slot ids, which are not easily
accessible with the `TestRoute` API. Overall, adjusting this seemed like
too much work for their benefit.
2020-09-11 14:23:24 +01:00
Lars Karlitski
783a88d8cc worker/api: give operations simpler names
The code generator uses the `operationID` field to generate server
handlers, client functions, and types. Use simpler names to make the
generated code easier to read.
2020-09-11 14:23:24 +01:00
Lars Karlitski
bf0dd66382 worker/api: drop /job-queue/v1 from api paths
This kind of common base path is better set in the top-level
`server.url` field, so that it can be adjusted.

For now, drop it completely, as we already broke the consistency when
introducing the `/status` route.

This change breaks backwards compatibility, but we're not yet promising
a stable worker API to anyone.
2020-09-11 14:23:24 +01:00
Lars Karlitski
0962fbd306 worker/client: use code generated from openapi spec 2020-09-06 18:42:23 +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