diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-07-09 09:45:43 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-07-09 09:45:43 +0900 |
| commit | 6cfd8fb93484b5683f4a59f84b5bf5b0dde208a2 (patch) | |
| tree | 9ff4b57607fc965963746378184b834d4fbdfd58 /internal/pkg/exec.go | |
| parent | 2f1534853a187018b94754e5ae2f009d7c2ae347 (diff) | |
internal/pkg: loadavg target in container environment
This exposes preferred loadavg target to the container initial process.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec.go')
| -rw-r--r-- | internal/pkg/exec.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index d9063c74..c7d8c30d 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -30,10 +30,16 @@ import ( // AbsWork is the container pathname [TContext.GetWorkDir] is mounted on. var AbsWork = fhs.AbsRoot.Append("work/") -// EnvJobs is the name of the environment variable holding a decimal -// representation of the preferred job count. Its value must not affect cure -// outcome. -const EnvJobs = "CURE_JOBS" +const ( + // EnvJobs is the name of the environment variable holding a decimal + // representation of the preferred job count. Its value must not affect cure + // outcome. + EnvJobs = "CURE_JOBS" + // EnvLoad is the name of the environment variable holding a decimal + // representation of the preferred loadavg target. Its value must not affect + // cure outcome. + EnvLoad = "CURE_LOAD" +) // ExecPath is a slice of [Artifact] and the [check.Absolute] pathname to make // it available at under in the container. @@ -471,7 +477,7 @@ const SeccompPresets = std.PresetStrict & func (a *execArtifact) makeContainer( ctx context.Context, msg message.Msg, - flags, jobs int, + flags, jobs, load int, hostNet bool, temp, work *check.Absolute, getArtifact GetArtifactFunc, @@ -508,7 +514,10 @@ func (a *execArtifact) makeContainer( z.Quiet = flags&CSuppressInit != 0 z.Uid, z.Gid = (1<<10)-1, (1<<10)-1 z.Dir, z.Path, z.Args = a.dir, a.path, a.args - z.Env = slices.Concat(a.env, []string{EnvJobs + "=" + strconv.Itoa(jobs)}) + z.Env = slices.Concat(a.env, []string{ + EnvJobs + "=" + strconv.Itoa(jobs), + EnvLoad + "=" + strconv.Itoa(load), + }) z.Grow(len(a.paths) + 4) if a.arch != runtime.GOARCH { @@ -651,6 +660,7 @@ func (c *Cache) EnterExec( ctx, c.msg, c.attr.Flags, c.attr.Jobs, + c.attr.Load, hostNet, temp, work, func(a Artifact) (*check.Absolute, unique.Handle[Checksum]) { @@ -693,7 +703,7 @@ func (a *execArtifact) cure(f *FContext, hostNet bool) (err error) { msg := f.GetMessage() var z *container.Container if z, err = a.makeContainer( - ctx, msg, f.cache.attr.Flags, f.GetJobs(), hostNet, + ctx, msg, f.cache.attr.Flags, f.GetJobs(), f.GetLoad(), hostNet, f.GetTempDir(), f.GetWorkDir(), f.GetArtifact, f.cache.Ident, |
