Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- GO111MODULE=on
- GOPATH=/home/circleci/go
- GOFLAGS=-mod=vendor
- GOVERSION=1.13.15
- GOVERSION=1.24.11
- # OS/ARCH are for the go tooling that running on circle CI server. Not for building Fn Server
- OS=linux
- ARCH=amd64
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
fi
- when:
condition:
equal: ["master", << pipeline.git.branch >> ]
equal: ["marleung/publish-latest", << pipeline.git.branch >> ]
steps:
# Once the test pass and if it is a master branch, do a multi-arch build and push
- run:
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Graduation: Some extensions can graduate into core if they become commonplace in

### Build Dependencies ###
- [Go](https://golang.org/doc/install)
- [Dep](https://github.com/golang/dep)

### Getting the Repository ###

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ARG DIND_VERSION=24.0.9-dind

# build stage
FROM golang:1.10-alpine AS build-env
RUN apk --no-cache add build-base git bzr mercurial gcc
FROM golang:1.24-alpine AS build-env
RUN apk --no-cache add gcc musl-dev
ENV D=/go/src/github.com/fnproject/fn
ADD . $D
RUN cd $D/cmd/fnserver && go build -o fn-alpine && cp fn-alpine /tmp/
RUN cd $D/cmd/fnserver && CGO_ENABLED=1 go build -o fn-alpine && cp fn-alpine /tmp/

# final stage: using docker:dind as base image
FROM docker:${DIND_VERSION}
Expand Down
16 changes: 8 additions & 8 deletions api/agent/agent_evict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestPlainNoEvict(t *testing.T) {
defer wg.Done()
err := execFn(`{"sleepTime": 8000}`, getFn(0), getApp(), a, 20000)
if err != nil {
t.Fatalf("submit should not error! %v", err)
t.Errorf("submit should not error! %v", err)
}
}()

Expand All @@ -206,7 +206,7 @@ func TestPlainNoEvict(t *testing.T) {
time.Sleep(3000 * time.Millisecond)
err := execFn(`{"sleepTime": 0}`, getFn(0), getApp(), a, 20000)
if err != models.ErrCallTimeoutServerBusy {
t.Fatalf("unexpected error %v", err)
t.Errorf("unexpected error %v", err)
}
}()

Expand All @@ -228,7 +228,7 @@ func TestPlainDoEvict(t *testing.T) {
defer wg.Done()
err := execFn(`{"sleepTime": 0}`, getFn(0), getApp(), a, 20000)
if err != nil {
t.Fatalf("submit should not error! %v", err)
t.Errorf("submit should not error! %v", err)
}
}()

Expand All @@ -237,7 +237,7 @@ func TestPlainDoEvict(t *testing.T) {
time.Sleep(3000 * time.Millisecond)
err := execFn(`{"sleepTime": 0}`, getFn(0), getApp(), a, 20000)
if err != nil {
t.Fatalf("submit should not error! %v", err)
t.Errorf("submit should not error! %v", err)
}
}()

Expand All @@ -258,7 +258,7 @@ func TestHungFDKNoEvict(t *testing.T) {
defer wg.Done()
err := execFn(`{"sleepTime": 0}`, getFn(11000), getApp(), a, 20000)
if err != models.ErrContainerInitTimeout {
t.Fatalf("submit unexpected error! %v", err)
t.Errorf("submit unexpected error! %v", err)
}
}()

Expand All @@ -267,7 +267,7 @@ func TestHungFDKNoEvict(t *testing.T) {
time.Sleep(3000 * time.Millisecond)
err := execFn(`{"sleepTime": 0}`, getFn(0), getApp(), a, 20000)
if err != models.ErrCallTimeoutServerBusy {
t.Fatalf("unexpected error %v", err)
t.Errorf("unexpected error %v", err)
}
}()

Expand Down Expand Up @@ -295,7 +295,7 @@ func TestDockerPullHungNoEvict(t *testing.T) {

err := execFn(`{"sleepTime": 0}`, fn, getApp(), a, 20000)
if err != models.ErrDockerPullTimeout {
t.Fatalf("unexpected error %v", err)
t.Errorf("unexpected error %v", err)
}
}()

Expand All @@ -304,7 +304,7 @@ func TestDockerPullHungNoEvict(t *testing.T) {
time.Sleep(3000 * time.Millisecond)
err := execFn(`{"sleepTime": 0}`, getFn(0), getApp(), a, 20000)
if err != models.ErrCallTimeoutServerBusy {
t.Fatalf("unexpected error %v", err)
t.Errorf("unexpected error %v", err)
}
}()

Expand Down
14 changes: 6 additions & 8 deletions api/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,7 @@ func TestGetCallReturnsResourceImpossibility(t *testing.T) {
}
}

//
// Tmp directory should be RW by default.
//
func TestTmpFsRW(t *testing.T) {

app := &models.App{ID: "app_id"}
Expand Down Expand Up @@ -1222,13 +1220,13 @@ func TestNBIOResourceTracker(t *testing.T) {
body := `{sleepTime": 10000, "isDebug": true}`
req, err := http.NewRequest("GET", call.URL, strings.NewReader(body))
if err != nil {
t.Fatal("unexpected error building request", err)
t.Errorf("unexpected error building request %v", err)
}

var outOne bytes.Buffer
callI, err := a.GetCall(FromHTTPFnRequest(app, fn, req), WithWriter(&outOne))
if err != nil {
t.Fatal(err)
t.Error(err)
}

err = a.Submit(callI)
Expand Down Expand Up @@ -1539,27 +1537,27 @@ func TestSlotErrorRetention(t *testing.T) {
body := fmt.Sprintf(`{"sleepTime": 5, "echoContent":"%s"}`, echoContent)
req, err := http.NewRequest("GET", url, strings.NewReader(body))
if err != nil {
t.Fatalf("unexpected error building request %v", err)
t.Errorf("unexpected error building request %v", err)
}
req = req.WithContext(ctx)

var out bytes.Buffer
callI, err := a.GetCall(FromHTTPFnRequest(app, fn, req), WithWriter(&out))
if err != nil {
t.Fatalf("unexpected error building call %v", err)
t.Errorf("unexpected error building call %v", err)
}

callI.Model().Config["ENABLE_FAIL_IF_FN_SPAWN_CALL_ID_NONMATCH"] = uniqId
callI.Model().Config["ENABLE_FAIL_IF_FN_SPAWN_CALL_ID_NONMATCH_MSEC"] = "100"

err = a.Submit(callI)
if err != nil {
t.Fatalf("submit should not error %v", err)
t.Errorf("submit should not error %v", err)
}

res, err := http.ReadResponse(bufio.NewReader(&out), nil)
if err != nil {
t.Fatalf("read resp should not error %v", err)
t.Errorf("read resp should not error %v", err)
}

checkBody(res)
Expand Down
2 changes: 1 addition & 1 deletion api/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const (
EnvHotPoll = "FN_HOT_POLL_MSECS"
// EnvHotLauncherTimeout is the timeout for a hot container queue to persist if idle
EnvHotLauncherTimeout = "FN_HOT_LAUNCHER_TIMEOUT_MSECS"
// EnvHotStartTimeout is the timeout for a hot container to be created including docker-pull
// EnvHotPullTimeout is the timeout for a hot container to be created including docker-pull
EnvHotPullTimeout = "FN_HOT_PULL_TIMEOUT_MSECS"
// EnvHotStartTimeout is the timeout for a hot container to become available for use for requests after EnvHotStartTimeout
EnvHotStartTimeout = "FN_HOT_START_TIMEOUT_MSECS"
Expand Down
12 changes: 6 additions & 6 deletions api/agent/doc.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Package agent defines the Agent interface and related concepts. An agent is
// an entity that knows how to execute an Fn function.
//
// The Agent Interface
// # The Agent Interface
//
// The Agent interface is the heart of this package. Agent exposes an api to
// create calls from various parameters and then execute those calls. An Agent
// has a few roles:
// * manage the memory pool for a given server
// * manage the container lifecycle for calls
// * execute calls against containers
// * invoke Start and End for each call appropriately
// - manage the memory pool for a given server
// - manage the container lifecycle for calls
// - execute calls against containers
// - invoke Start and End for each call appropriately
//
// For more information about how an agent executes a call see the
// documentation on the Agent interface.
//
// Variants
// # Variants
//
// There are two flavors of runner, the local Docker agent and a load-balancing
// agent. To create an agent that uses Docker containers to execute calls, use
Expand Down
4 changes: 2 additions & 2 deletions api/agent/drivers/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// runtimes (e.g. Docker, Rkt, etc.) and provides utlities and data types that
// are common across all runtimes.
//
// Docker Driver
// # Docker Driver
//
// The docker driver runs functions as Docker containers.
//
// Mock Driver
// # Mock Driver
//
// The mock driver pretends to run functions but doesn't actually run them. This
// is for testing only.
Expand Down
2 changes: 2 additions & 0 deletions api/agent/drivers/docker/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Package docker provides a Docker driver for Fn. Provides an implementation
// of
//
// github.com/fnproject/fn/api/agent/drivers.Driver
//
// that knows how to run Docker images.
package docker
8 changes: 4 additions & 4 deletions api/agent/drivers/docker/image_puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestImagePullConcurrent1(t *testing.T) {
defer wg.Done()
err := <-puller.PullImage(ctx, &cfg, img, repo, tag1)
if err != nil {
t.Fatalf("err received %v", err)
t.Errorf("err received %v", err)
}
}()
}
Expand All @@ -62,7 +62,7 @@ func TestImagePullConcurrent1(t *testing.T) {
defer wg.Done()
err := <-puller.PullImage(ctx, &cfg, img, repo, tag2)
if err != nil {
t.Fatalf("err received %v", err)
t.Errorf("err received %v", err)
}
}()
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestImagePullConcurrent2(t *testing.T) {
defer wg.Done()
err := <-puller.PullImage(ctx, &cfg, img, repo, tag)
if err == nil || strings.Index(err.Error(), "yogurt") == -1 {
t.Fatalf("Unknown err received %v", err)
t.Errorf("Unknown err received %v", err)
}
}()
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestImagePullConcurrent3(t *testing.T) {
defer wg.Done()
err := <-puller.PullImage(ctx, &cfg, img, repo, tag)
if err == nil {
t.Fatalf("no err received")
t.Errorf("no err received")
}
}()
}
Expand Down
2 changes: 1 addition & 1 deletion api/agent/pure_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (ch *callHandle) getTryMsg() *runner.TryCall {
case <-ch.doneQueue:
case <-ch.ctx.Done():
// if ctx timed out while waiting, then this is a 503 (retriable)
err := status.Errorf(codes.Code(models.ErrCallTimeoutServerBusy.Code()), models.ErrCallTimeoutServerBusy.Error())
err := status.Error(codes.Code(models.ErrCallTimeoutServerBusy.Code()), models.ErrCallTimeoutServerBusy.Error())
ch.shutdown(err)
return nil
case item := <-ch.inQueue:
Expand Down
14 changes: 7 additions & 7 deletions api/agent/runner_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func sendToRunner(ctx context.Context, protocolClient pb.RunnerProtocol_EngageCl
data := writeBuffer[:n]
infoMsg = fmt.Sprintf("Sending %d bytes of data isEOF=%v to runner", n, isEOF)
span.Annotate([]trace.Attribute{trace.StringAttribute("status", infoMsg)}, "")
log.Debugf(infoMsg)
log.Debug(infoMsg)
sendErr := protocolClient.Send(&pb.ClientMsg{
Body: &pb.ClientMsg_Data{
Data: &pb.DataFrame{
Expand All @@ -291,7 +291,7 @@ func sendToRunner(ctx context.Context, protocolClient pb.RunnerProtocol_EngageCl
if sendErr != io.EOF {
errorMsg = fmt.Sprintf("Failed to send data frame size=%d isEOF=%v", n, isEOF)
span.SetStatus(trace.Status{Code: int32(trace.StatusCodeDataLoss), Message: errorMsg})
log.WithError(sendErr).Errorf(errorMsg)
log.WithError(sendErr).Error(errorMsg)
}
return
}
Expand Down Expand Up @@ -390,7 +390,7 @@ DataLoop:
case *pb.CallResultStart_Http:
infoMsg = fmt.Sprintf("Received meta http result from runner Status=%v", meta.Http.StatusCode)
span.Annotate([]trace.Attribute{trace.StringAttribute("status", infoMsg)}, "")
log.Debugf(infoMsg)
log.Debug(infoMsg)
for _, header := range meta.Http.Headers {
clonedHeaders.Add(header.Key, header.Value)
w.Header().Add(header.Key, header.Value)
Expand All @@ -402,22 +402,22 @@ DataLoop:
default:
errorMsg = fmt.Sprintf("Unhandled meta type in start message: %v", meta)
span.SetStatus(trace.Status{Code: trace.StatusCodeDataLoss, Message: errorMsg})
log.Errorf(errorMsg)
log.Error(errorMsg)
}

// May arrive if function has output. We ignore EOF.
case *pb.RunnerMsg_Data:
infoMsg = fmt.Sprintf("Received data from runner len=%d isEOF=%v", len(body.Data.Data), body.Data.Eof)
span.Annotate([]trace.Attribute{trace.StringAttribute("status", infoMsg)}, "")
log.Debugf(infoMsg)
log.Debug(infoMsg)
if !isPartialWrite {
// WARNING: blocking write
n, err := w.Write(body.Data.Data)
if n != len(body.Data.Data) {
isPartialWrite = true
errorMsg = fmt.Sprintf("Failed to write full response (%d of %d) to client", n, len(body.Data.Data))
span.SetStatus(trace.Status{Code: int32(trace.StatusCodeDataLoss), Message: errorMsg})
log.WithError(err).Infof(errorMsg)
log.WithError(err).Info(errorMsg)
if err == nil {
err = io.ErrShortWrite
}
Expand Down Expand Up @@ -456,7 +456,7 @@ DataLoop:
default:
errorMsg = fmt.Sprintf("Ignoring unknown message type %T from runner, possible client/server mismatch", body)
span.SetStatus(trace.Status{Code: trace.StatusCodeUnauthenticated, Message: errorMsg})
log.Errorf(errorMsg)
log.Error(errorMsg)
}
}

Expand Down
12 changes: 6 additions & 6 deletions api/agent/slots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestSlotQueueBasic1(t *testing.T) {
t.Fatalf("Should not get anything from queue")
}
if err != context.DeadlineExceeded {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}

// create slots
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestSlotQueueBasic1(t *testing.T) {

err = checkGetTokenId(t, obj, timeout, 8)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}

// acquire 7 before we can consume
Expand All @@ -137,7 +137,7 @@ func TestSlotQueueBasic1(t *testing.T) {

err = checkGetTokenId(t, obj, timeout, 6)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
}

Expand All @@ -155,7 +155,7 @@ func TestSlotQueueBasic2(t *testing.T) {
t.Fatalf("Should not get anything from queue")
}
if err != context.DeadlineExceeded {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func TestSlotQueueBasic3(t *testing.T) {
timeout := time.Duration(500) * time.Millisecond
err := checkGetTokenId(t, obj, timeout, 1)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}

// let's acquire 1
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestSlotQueueBasic3(t *testing.T) {

err = checkGetTokenId(t, obj, timeout, 2)
if err != context.DeadlineExceeded {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/common/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type contextKey string
// RequestIDContextKey is the name of the key used to store the request ID into the context
const RequestIDContextKey = "fn_request_id"

//WithRequestID stores a request ID into the context
// WithRequestID stores a request ID into the context
func WithRequestID(ctx context.Context, rid string) context.Context {
return context.WithValue(ctx, contextKey(RequestIDContextKey), rid)
}
Expand Down
Loading