Skip to content

Commit 9ba55b5

Browse files
authored
Merge pull request #438 from kzys/fc-master
Upgrade Firecracker Go SDK from 0.21.0 to master
2 parents 8b05434 + 4626db1 commit 9ba55b5

File tree

8 files changed

+156
-44
lines changed

8 files changed

+156
-44
lines changed

_submodules/firecracker

Submodule firecracker updated 278 files

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ require (
1212
github.com/containerd/ttrpc v0.0.0-20190613183316-1fb3814edf44
1313
github.com/containerd/typeurl v0.0.0-20181015155603-461401dc8f19
1414
github.com/containernetworking/cni v0.7.2-0.20190807151350-8c6c47d1c7fc
15-
github.com/containernetworking/plugins v0.8.5
15+
github.com/containernetworking/plugins v0.8.6
1616
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
1717
github.com/docker/distribution v2.7.1+incompatible // indirect
1818
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect
1919
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
20-
github.com/firecracker-microvm/firecracker-go-sdk v0.21.0
20+
github.com/firecracker-microvm/firecracker-go-sdk v0.21.1-0.20200811001213-ee1e7c41b7bd
2121
github.com/go-ole/go-ole v1.2.4 // indirect
2222
github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384 // indirect
23-
github.com/gofrs/uuid v3.2.0+incompatible
23+
github.com/gofrs/uuid v3.3.0+incompatible
2424
github.com/gogo/googleapis v1.1.0 // indirect
2525
github.com/gogo/protobuf v1.3.0
2626
github.com/golang/protobuf v1.3.1
@@ -37,14 +37,14 @@ require (
3737
github.com/prometheus/client_golang v0.9.2 // indirect
3838
github.com/shirou/gopsutil v2.18.12+incompatible
3939
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
40-
github.com/sirupsen/logrus v1.4.2
41-
github.com/stretchr/testify v1.5.1
40+
github.com/sirupsen/logrus v1.6.0
41+
github.com/stretchr/testify v1.6.1
4242
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
4343
github.com/urfave/cli v1.20.0 // indirect
4444
github.com/vishvananda/netlink v1.1.0
4545
go.etcd.io/bbolt v1.3.1-etcd.8 // indirect
4646
golang.org/x/sync v0.0.0-20190423024810-112230192c58
47-
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
47+
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
4848
google.golang.org/genproto v0.0.0-20181109154231-b5d43981345b // indirect
4949
google.golang.org/grpc v1.21.0
5050
gotest.tools v2.2.0+incompatible // indirect

go.sum

Lines changed: 116 additions & 27 deletions
Large diffs are not rendered by default.

runtime/jailer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type jailer interface {
5353
StubDrivesOptions() []FileOpt
5454

5555
// Stop the jailer as a way that is visible from the user-level process (e.g. SIGTERM).
56-
Stop() error
56+
Stop(force bool) error
5757

5858
// Close will do any necessary cleanup that the jailer has accrued.
5959
Close() error

runtime/noop_jailer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,22 @@ func (j *noopJailer) StubDrivesOptions() []FileOpt {
101101
return []FileOpt{}
102102
}
103103

104-
func (j *noopJailer) Stop() error {
104+
func (j *noopJailer) Stop(force bool) error {
105105
if j.pid == 0 {
106106
return errors.New("the machine hasn't been started")
107107
}
108108

109-
j.logger.Debugf("sending SIGTERM to %d", j.pid)
109+
signal := syscall.SIGTERM
110+
if force {
111+
signal = syscall.SIGKILL
112+
}
113+
j.logger.Debugf("sending signal %d to %d", signal, j.pid)
110114
p, err := os.FindProcess(j.pid)
111115
if err != nil {
112116
return err
113117
}
114118

115-
err = p.Signal(syscall.SIGTERM)
119+
err = p.Signal(signal)
116120
if err == nil || err.Error() == "os: process already finished" {
117121
return nil
118122
}

runtime/runc_jailer.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ func (j *runcJailer) JailPath() vm.Dir {
124124
func (j *runcJailer) BuildJailedMachine(cfg *config.Config, machineConfig *firecracker.Config, vmID string) ([]firecracker.Opt, error) {
125125
handler := j.BuildJailedRootHandler(cfg, machineConfig, vmID)
126126
fifoHandler := j.BuildLinkFifoHandler()
127+
128+
var debugSDK bool
129+
if level, set := cfg.DebugHelper.GetFirecrackerSDKLogLevel(); set {
130+
debugSDK = level == logrus.DebugLevel
131+
}
127132
// Build a new client since BuildJailedRootHandler modifies the socket path value.
128-
client := firecracker.NewClient(machineConfig.SocketPath, j.logger, machineConfig.Debug)
133+
client := firecracker.NewClient(machineConfig.SocketPath, j.logger, debugSDK)
129134

130135
if machineConfig.NetNS == "" {
131136
if netns := getNetNS(j.configSpec); netns != "" {
@@ -539,6 +544,10 @@ func getNetNS(spec specs.Spec) string {
539544
return ""
540545
}
541546

542-
func (j runcJailer) Stop() error {
543-
return j.runcClient.Kill(j.ctx, j.vmID, int(syscall.SIGTERM), &runc.KillOpts{All: true})
547+
func (j runcJailer) Stop(force bool) error {
548+
signal := syscall.SIGTERM
549+
if force {
550+
signal = syscall.SIGKILL
551+
}
552+
return j.runcClient.Kill(j.ctx, j.vmID, int(signal), &runc.KillOpts{All: true})
544553
}

runtime/service.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,16 @@ func (s *service) shutdownLoop(
12341234
timeout: timeout,
12351235
},
12361236
{
1237-
name: "stop the jailer",
1237+
name: "stop the jailer by SIGTERM",
12381238
shutdown: func() error {
1239-
return s.jailer.Stop()
1239+
return s.jailer.Stop(false)
1240+
},
1241+
timeout: jailerStopTimeout,
1242+
},
1243+
{
1244+
name: "stop the jailer by SIGKILL",
1245+
shutdown: func() error {
1246+
return s.jailer.Stop(true)
12401247
},
12411248
timeout: jailerStopTimeout,
12421249
},

tools/docker/Dockerfile.firecracker-builder

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

14-
FROM rust:1.39-stretch
14+
# Firecracker tends to use latest Rust versions.
15+
# The Rust version below should be matched with
16+
# https://github.com/firecracker-microvm/firecracker/blob/master/tools/devctr/Dockerfile.x86_64.
17+
FROM rust:1.43.1-buster
1518

1619
ENV DEBIAN_FRONTEND="noninteractive"
1720
RUN apt-get update && apt-get install --yes --no-install-recommends \

0 commit comments

Comments
 (0)