Skip to content

Commit 7ccf1e3

Browse files
grussorussomatnar
andcommitted
Fix: function deletion not followed by container destruction in test
Co-authored-by: Matteo Nardelli <matnar@gmail.com>
1 parent 870dccb commit 7ccf1e3

19 files changed

Lines changed: 105 additions & 105 deletions

File tree

Makefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ serverledge-cli:
1414
executor:
1515
CGO_ENABLED=0 $(GO) build -o $(BIN)/$@ cmd/$@/executor.go
1616

17-
proto:
18-
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/scheduling/protobuf/solver.proto
19-
2017
DOCKERHUB_USER=grussorusso
2118
images: image-python310 image-nodejs17ng image-base
2219
image-python310:
@@ -26,15 +23,6 @@ image-base:
2623
image-nodejs17ng:
2724
docker build -t $(DOCKERHUB_USER)/serverledge-nodejs17ng -f images/nodejs17ng/Dockerfile .
2825

29-
images-multi-arch: image-python310-multi-arch image-nodejs17ng-multi-arch image-base-multi-arch
30-
PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7
31-
image-python310-multi-arch:
32-
docker buildx build --platform $(PLATFORMS) -t $(DOCKERHUB_USER)/serverledge-python310 -f images/python310/Dockerfile --push .
33-
image-base-multi-arch:
34-
docker buildx build --platform $(PLATFORMS) -t $(DOCKERHUB_USER)/serverledge-base -f images/base-alpine/Dockerfile --push .
35-
image-nodejs17ng-multi-arch:
36-
docker buildx build --platform $(PLATFORMS) -t $(DOCKERHUB_USER)/serverledge-nodejs17ng -f images/nodejs17ng/Dockerfile --push .
37-
3826
push-images:
3927
docker push $(DOCKERHUB_USER)/serverledge-python310
4028
docker push $(DOCKERHUB_USER)/serverledge-base

cmd/serverledge/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package main
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"log"
78
"os"
89
"os/signal"
910
"time"
1011

11-
"golang.org/x/net/context"
12+
"github.com/labstack/echo/v4"
1213

1314
"github.com/serverledge-faas/serverledge/internal/api"
1415
"github.com/serverledge-faas/serverledge/internal/config"
@@ -18,8 +19,6 @@ import (
1819
"github.com/serverledge-faas/serverledge/internal/scheduling"
1920
"github.com/serverledge-faas/serverledge/internal/telemetry"
2021
"github.com/serverledge-faas/serverledge/utils"
21-
22-
"github.com/labstack/echo/v4"
2322
)
2423

