Skip to content

Commit

Permalink
Merge pull request 'fix: [container].docker_host = "" is now "automou…
Browse files Browse the repository at this point in the history
…nt"' (#354) from earl-warren/runner:wip-config into main

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/354
Reviewed-by: Michael Kriese <[email protected]>
  • Loading branch information
earl-warren committed Nov 27, 2024
2 parents eee0b08 + 279faef commit f8b0ccf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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

* 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`.
Expand Down
7 changes: 2 additions & 5 deletions internal/app/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
if err := envcheck.CheckIfDockerRunning(ctx, dockerSocketPath); err != nil {
return err
}
// if dockerSocketPath passes the check, override DOCKER_HOST with dockerSocketPath
os.Setenv("DOCKER_HOST", dockerSocketPath)
// empty cfg.Container.DockerHost means act_runner need to find an available docker host automatically
// and assign the path to cfg.Container.DockerHost
if cfg.Container.DockerHost == "" {
if cfg.Container.DockerHost == "automount" {
cfg.Container.DockerHost = dockerSocketPath
}
// check the scheme, if the scheme is not npipe or unix
Expand Down Expand Up @@ -186,7 +183,7 @@ var commonSocketPaths = []string{

func getDockerSocketPath(configDockerHost string) (string, error) {
// a `-` means don't mount the docker socket to job containers
if configDockerHost != "" && configDockerHost != "-" {
if configDockerHost != "automount" && configDockerHost != "-" {
return configDockerHost, nil
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ container:
# - '**'
valid_volumes: []
# overrides the docker client host with the specified one.
# If "-", 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 "-" or "", an available docker host will automatically be found.
# 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.
docker_host: "-"
# Pull docker image(s) even if already present
Expand Down
5 changes: 1 addition & 4 deletions internal/pkg/envcheck/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import (
func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error {
opts := []client.Opt{
client.FromEnv,
}

if configDockerHost != "" {
opts = append(opts, client.WithHost(configDockerHost))
client.WithHost(configDockerHost),
}

cli, err := client.NewClientWithOpts(opts...)
Expand Down

0 comments on commit f8b0ccf

Please sign in to comment.