internal/app: relocate dynamic exported state
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m12s
Test / Hakurei (push) Successful in 3m8s
Test / Hpkg (push) Successful in 3m55s
Test / Sandbox (race detector) (push) Successful in 4m30s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m30s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m12s
Test / Hakurei (push) Successful in 3m8s
Test / Hpkg (push) Successful in 3m55s
Test / Sandbox (race detector) (push) Successful in 4m30s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m30s
This allows reuse of the populateEarly method in test instrumentation. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
034c59a26a
commit
16bf3178d3
@ -96,21 +96,7 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID,
|
|||||||
EnvPaths: copyPaths(k.syscallDispatcher),
|
EnvPaths: copyPaths(k.syscallDispatcher),
|
||||||
Container: config.Container,
|
Container: config.Container,
|
||||||
}
|
}
|
||||||
|
kp.waitDelay = s.populateEarly(k.syscallDispatcher, msg)
|
||||||
// enforce bounds and default early
|
|
||||||
if s.Container.WaitDelay <= 0 {
|
|
||||||
kp.waitDelay = hst.WaitDelayDefault
|
|
||||||
} else if s.Container.WaitDelay > hst.WaitDelayMax {
|
|
||||||
kp.waitDelay = hst.WaitDelayMax
|
|
||||||
} else {
|
|
||||||
kp.waitDelay = s.Container.WaitDelay
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.Container.MapRealUID {
|
|
||||||
s.Mapuid, s.Mapgid = k.getuid(), k.getgid()
|
|
||||||
} else {
|
|
||||||
s.Mapuid, s.Mapgid = k.overflowUid(msg), k.overflowGid(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(ophestra): duplicate in shim (params to shim)
|
// TODO(ophestra): duplicate in shim (params to shim)
|
||||||
if err := s.populateLocal(k.syscallDispatcher, msg); err != nil {
|
if err := s.populateLocal(k.syscallDispatcher, msg); err != nil {
|
||||||
|
@ -2,6 +2,7 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/container/check"
|
||||||
@ -68,6 +69,27 @@ func (s *outcomeState) valid() bool {
|
|||||||
s.EnvPaths != nil
|
s.EnvPaths != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// populateEarly populates exported fields via syscallDispatcher.
|
||||||
|
// This must only be called from the priv side.
|
||||||
|
func (s *outcomeState) populateEarly(k syscallDispatcher, msg container.Msg) (waitDelay time.Duration) {
|
||||||
|
// enforce bounds and default early
|
||||||
|
if s.Container.WaitDelay <= 0 {
|
||||||
|
waitDelay = hst.WaitDelayDefault
|
||||||
|
} else if s.Container.WaitDelay > hst.WaitDelayMax {
|
||||||
|
waitDelay = hst.WaitDelayMax
|
||||||
|
} else {
|
||||||
|
waitDelay = s.Container.WaitDelay
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.Container.MapRealUID {
|
||||||
|
s.Mapuid, s.Mapgid = k.getuid(), k.getgid()
|
||||||
|
} else {
|
||||||
|
s.Mapuid, s.Mapgid = k.overflowUid(msg), k.overflowGid(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// populateLocal populates unexported fields from transmitted exported fields.
|
// populateLocal populates unexported fields from transmitted exported fields.
|
||||||
// These fields are cheaper to recompute per-process.
|
// These fields are cheaper to recompute per-process.
|
||||||
func (s *outcomeState) populateLocal(k syscallDispatcher, msg container.Msg) error {
|
func (s *outcomeState) populateLocal(k syscallDispatcher, msg container.Msg) error {
|
||||||
@ -161,7 +183,7 @@ func (state *outcomeStateSys) runtime() *check.Absolute {
|
|||||||
type outcomeStateParams struct {
|
type outcomeStateParams struct {
|
||||||
// Overrides the embedded [container.Params] in [container.Container]. The Env field must not be used.
|
// Overrides the embedded [container.Params] in [container.Container]. The Env field must not be used.
|
||||||
params *container.Params
|
params *container.Params
|
||||||
// Collapsed into the Env slice in [container.Params] after every call to outcomeOp.toContainer completes.
|
// Collapsed into the Env slice in [container.Params] by the final outcomeOp.
|
||||||
env map[string]string
|
env map[string]string
|
||||||
|
|
||||||
// Filesystems with the optional root sliced off if present. Populated by spParamsOp.
|
// Filesystems with the optional root sliced off if present. Populated by spParamsOp.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user