2524
func main() {

examples/inc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
def handler(params, context):
2+
print(f"Invoked inc with input: {params}")
23
return int(params["input"]) + 1

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/lithammer/shortuuid v3.0.0+incompatible
1616
github.com/mikoim/go-loadavg v0.0.0-20150917074714-35ece5f6d547
1717
github.com/prometheus/client_golang v1.14.0
18-
github.com/spf13/cobra v1.0.0
18+
github.com/spf13/cobra v1.9.1
1919
github.com/spf13/viper v1.4.0
2020
go.etcd.io/etcd/client/v3 v3.5.1
2121
go.opentelemetry.io/otel v1.28.0
@@ -44,7 +44,7 @@ require (
4444
github.com/golang/protobuf v1.5.3 // indirect
4545
github.com/google/uuid v1.6.0 // indirect
4646
github.com/hashicorp/hcl v1.0.0 // indirect
47-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
47+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4848
github.com/kr/pretty v0.3.0 // indirect
4949
github.com/magiconair/properties v1.8.7 // indirect
5050
github.com/mattn/go-colorable v0.1.8 // indirect
@@ -64,7 +64,7 @@ require (
6464
github.com/spf13/afero v1.2.2 // indirect
6565
github.com/spf13/cast v1.3.0 // indirect
6666
github.com/spf13/jwalterweatherman v1.0.0 // indirect
67-
github.com/spf13/pflag v1.0.5 // indirect
67+
github.com/spf13/pflag v1.0.6 // indirect
6868
github.com/valyala/bytebufferpool v1.0.0 // indirect
6969
github.com/valyala/fasttemplate v1.2.1 // indirect
7070
go.etcd.io/etcd/api/v3 v3.5.1 // indirect

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
7777
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
7878
github.com/cornelk/hashmap v1.0.8 h1:nv0AWgw02n+iDcawr5It4CjQIAcdMMKRrs10HOJYlrc=
7979
github.com/cornelk/hashmap v1.0.8/go.mod h1:RfZb7JO3RviW/rT6emczVuC/oxpdz4UsSB2LJSclR1k=
80-
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
80+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
8181
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
8282
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8383
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -197,8 +197,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
197197
github.com/hexablock/vivaldi v0.0.0-20180727225019-07adad3f2b5f h1:vgMos6ed6qNnsswN5hB+l/y/UcuUxyq7OL6pXu8XkaI=
198198
github.com/hexablock/vivaldi v0.0.0-20180727225019-07adad3f2b5f/go.mod h1:oicL+P8ej+PDUzurbqC9ln05I+/+LP0YHljnBmv1HZw=
199199
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
200-
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
201-
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
200+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
201+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
202202
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
203203
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
204204
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -245,7 +245,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk
245245
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
246246
github.com/mikoim/go-loadavg v0.0.0-20150917074714-35ece5f6d547 h1:sKOBS3TQA6gIeu7xDDIJnH1cPmGAa3535gg2/cWrwC4=
247247
github.com/mikoim/go-loadavg v0.0.0-20150917074714-35ece5f6d547/go.mod h1:Gv1gEAo58s56eUbsb59IAFnEr6flyFg9lgryVQnKwhM=
248-
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
249248
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
250249
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
251250
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
@@ -311,8 +310,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
311310
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
312311
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
313312
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
314-
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
315-
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
313+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
316314
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
317315
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
318316
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
@@ -323,13 +321,13 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
323321
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
324322
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
325323
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
326-
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
327-
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
324+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
325+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
328326
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
329327
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
330328
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
331-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
332-
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
329+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
330+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
333331
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
334332
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
335333
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

images/base-alpine/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20-alpine AS build
1+
FROM golang:1.21-alpine AS build
22

33
WORKDIR /sedge
44

internal/api/api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ import (
1717
"github.com/serverledge-faas/serverledge/internal/function"
1818
"github.com/serverledge-faas/serverledge/internal/node"
1919
"github.com/serverledge-faas/serverledge/internal/registration"
20-
"github.com/serverledge-faas/serverledge/internal/scheduling"
2120
"github.com/serverledge-faas/serverledge/internal/telemetry"
2221
"github.com/serverledge-faas/serverledge/internal/workflow"
2322
"github.com/serverledge-faas/serverledge/utils"
23+
"go.opentelemetry.io/otel/attribute"
2424

2525
"github.com/labstack/echo/v4"
2626
"github.com/mikoim/go-loadavg"
27-
28-
"go.opentelemetry.io/otel/attribute"
27+
"github.com/serverledge-faas/serverledge/internal/scheduling"
2928
)
3029

3130
var requestsPool = sync.Pool{
@@ -129,7 +128,7 @@ func PollAsyncResult(c echo.Context) error {
129128
payload := res.Kvs[0].Value
130129
return c.JSONBlob(http.StatusOK, payload)
131130
} else {
132-
return c.JSON(http.StatusNotFound, "request not found")
131+
return c.String(http.StatusNotFound, "")
133132
}
134133
}
135134

@@ -214,7 +213,9 @@ func GetServerStatus(c echo.Context) error {
214213
defer node.Resources.RUnlock()
215214

216215
portNumber := config.GetInt("api.port", 1323)
217-
url := fmt.Sprintf("http://%s:%d", utils.GetIpAddress().String(), portNumber)
216+
217+
address, err := utils.GetOutboundIp()
218+
url := fmt.Sprintf("http://%s:%d", address.String(), portNumber)
218219

219220
loadAvg, err := loadavg.Parse()
220221
loadAvgValues := []float64{-1.0, -1.0, -1.0}
@@ -227,7 +228,6 @@ func GetServerStatus(c echo.Context) error {
227228
AvailableWarmContainers: node.WarmStatus(),
228229
AvailableMemMB: node.Resources.AvailableMemMB,
229230
AvailableCPUs: node.Resources.AvailableCPUs,
230-
DropCount: node.Resources.DropCount,
231231
Coordinates: *registration.Reg.Client.GetCoordinate(),
232232
LoadAvg: loadAvgValues,
233233
}

internal/api/server.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"os/signal"
1111
"time"
1212

13+
"github.com/labstack/echo/v4"
14+
"github.com/labstack/echo/v4/middleware"
1315
"github.com/serverledge-faas/serverledge/internal/cache"
1416
"github.com/serverledge-faas/serverledge/internal/config"
1517
"github.com/serverledge-faas/serverledge/internal/node"
1618
"github.com/serverledge-faas/serverledge/internal/registration"
1719
"github.com/serverledge-faas/serverledge/internal/scheduling"
18-
"github.com/labstack/echo/v4"
19-
"github.com/labstack/echo/v4/middleware"
2020
)
2121

2222
func StartAPIServer(e *echo.Echo) {
@@ -105,8 +105,6 @@ func CreateSchedulingPolicy() scheduling.Policy {
105105
return &scheduling.CloudEdgePolicy{}
106106
} else if policyConf == "edgeonly" {
107107
return &scheduling.EdgePolicy{}
108-
} else if policyConf == "custom1" {
109-
return &scheduling.Custom1Policy{}
110108
} else { // default, localonly
111109
return &scheduling.DefaultLocalPolicy{}
112110
}

internal/container/container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func Execute(contID ContainerID, req *executor.InvocationRequest) (*executor.Inv
6868
if resp.StatusCode != 200 {
6969
buffer, err2 := io.ReadAll(resp.Body)
7070
if err2 != nil {
71-
return nil, waitDuration, fmt.Errorf("function invocation with params: %s failed with status %s: - can't get response buffer %v", postBodyB, resp.Status, err2)
71+
return nil, waitDuration, fmt.Errorf("function invocation %v failed with status %s: - can't get response buffer %v", req, resp.Status, err2)
7272
}
73-
return nil, waitDuration, fmt.Errorf("function invocation with params: %s failed with status %s: %s", postBodyB, resp.Status, buffer)
73+
return nil, waitDuration, fmt.Errorf("function invocation %v failed with status %s: %s", req, resp.Status, buffer)
7474
}
7575
defer func(Body io.ReadCloser) {
7676
err := Body.Close()

internal/container/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ func (cf *DockerFactory) GetLog(contID ContainerID) (string, error) {
165165
if err != nil {
166166
return "no logs", fmt.Errorf("can't read the logs: %v", err)
167167
}
168-
return fmt.Sprintf("%s\n", logs), nil
168+
return string(logs[:]), nil
169169
}

0 commit comments

Comments
 (0)