mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-16 21:03:43 +00:00
fix: misc improvements (#1415)
- Stop overwriting the image's `ImageOS`. `ubuntu-latest` got `ubuntu20` on the 24.04 default image. - Derive `ImageOS` from `os-release` when the image sets none. Fall back to `ubuntu24` for `ubuntu-latest`. - Keep an `ImageOS` set in the job, step or container env. - Honor the image's `ImageOS` on Kubernetes. - Treat steps after a job timeout as cancelled. `cancelled()` and `always()` cleanup now runs. The job still fails. - Record nested reusable workflow results. Jobs that `needs:` a nested call now run. - Forward outputs through nested reusable workflows. A bad output fails the call. - Pass the job's `GITHUB_TOKEN` and `GITEA_TOKEN` to called workflows by default. An explicit mapping overrides them. - Probe a started container's uid and gid concurrently. - Cache the Docker container env from its first inspect. - Check `ImageOS` in the Kubernetes e2e test. --------- Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1415 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
This commit is contained in:
1 parent
1f2ea1b83a
commit
0e4c8b6b78
18 files changed
+225
-56
No files matched your search
+20
-11
@@ -23,6 +23,7 @@ import (
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.com/gitea/runner/act/common"
|
||||
@@ -83,8 +84,13 @@ func (cr *containerReference) Start(attach bool) common.Executor {
|
||||
cr.attach().IfBool(attach),
|
||||
cr.start(),
|
||||
cr.wait().IfBool(attach),
|
||||
cr.tryReadID("-u", func(id int) { cr.UID = id }),
|
||||
cr.tryReadID("-g", func(id int) { cr.GID = id }),
|
||||
func(ctx context.Context) error {
|
||||
var wg sync.WaitGroup
|
||||
wg.Go(func() { _ = cr.tryReadID("-u", func(id int) { cr.UID = id })(ctx) })
|
||||
_ = cr.tryReadID("-g", func(id int) { cr.GID = id })(ctx)
|
||||
wg.Wait()
|
||||
return nil
|
||||
},
|
||||
func(ctx context.Context) error {
|
||||
// If this fails, then folders have wrong permissions on non root container
|
||||
if cr.UID != 0 || cr.GID != 0 {
|
||||
@@ -184,6 +190,9 @@ func (cr *containerReference) Inspect(ctx context.Context) (*Info, error) {
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cr.containerEnvID != cr.id && result.Container.Config != nil {
|
||||
cr.containerEnv, cr.containerEnvID = opts.ConvertKVStringsToMap(result.Container.Config.Env), cr.id
|
||||
}
|
||||
return containerInfoFromInspect(result.Container), nil
|
||||
}
|
||||
|
||||
@@ -307,15 +316,13 @@ func (cr *containerReference) UpdateFromEnv(srcPath string, env *map[string]stri
|
||||
func (cr *containerReference) UpdateFromImageEnv(env *map[string]string) common.Executor {
|
||||
envMap := *env
|
||||
return common.Executor(func(ctx context.Context) error {
|
||||
inspect, err := cr.cli.ContainerInspect(ctx, cr.id, client.ContainerInspectOptions{})
|
||||
if err != nil {
|
||||
common.Logger(ctx).Error(err)
|
||||
return fmt.Errorf("inspect container: %w", err)
|
||||
if cr.containerEnvID != cr.id {
|
||||
if _, err := cr.Inspect(ctx); err != nil {
|
||||
common.Logger(ctx).Error(err)
|
||||
return fmt.Errorf("inspect container: %w", err)
|
||||
}
|
||||
}
|
||||
if inspect.Container.Config == nil {
|
||||
return nil
|
||||
}
|
||||
for key, value := range opts.ConvertKVStringsToMap(inspect.Container.Config.Env) {
|
||||
for key, value := range cr.containerEnv {
|
||||
if envMap[key] == "" {
|
||||
envMap[key] = value
|
||||
} else if key == "PATH" {
|
||||
@@ -365,7 +372,9 @@ type containerReference struct {
|
||||
// attachDone is closed by the attach() streaming goroutine once it has
|
||||
// drained and flushed the container's output. wait() blocks on it so the
|
||||
// tail of the log lands before the step proceeds.
|
||||
attachDone chan struct{}
|
||||
attachDone chan struct{}
|
||||
containerEnv map[string]string // fixed at creation, cached by inspect for containerEnvID
|
||||
containerEnvID string
|
||||
LinuxContainerEnvironmentExtensions
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user