Skip to content

Commit 4cbee96

Browse files
CuriousGeorgiyustiugov
authored andcommitted
Fix gVisor CRI setup in vHive orchestrator
gVisor CRI setup needs to be done in the same place as firecracker CRI setup, otherwise setup parts such as logger setup and orchestrator creation are skipped. Closes firecracker-microvm#696 Signed-off-by: Georgiy Lebedev <[email protected]>
1 parent 2d01449 commit 4cbee96

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

vhive.go

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ import (
3333
"runtime"
3434

3535
ctrdlog "github.com/containerd/containerd/log"
36+
log "github.com/sirupsen/logrus"
3637
"github.com/vhive-serverless/vhive/cri"
3738
fccri "github.com/vhive-serverless/vhive/cri/firecracker"
3839
gvcri "github.com/vhive-serverless/vhive/cri/gvisor"
3940
ctriface "github.com/vhive-serverless/vhive/ctriface"
4041
hpb "github.com/vhive-serverless/vhive/examples/protobuf/helloworld"
4142
pb "github.com/vhive-serverless/vhive/proto"
42-
log "github.com/sirupsen/logrus"
4343
"google.golang.org/grpc"
4444
)
4545

@@ -91,13 +91,6 @@ func main() {
9191
return
9292
}
9393

94-
if *sandbox == "gvisor" {
95-
if err := setupGVisorCRI(); err != nil {
96-
log.Fatalf("failed to setup GVisorCRI: %v", err)
97-
}
98-
return
99-
}
100-
10194
if *isUPFEnabled && !*isSnapshotsEnabled {
10295
log.Error("User-level page faults are not supported without snapshots")
10396
return
@@ -132,23 +125,25 @@ func main() {
132125
log.Info(fmt.Sprintf("Creating orchestrator for pinned=%d functions", *pinnedFuncNum))
133126
}
134127

135-
testModeOn := false
136-
137-
orch = ctriface.NewOrchestrator(
138-
*snapshotter,
139-
*hostIface,
140-
ctriface.WithTestModeOn(testModeOn),
141-
ctriface.WithSnapshots(*isSnapshotsEnabled),
142-
ctriface.WithUPF(*isUPFEnabled),
143-
ctriface.WithMetricsMode(*isMetricsMode),
144-
ctriface.WithLazyMode(*isLazyMode),
145-
)
146-
147-
funcPool = NewFuncPool(*isSaveMemory, *servedThreshold, *pinnedFuncNum, testModeOn)
148-
149-
go setupFirecrackerCRI()
150-
go orchServe()
151-
fwdServe()
128+
switch *sandbox {
129+
case "firecracker":
130+
testModeOn := false
131+
orch = ctriface.NewOrchestrator(
132+
*snapshotter,
133+
*hostIface,
134+
ctriface.WithTestModeOn(testModeOn),
135+
ctriface.WithSnapshots(*isSnapshotsEnabled),
136+
ctriface.WithUPF(*isUPFEnabled),
137+
ctriface.WithMetricsMode(*isMetricsMode),
138+
ctriface.WithLazyMode(*isLazyMode),
139+
)
140+
funcPool = NewFuncPool(*isSaveMemory, *servedThreshold, *pinnedFuncNum, testModeOn)
141+
go setupFirecrackerCRI()
142+
go orchServe()
143+
fwdServe()
144+
case "gvisor":
145+
setupGVisorCRI()
146+
}
152147
}
153148

154149
type server struct {
@@ -265,28 +260,27 @@ func (s *fwdServer) FwdHello(ctx context.Context, in *hpb.FwdHelloReq) (*hpb.Fwd
265260
return resp, err
266261
}
267262

268-
func setupGVisorCRI() error {
263+
func setupGVisorCRI() {
269264
lis, err := net.Listen("unix", *criSock)
270265
if err != nil {
271-
return fmt.Errorf("failed to listen: %v", err)
266+
log.Fatalf("failed to listen: %v", err)
272267
}
273268

274269
s := grpc.NewServer()
275270

276271
gvService, err := gvcri.NewGVisorService()
277272
if err != nil {
278-
return fmt.Errorf("failed to create firecracker service %v", err)
273+
log.Fatalf("failed to create gVisor service %v", err)
279274
}
280275

281276
criService, err := cri.NewService(gvService)
282277
if err != nil {
283-
return fmt.Errorf("failed to create CRI service %v", err)
278+
log.Fatalf("failed to create CRI service %v", err)
284279
}
285280

286281
criService.Register(s)
287282

288283
if err := s.Serve(lis); err != nil {
289-
return fmt.Errorf("failed to serve: %v", err)
284+
log.Fatalf("failed to serve: %v", err)
290285
}
291-
return nil
292286
}

0 commit comments

Comments
 (0)