container: do not set static deadline
All checks were successful
Test / Create distribution (push) Successful in 1m19s
Test / Sandbox (push) Successful in 3m25s
Test / Hakurei (push) Successful in 5m0s
Test / ShareFS (push) Successful in 4m53s
Test / Sandbox (race detector) (push) Successful in 6m1s
Test / Hakurei (race detector) (push) Successful in 3m37s
Test / Flake checks (push) Successful in 1m27s
All checks were successful
Test / Create distribution (push) Successful in 1m19s
Test / Sandbox (push) Successful in 3m25s
Test / Hakurei (push) Successful in 5m0s
Test / ShareFS (push) Successful in 4m53s
Test / Sandbox (race detector) (push) Successful in 6m1s
Test / Hakurei (race detector) (push) Successful in 3m37s
Test / Flake checks (push) Successful in 1m27s
This usually ends up in the buffer, or completes well before the deadline, however this can still timeout on a very slow system. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -28,9 +28,6 @@ const (
|
|||||||
// CancelSignal is the signal expected by container init on context cancel.
|
// CancelSignal is the signal expected by container init on context cancel.
|
||||||
// A custom [Container.Cancel] function must eventually deliver this signal.
|
// A custom [Container.Cancel] function must eventually deliver this signal.
|
||||||
CancelSignal = SIGUSR2
|
CancelSignal = SIGUSR2
|
||||||
|
|
||||||
// Timeout for writing initParams to Container.setup.
|
|
||||||
initSetupTimeout = 5 * time.Second
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -434,6 +431,8 @@ func (p *Container) Serve() (err error) {
|
|||||||
if p.setup[0] == nil || p.setup[1] == nil {
|
if p.setup[0] == nil || p.setup[1] == nil {
|
||||||
panic("invalid serve")
|
panic("invalid serve")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
defer func() {
|
defer func() {
|
||||||
if closeErr := p.setup[1].Close(); err == nil {
|
if closeErr := p.setup[1].Close(); err == nil {
|
||||||
err = closeErr
|
err = closeErr
|
||||||
@@ -442,6 +441,7 @@ func (p *Container) Serve() (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
p.cancel()
|
p.cancel()
|
||||||
}
|
}
|
||||||
|
close(done)
|
||||||
p.setup[0], p.setup[1] = nil, nil
|
p.setup[0], p.setup[1] = nil, nil
|
||||||
}()
|
}()
|
||||||
if err = p.setup[0].Close(); err != nil {
|
if err = p.setup[0].Close(); err != nil {
|
||||||
@@ -453,15 +453,6 @@ func (p *Container) Serve() (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.setup[1].SetDeadline(time.Now().Add(initSetupTimeout)); err != nil {
|
|
||||||
return &StartError{
|
|
||||||
Fatal: true,
|
|
||||||
Step: "set init pipe deadline",
|
|
||||||
Err: err,
|
|
||||||
Passthrough: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Path == nil {
|
if p.Path == nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Step: "invalid executable pathname",
|
Step: "invalid executable pathname",
|
||||||
@@ -478,6 +469,20 @@ func (p *Container) Serve() (err error) {
|
|||||||
p.SeccompRules = make([]std.NativeRule, 0)
|
p.SeccompRules = make([]std.NativeRule, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t := time.Now().UTC()
|
||||||
|
go func(f *os.File) {
|
||||||
|
select {
|
||||||
|
case <-p.ctx.Done():
|
||||||
|
if cancelErr := f.SetWriteDeadline(t); cancelErr != nil {
|
||||||
|
p.msg.Verbose(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
case <-done:
|
||||||
|
p.msg.Verbose("setup payload took", time.Since(t))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}(p.setup[1])
|
||||||
|
|
||||||
return gob.NewEncoder(p.setup[1]).Encode(&initParams{
|
return gob.NewEncoder(p.setup[1]).Encode(&initParams{
|
||||||
p.Params,
|
p.Params,
|
||||||
Getuid(),
|
Getuid(),
|
||||||
|
|||||||
Reference in New Issue
Block a user