Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firecracker snapshot upf ctriface #928

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ SUBDIRS:=ctriface taps misc profile
EXTRAGOARGS:=-v -race -cover
EXTRAGOARGS_NORACE:=-v
EXTRATESTFILES:=vhive_test.go stats.go vhive.go functions.go
# User-level page faults are temporarily disabled (gh-807)
# WITHUPF:=-upfTest
# WITHLAZY:=-lazyTest
WITHUPF:=
WITHLAZY:=
WITHUPF:=-upfTest
WITHLAZY:=-lazyTest
WITHSNAPSHOTS:=-snapshotsTest
CTRDLOGDIR:=/tmp/ctrd-logs

Expand All @@ -45,6 +42,11 @@ test-all: test-subdirs test-orch

test-orch: test test-man

debug:
./scripts/clean_fcctr.sh
sudo mkdir -m777 -p $(CTRDLOGDIR) && sudo env "PATH=$(PATH)" /usr/local/bin/firecracker-containerd --config /etc/firecracker-containerd/config.toml 1>$(CTRDLOGDIR)/fccd_orch_upf_log.out 2>$(CTRDLOGDIR)/fccd_orch_upf_log.err &
sudo env "PATH=$(PATH)" go test $(EXTRATESTFILES) -short $(EXTRAGOARGS) -args $(WITHSNAPSHOTS) $(WITHUPF)

