From 2b797a556a90d56bf3eec525dde8515aadfa69c0 Mon Sep 17 00:00:00 2001 From: Reed Allman Date: Fri, 14 Sep 2018 16:54:18 +0100 Subject: [PATCH] update docs with pro tips for fdk http stream people (#1211) * update docs with pro tips for fdk http stream people * fix bug where container could die before uds wait we used to hang out for an hour. oopsie, thanks Owen --- api/agent/agent.go | 27 ++++++++++++++------------- docs/developers/fn-format.md | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/api/agent/agent.go b/api/agent/agent.go index c599ff19b..be0a95c28 100644 --- a/api/agent/agent.go +++ b/api/agent/agent.go @@ -925,19 +925,6 @@ func (a *agent) runHot(ctx context.Context, call *call, tok ResourceToken, state return } - // now we wait for the socket to be created before handing out any slots - select { - case err := <-udsAwait: // XXX(reed): need to leave a note about pairing ctx here? - // sends a nil error if all is good, we can proceed... - if err != nil { - call.slots.queueSlot(&hotSlot{done: make(chan struct{}), fatalErr: err}) - return - } - case <-ctx.Done(): - call.slots.queueSlot(&hotSlot{done: make(chan struct{}), fatalErr: ctx.Err()}) - return - } - // container is running state.UpdateState(ctx, ContainerStateIdle, call.slots) @@ -949,6 +936,20 @@ func (a *agent) runHot(ctx context.Context, call *call, tok ResourceToken, state go func() { defer shutdownContainer() // also close if we get an agent shutdown / idle timeout + // now we wait for the socket to be created before handing out any slots, need this + // here in case the container dies before making the sock we need to bail + select { + case err := <-udsAwait: // XXX(reed): need to leave a note about pairing ctx here? + // sends a nil error if all is good, we can proceed... + if err != nil { + call.slots.queueSlot(&hotSlot{done: make(chan struct{}), fatalErr: err}) + return + } + case <-ctx.Done(): + call.slots.queueSlot(&hotSlot{done: make(chan struct{}), fatalErr: ctx.Err()}) + return + } + for { select { // make sure everything is up before trying to send slot case <-ctx.Done(): // container shutdown diff --git a/docs/developers/fn-format.md b/docs/developers/fn-format.md index 666f32e1c..ac81441f3 100644 --- a/docs/developers/fn-format.md +++ b/docs/developers/fn-format.md @@ -32,7 +32,7 @@ If `FN_FORMAT` is `http-stream`, then absence of `FN_LISTENER` or "unix:" prefix Before exiting, FDKs __SHOULD__ remove the UDS file (from `FN_LISTENER` path). -FDKs upon creation of UDS file on disk with bind system call __SHOULD__ be ready to receive and handle traffic. Upon bind call, the UDS file __MUST__ be writable by fn-agent. +FDKs upon creation of UDS file on disk with bind system call __SHOULD__ be ready to receive and handle traffic. Upon bind call, the UDS file __MUST__ be writable by fn-agent. In order to create a properly permissioned UDS file, FDKs __MUST__ create a file with [at least] permissions of `0666`, if the language provides support for creating this file with the right permissions this may be easily achieved; users may alternatively bind to a file that is not `FN_LISTENER`, modify its permissions to the required setting, and then symlink that file to `FN_LISTENER` (see fdk-go for an example). Path in `FN_LISTENER` (after "unix:" prefix) cannot be larger than 107 bytes.