@@ -33,13 +33,13 @@ import (
33
33
"runtime"
34
34
35
35
ctrdlog "github.com/containerd/containerd/log"
36
+ log "github.com/sirupsen/logrus"
36
37
"github.com/vhive-serverless/vhive/cri"
37
38
fccri "github.com/vhive-serverless/vhive/cri/firecracker"
38
39
gvcri "github.com/vhive-serverless/vhive/cri/gvisor"
39
40
ctriface "github.com/vhive-serverless/vhive/ctriface"
40
41
hpb "github.com/vhive-serverless/vhive/examples/protobuf/helloworld"
41
42
pb "github.com/vhive-serverless/vhive/proto"
42
- log "github.com/sirupsen/logrus"
43
43
"google.golang.org/grpc"
44
44
)
45
45
@@ -91,13 +91,6 @@ func main() {
91
91
return
92
92
}
93
93
94
- if * sandbox == "gvisor" {
95
- if err := setupGVisorCRI (); err != nil {
96
- log .Fatalf ("failed to setup GVisorCRI: %v" , err )
97
- }
98
- return
99
- }
100
-
101
94
if * isUPFEnabled && ! * isSnapshotsEnabled {
102
95
log .Error ("User-level page faults are not supported without snapshots" )
103
96
return
@@ -132,23 +125,25 @@ func main() {
132
125
log .Info (fmt .Sprintf ("Creating orchestrator for pinned=%d functions" , * pinnedFuncNum ))
133
126
}
134
127
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
+ }
152
147
}
153
148
154
149
type server struct {
@@ -265,28 +260,27 @@ func (s *fwdServer) FwdHello(ctx context.Context, in *hpb.FwdHelloReq) (*hpb.Fwd
265
260
return resp , err
266
261
}
267
262
268
- func setupGVisorCRI () error {
263
+ func setupGVisorCRI () {
269
264
lis , err := net .Listen ("unix" , * criSock )
270
265
if err != nil {
271
- return fmt . Errorf ("failed to listen: %v" , err )
266
+ log . Fatalf ("failed to listen: %v" , err )
272
267
}
273
268
274
269
s := grpc .NewServer ()
275
270
276
271
gvService , err := gvcri .NewGVisorService ()
277
272
if err != nil {
278
- return fmt . Errorf ("failed to create firecracker service %v" , err )
273
+ log . Fatalf ("failed to create gVisor service %v" , err )
279
274
}
280
275
281
276
criService , err := cri .NewService (gvService )
282
277
if err != nil {
283
- return fmt . Errorf ("failed to create CRI service %v" , err )
278
+ log . Fatalf ("failed to create CRI service %v" , err )
284
279
}
285
280
286
281
criService .Register (s )
287
282
288
283
if err := s .Serve (lis ); err != nil {
289
- return fmt . Errorf ("failed to serve: %v" , err )
284
+ log . Fatalf ("failed to serve: %v" , err )
290
285
}
291
- return nil
292
286
}
0 commit comments