fix: [container].docker_host = "" is now "automount"
The empty string is always replaced with "-" and there no longer is any way to specify that the docker socket is to be mounted in the container automatically. The "automount" value is introduced as a replacement. https://code.forgejo.org/forgejo/act/pulls/67 and https://code.forgejo.org/forgejo/runner/pulls/305 introduced this regression.
This commit is contained in:
parent
eee0b082fb
commit
279faefa08
4 changed files with 9 additions and 11 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
## 5.0.3
|
||||||
|
|
||||||
|
* [Fixes a regression](https://code.forgejo.org/forgejo/runner/pulls/354) that was introduced in version 5.0.0 by which it was no longer possible to mount the docker socket in each container by specifying `[container].docker_host = ""`. This is now implemented when `[container].docker_host = "automount"` is specified.
|
||||||
|
|
||||||
## 5.0.2
|
## 5.0.2
|
||||||
|
|
||||||
* Fixes a regression that was introduced in version 5.0.0 by which [skipped jobs were marked as failed instead](https://code.forgejo.org/forgejo/act/pulls/67). The workaround is to change the job log level to debug `[log].job_level: debug`.
|
* Fixes a regression that was introduced in version 5.0.0 by which [skipped jobs were marked as failed instead](https://code.forgejo.org/forgejo/act/pulls/67). The workaround is to change the job log level to debug `[log].job_level: debug`.
|
||||||
|
|
|
@ -73,11 +73,8 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
|
||||||
if err := envcheck.CheckIfDockerRunning(ctx, dockerSocketPath); err != nil {
|
if err := envcheck.CheckIfDockerRunning(ctx, dockerSocketPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// if dockerSocketPath passes the check, override DOCKER_HOST with dockerSocketPath
|
|
||||||
os.Setenv("DOCKER_HOST", dockerSocketPath)
|
os.Setenv("DOCKER_HOST", dockerSocketPath)
|
||||||
// empty cfg.Container.DockerHost means act_runner need to find an available docker host automatically
|
if cfg.Container.DockerHost == "automount" {
|
||||||
// and assign the path to cfg.Container.DockerHost
|
|
||||||
if cfg.Container.DockerHost == "" {
|
|
||||||
cfg.Container.DockerHost = dockerSocketPath
|
cfg.Container.DockerHost = dockerSocketPath
|
||||||
}
|
}
|
||||||
// check the scheme, if the scheme is not npipe or unix
|
// check the scheme, if the scheme is not npipe or unix
|
||||||
|
@ -186,7 +183,7 @@ var commonSocketPaths = []string{
|
||||||
|
|
||||||
func getDockerSocketPath(configDockerHost string) (string, error) {
|
func getDockerSocketPath(configDockerHost string) (string, error) {
|
||||||
// a `-` means don't mount the docker socket to job containers
|
// a `-` means don't mount the docker socket to job containers
|
||||||
if configDockerHost != "" && configDockerHost != "-" {
|
if configDockerHost != "automount" && configDockerHost != "-" {
|
||||||
return configDockerHost, nil
|
return configDockerHost, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,8 @@ container:
|
||||||
# - '**'
|
# - '**'
|
||||||
valid_volumes: []
|
valid_volumes: []
|
||||||
# overrides the docker client host with the specified one.
|
# overrides the docker client host with the specified one.
|
||||||
# If "-", an available docker host will automatically be found.
|
# If "-" or "", an available docker host will automatically be found.
|
||||||
# If empty, an available docker host will automatically be found and mounted in the job container (e.g. /var/run/docker.sock).
|
# If "automount", an available docker host will automatically be found and mounted in the job container (e.g. /var/run/docker.sock).
|
||||||
# Otherwise the specified docker host will be used and an error will be returned if it doesn't work.
|
# Otherwise the specified docker host will be used and an error will be returned if it doesn't work.
|
||||||
docker_host: "-"
|
docker_host: "-"
|
||||||
# Pull docker image(s) even if already present
|
# Pull docker image(s) even if already present
|
||||||
|
|
|
@ -13,10 +13,7 @@ import (
|
||||||
func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error {
|
func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error {
|
||||||
opts := []client.Opt{
|
opts := []client.Opt{
|
||||||
client.FromEnv,
|
client.FromEnv,
|
||||||
}
|
client.WithHost(configDockerHost),
|
||||||
|
|
||||||
if configDockerHost != "" {
|
|
||||||
opts = append(opts, client.WithHost(configDockerHost))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cli, err := client.NewClientWithOpts(opts...)
|
cli, err := client.NewClientWithOpts(opts...)
|
||||||
|
|
Loading…
Reference in a new issue