mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-06 00:44:22 +02:00
feat: wait for healthy services and fill the job context (#1107)
Service containers were started and then left alone, so a job's first step could run while a database was still starting up. The runner now waits for every service whose image or `options` declare a healthcheck, as GitHub does. An unhealthy service fails the job with its container log, one that never becomes healthy fails it after `container.service_ready_timeout` (default `5m`, negative disables the wait), and one that exits without a healthcheck only gets its log and a warning.
The started containers also fill the `job` context, whose fields existed but were never populated: `job.container.{id,network}` and `job.services.<id>.{id,network,ports}`. `ports` is keyed by the plain container port, so `job.services.postgres.ports['5432']` resolves to the host port Docker picked.
---------
Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1107
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
@@ -5,12 +5,18 @@
|
||||
package model
|
||||
|
||||
type JobContext struct {
|
||||
Status string `json:"status"`
|
||||
Container struct {
|
||||
ID string `json:"id"`
|
||||
Network string `json:"network"`
|
||||
} `json:"container"`
|
||||
Services map[string]struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"services"`
|
||||
Status string `json:"status"`
|
||||
Container JobContainerContext `json:"container"`
|
||||
Services map[string]JobService `json:"services"`
|
||||
}
|
||||
|
||||
type JobContainerContext struct {
|
||||
ID string `json:"id"`
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
type JobService struct {
|
||||
ID string `json:"id"`
|
||||
Network string `json:"network"`
|
||||
Ports map[string]string `json:"ports"` // container port to the published host port
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user