test:
./scripts/clean_fcctr.sh
sudo mkdir -m777 -p $(CTRDLOGDIR) && sudo env "PATH=$(PATH)" /usr/local/bin/firecracker-containerd --config /etc/firecracker-containerd/config.toml 1>$(CTRDLOGDIR)/fccd_orch_noupf_log.out 2>$(CTRDLOGDIR)/fccd_orch_noupf_log.err &
Expand Down
4 changes: 2 additions & 2 deletions bin/containerd-shim-aws-firecracker
Git LFS file not shown
4 changes: 2 additions & 2 deletions bin/default-rootfs.img
Git LFS file not shown
2 changes: 1 addition & 1 deletion bin/firecracker
Git LFS file not shown
4 changes: 2 additions & 2 deletions bin/firecracker-containerd
Git LFS file not shown
4 changes: 2 additions & 2 deletions bin/firecracker-ctr
Git LFS file not shown
3 changes: 2 additions & 1 deletion configs/firecracker-containerd/firecracker-runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"kernel_args": "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules ro systemd.journald.forward_to_console systemd.unit=firecracker.target init=/sbin/overlay-init",
"root_drive": "/var/lib/firecracker-containerd/runtime/default-rootfs.img",
"cpu_template": "T2",
"log_levels": ["info"]
"log_levels": ["debug"],
"debug": true
}
8 changes: 5 additions & 3 deletions cri/firecracker/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import (
"context"
"errors"
"fmt"
"github.com/google/uuid"
"github.com/vhive-serverless/vhive/snapshotting"
"strconv"
"sync"
"sync/atomic"
"time"

"github.com/google/uuid"
"github.com/vhive-serverless/vhive/snapshotting"

log "github.com/sirupsen/logrus"
"github.com/vhive-serverless/vhive/ctriface"
)
Expand Down Expand Up @@ -169,6 +170,7 @@ func (c *coordinator) orchStartVM(ctx context.Context, image, revision string, e

func (c *coordinator) orchLoadInstance(ctx context.Context, snap *snapshotting.Snapshot) (*funcInstance, error) {
vmID := c.getVMID()
originVmID := vmID
logger := log.WithFields(
log.Fields{
"vmID": vmID,
Expand All @@ -181,7 +183,7 @@ func (c *coordinator) orchLoadInstance(ctx context.Context, snap *snapshotting.S
ctxTimeout, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()

resp, _, err := c.orch.LoadSnapshot(ctxTimeout, vmID, snap)
resp, _, err := c.orch.LoadSnapshot(ctxTimeout, originVmID, vmID, snap)
if err != nil {
logger.WithError(err).Error("failed to load VM")
return nil, err
Expand Down
13 changes: 8 additions & 5 deletions ctriface/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
EXTRAGOARGS:=-v -race -cover
EXTRATESTFILES:=iface_test.go iface.go orch_options.go orch.go
BENCHFILES:=bench_test.go iface.go orch_options.go orch.go
# User-level page faults are temporarily disabled (gh-807)
# WITHUPF:=-upf
# WITHLAZY:=-lazy
WITHUPF:=
WITHLAZY:=
WITHUPF:=-upf
WITHLAZY:=-lazy
GOBENCH:=-v -timeout 1500s
CTRDLOGDIR:=/tmp/ctrd-logs

debug:
./../scripts/clean_fcctr.sh
sudo mkdir -m777 -p $(CTRDLOGDIR) && sudo env "PATH=$(PATH)" /usr/local/bin/firecracker-containerd --config /etc/firecracker-containerd/config.toml 1>$(CTRDLOGDIR)/ctriface_log.out 2>$(CTRDLOGDIR)/ctriface_log.err &
sudo env "PATH=$(PATH)" go test $(EXTRATESTFILES) $(EXTRAGOARGS) -args $(WITHUPF)
./../scripts/clean_fcctr.sh

test:
./../scripts/clean_fcctr.sh
sudo mkdir -m777 -p $(CTRDLOGDIR) && sudo env "PATH=$(PATH)" /usr/local/bin/firecracker-containerd --config /etc/firecracker-containerd/config.toml 1>$(CTRDLOGDIR)/ctriface_log.out 2>$(CTRDLOGDIR)/ctriface_log.err &
Expand Down
79 changes: 33 additions & 46 deletions ctriface/failing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,49 @@

package ctriface

import (
"context"
"os"
"testing"
"time"
// func TestStartSnapStop(t *testing.T) {
// // BROKEN BECAUSE StopVM does not work yet.
// // t.Skip("skipping failing test")
// log.SetFormatter(&log.TextFormatter{
// TimestampFormat: ctrdlog.RFC3339NanoFixed,
// FullTimestamp: true,
// })
// //log.SetReportCaller(true) // FIXME: make sure it's false unless debugging

ctrdlog "github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/vhive-serverless/vhive/snapshotting"
)
// log.SetOutput(os.Stdout)

func TestStartSnapStop(t *testing.T) {
// BROKEN BECAUSE StopVM does not work yet.
t.Skip("skipping failing test")
log.SetFormatter(&log.TextFormatter{
TimestampFormat: ctrdlog.RFC3339NanoFixed,
FullTimestamp: true,
})
//log.SetReportCaller(true) // FIXME: make sure it's false unless debugging
// log.SetLevel(log.DebugLevel)

log.SetOutput(os.Stdout)
// testTimeout := 120 * time.Second
// ctx, cancel := context.WithTimeout(namespaces.WithNamespace(context.Background(), namespaceName), testTimeout)
// defer cancel()

log.SetLevel(log.DebugLevel)
// orch := NewOrchestrator("devmapper", "", WithTestModeOn(true))

testTimeout := 120 * time.Second
ctx, cancel := context.WithTimeout(namespaces.WithNamespace(context.Background(), namespaceName), testTimeout)
defer cancel()
// vmID := "2"

orch := NewOrchestrator("devmapper", "", WithTestModeOn(true))
// _, _, err := orch.StartVM(ctx, vmID, testImageName)
// require.NoError(t, err, "Failed to start VM")

vmID := "2"
// err = orch.PauseVM(ctx, vmID)
// require.NoError(t, err, "Failed to pause VM")

_, _, err := orch.StartVM(ctx, vmID, testImageName)
require.NoError(t, err, "Failed to start VM")
// snap := snapshotting.NewSnapshot(vmID, "/fccd/snapshots", testImageName)
// err = orch.CreateSnapshot(ctx, vmID, snap)
// require.NoError(t, err, "Failed to create snapshot of VM")

err = orch.PauseVM(ctx, vmID)
require.NoError(t, err, "Failed to pause VM")
// err = orch.StopSingleVM(ctx, vmID)
// require.NoError(t, err, "Failed to stop VM")

snap := snapshotting.NewSnapshot(vmID, "/fccd/snapshots", testImageName)
err = orch.CreateSnapshot(ctx, vmID, snap)
require.NoError(t, err, "Failed to create snapshot of VM")
// _, _, err = orch.LoadSnapshot(ctx, "1", vmID, snap)
// require.NoError(t, err, "Failed to load snapshot of VM")

err = orch.StopSingleVM(ctx, vmID)
require.NoError(t, err, "Failed to stop VM")
// _, err = orch.ResumeVM(ctx, vmID)
// require.NoError(t, err, "Failed to resume VM")

_, _, err = orch.LoadSnapshot(ctx, vmID, snap)
require.NoError(t, err, "Failed to load snapshot of VM")
// err = orch.StopSingleVM(ctx, vmID)
// require.NoError(t, err, "Failed to stop VM")

_, err = orch.ResumeVM(ctx, vmID)
require.NoError(t, err, "Failed to resume VM")

err = orch.StopSingleVM(ctx, vmID)
require.NoError(t, err, "Failed to stop VM")

_ = snap.Cleanup()
orch.Cleanup()
}
// _ = snap.Cleanup()
// orch.Cleanup()
// }
Loading