fn: runner status and docker load images (#1116)

* fn: runner status and docker load images

Introducing a function run for pure runner Status
calls. Previously, Status gRPC calls returned active
inflight request counts with the purpose of a simple
health checker. However this is not sufficient since
it does not show if agent or docker is healthy. With
this change, if pure runner is configured with a status
image, that image is executed through docker. The
call uses zero memory/cpu/tmpsize settings to ensure
resource tracker does not block it.

However, operators might not always have a docker
repository accessible/available for status image. Or
operators might not want the status to go over the
network. To allow such cases, and in general possibly
caching docker images, added a new environment variable
FN_DOCKER_LOAD_FILE. If this is set, fn-agent during
startup will load these images that were previously
saved with 'docker save' into docker.
This commit is contained in:
Tolga Ceylan
2018-07-12 13:58:38 -07:00
committed by GitHub
parent 62461d93a7
commit 5dc5740a54
26 changed files with 745 additions and 57 deletions

View File

@@ -5,6 +5,7 @@ import (
"io"
"net/http"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/models"
)
@@ -31,9 +32,23 @@ type PKIData struct {
// MTLSRunnerFactory represents a factory method for constructing runners using mTLS
type MTLSRunnerFactory func(addr, certCommonName string, pki *PKIData) (Runner, error)
// RunnerStatus is general information on Runner health as returned by Runner::Status() call
type RunnerStatus struct {
ActiveRequestCount int32 // Number of active running requests on Runner
StatusFailed bool // True if Status execution failed
StatusId string // Call ID for Status
Details string // General/Debug Log information
ErrorCode int32 // If StatusFailed, then error code is set
ErrorStr string // Error details if StatusFailed and ErrorCode is set
CreatedAt common.DateTime // Status creation date at Runner
StartedAt common.DateTime // Status execution date at Runner
CompletedAt common.DateTime // Status completion date at Runner
}
// Runner is the interface to invoke the execution of a function call on a specific runner
type Runner interface {
TryExec(ctx context.Context, call RunnerCall) (bool, error)
Status(ctx context.Context) (*RunnerStatus, error)
Close(ctx context.Context) error
Address() string
}