mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-10 14:02:59 +00:00
Compare commits
45 Commits
2.2.0
...
2.3.0-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fee6f49d38 | ||
|
|
18c95b9ab1 | ||
|
|
c0daa4ebff | ||
|
|
67d1f4fd14 | ||
|
|
87152fffcb | ||
|
|
2250360b56 | ||
|
|
a9de761d71 | ||
|
|
8ae3edbc18 | ||
|
|
0c7789fad6 | ||
|
|
72e3538e36 | ||
|
|
8dadca9cd1 | ||
|
|
b564dd47b6 | ||
|
|
a89cc0bb5c | ||
|
|
8771d8c375 | ||
|
|
a99fcc3af1 | ||
|
|
39ffd8ee84 | ||
|
|
ff37f5c798 | ||
|
|
fb583780f6 | ||
|
|
8f0f949abf | ||
|
|
932ee41b3f | ||
|
|
bff38e4f4d | ||
|
|
d967d3cb37 | ||
|
|
87de26bda3 | ||
|
|
8058e97212 | ||
|
|
a6a2e525de | ||
|
|
d490704133 | ||
|
|
a0dd840ef6 | ||
|
|
0be91280f2 | ||
|
|
f62ea5dade | ||
|
|
9de1129bf7 | ||
|
|
65a1e13195 | ||
|
|
a4214738b9 | ||
|
|
a989238348 | ||
|
|
b8717f35d7 | ||
|
|
938981be1d | ||
|
|
2304f935b4 | ||
|
|
c5fea9ff70 | ||
|
|
f3539d2fb7 | ||
|
|
e26a140448 | ||
|
|
2a614577fb | ||
|
|
486baba7fd | ||
|
|
46eb07e14f | ||
|
|
80fba4d637 | ||
|
|
8594f80c0a | ||
|
|
87bbae1bd7 |
@@ -4,6 +4,6 @@
|
||||
#
|
||||
# This is the build root image for Kata Containers on OpenShift CI.
|
||||
#
|
||||
FROM centos:8
|
||||
FROM registry.centos.org/centos:8
|
||||
|
||||
RUN yum -y update && yum -y install git sudo wget
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
- `firecracker`
|
||||
- `ACRN`
|
||||
|
||||
While `qemu` and `cloud-hypervisor` work out of the box with installation of Kata,
|
||||
some additional configuration is needed in case of `firecracker` and `ACRN`.
|
||||
While `qemu` , `cloud-hypervisor` and `firecracker` work out of the box with installation of Kata,
|
||||
some additional configuration is needed in case of `ACRN`.
|
||||
Refer to the following guides for additional configuration steps:
|
||||
- [Kata Containers with Firecracker](https://github.com/kata-containers/documentation/wiki/Initial-release-of-Kata-Containers-with-Firecracker-support)
|
||||
- [Kata Containers with ACRN Hypervisor](how-to-use-kata-containers-with-acrn.md)
|
||||
|
||||
## Advanced Topics
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This document describes how to set up a single-machine Kubernetes (k8s) cluster.
|
||||
|
||||
The Kubernetes cluster will use the
|
||||
[CRI containerd plugin](https://github.com/containerd/cri) and
|
||||
[CRI containerd plugin](https://github.com/containerd/containerd/tree/main/pkg/cri) and
|
||||
[Kata Containers](https://katacontainers.io) to launch untrusted workloads.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -181,8 +181,8 @@ func newCommand(ctx context.Context, id, containerdBinary, containerdAddress str
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
// StartShim willl start a kata shimv2 daemon which will implemented the
|
||||
// ShimV2 APIs such as create/start/update etc containers.
|
||||
// StartShim is a binary call that starts a kata shimv2 service which will
|
||||
// implement the ShimV2 APIs such as create/start/update etc containers.
|
||||
func (s *service) StartShim(ctx context.Context, opts cdshim.StartOpts) (_ string, retErr error) {
|
||||
bundlePath, err := os.Getwd()
|
||||
if err != nil {
|
||||
@@ -310,6 +310,7 @@ func getTopic(e interface{}) string {
|
||||
return cdruntime.TaskUnknownTopic
|
||||
}
|
||||
|
||||
// Cleanup is a binary call that cleans up resources used by the shim
|
||||
func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err error) {
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Cleanup", shimTracingTags)
|
||||
defer span.End()
|
||||
@@ -369,6 +370,8 @@ func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err e
|
||||
|
||||
// Create a new sandbox or container with the underlying OCI runtime
|
||||
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Create() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Create() end")
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
err = toGRPC(err)
|
||||
@@ -426,6 +429,8 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
|
||||
|
||||
// Start a process
|
||||
func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAPI.StartResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Start() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Start() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Start", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -477,6 +482,8 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAP
|
||||
|
||||
// Delete the initial process and container
|
||||
func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *taskAPI.DeleteResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Delete() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Delete() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Delete", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -529,6 +536,8 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *task
|
||||
|
||||
// Exec an additional process inside the container
|
||||
func (s *service) Exec(ctx context.Context, r *taskAPI.ExecProcessRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Exec() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Exec() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Exec", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -567,6 +576,8 @@ func (s *service) Exec(ctx context.Context, r *taskAPI.ExecProcessRequest) (_ *p
|
||||
|
||||
// ResizePty of a process
|
||||
func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("ResizePty() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("ResizePty() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "ResizePty", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -606,6 +617,8 @@ func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (_
|
||||
|
||||
// State returns runtime state information for a process
|
||||
func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (_ *taskAPI.StateResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("State() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("State() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "State", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -660,6 +673,8 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (_ *taskAP
|
||||
|
||||
// Pause the container
|
||||
func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Pause() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Pause() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Pause", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -699,6 +714,8 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes
|
||||
|
||||
// Resume the container
|
||||
func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Resume() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Resume() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Resume", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -736,6 +753,8 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptyp
|
||||
|
||||
// Kill a process with the provided signal
|
||||
func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Kill() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Kill() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Kill", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -797,6 +816,8 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.E
|
||||
// Since for kata, it cannot get the process's pid from VM,
|
||||
// thus only return the Shim's pid directly.
|
||||
func (s *service) Pids(ctx context.Context, r *taskAPI.PidsRequest) (_ *taskAPI.PidsResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Pids() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Pids() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Pids", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -820,6 +841,8 @@ func (s *service) Pids(ctx context.Context, r *taskAPI.PidsRequest) (_ *taskAPI.
|
||||
|
||||
// CloseIO of a process
|
||||
func (s *service) CloseIO(ctx context.Context, r *taskAPI.CloseIORequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("CloseIO() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("CloseIO() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "CloseIO", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -861,6 +884,8 @@ func (s *service) CloseIO(ctx context.Context, r *taskAPI.CloseIORequest) (_ *pt
|
||||
|
||||
// Checkpoint the container
|
||||
func (s *service) Checkpoint(ctx context.Context, r *taskAPI.CheckpointTaskRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Checkpoint() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Checkpoint() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Checkpoint", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -875,6 +900,8 @@ func (s *service) Checkpoint(ctx context.Context, r *taskAPI.CheckpointTaskReque
|
||||
|
||||
// Connect returns shim information such as the shim's pid
|
||||
func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (_ *taskAPI.ConnectResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Connect() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Connect() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Connect", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -895,6 +922,8 @@ func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (_ *ta
|
||||
}
|
||||
|
||||
func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Shutdown() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Shutdown() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Shutdown", shimTracingTags)
|
||||
|
||||
start := time.Now()
|
||||
@@ -928,6 +957,8 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *
|
||||
}
|
||||
|
||||
func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAPI.StatsResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Stats() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Stats() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Stats", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -957,6 +988,8 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAP
|
||||
|
||||
// Update a running container
|
||||
func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (_ *ptypes.Empty, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Update() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Update() end")
|
||||
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "Update", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
@@ -989,6 +1022,8 @@ func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (_ *
|
||||
|
||||
// Wait for a process to exit
|
||||
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (_ *taskAPI.WaitResponse, err error) {
|
||||
shimLog.WithField("container", r.ID).Debug("Wait() start")
|
||||
defer shimLog.WithField("container", r.ID).Debug("Wait() end")
|
||||
span, _ := katatrace.Trace(s.rootCtx, shimLog, "Wait", shimTracingTags)
|
||||
defer span.End()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Kata test utilities
|
||||
|
||||
This package provides a small set of test utilities. See the
|
||||
[GoDoc](https://godoc.org/github.com/kata-containers/runtime/pkg/katatestutils)
|
||||
[GoDoc](https://pkg.go.dev/github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils)
|
||||
for full details.
|
||||
|
||||
## Test Constraints
|
||||
@@ -165,4 +165,4 @@ func TestOldKernelVersion(t *testing.T) {
|
||||
### Full details
|
||||
|
||||
The public API is shown in [`constraints_api.go`](constraints_api.go) or
|
||||
the [GoDoc](https://godoc.org/github.com/kata-containers/runtime/pkg/katatestutils).
|
||||
the [GoDoc](https://pkg.go.dev/github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils).
|
||||
|
||||
@@ -129,7 +129,7 @@ func StopTracing(ctx context.Context) {
|
||||
// Trace creates a new tracing span based on the specified name and parent context.
|
||||
// It also accepts a logger to record nil context errors and a map of tracing tags.
|
||||
// Tracing tag keys and values are strings.
|
||||
func Trace(parent context.Context, logger *logrus.Entry, name string, tags map[string]string) (otelTrace.Span, context.Context) {
|
||||
func Trace(parent context.Context, logger *logrus.Entry, name string, tags ...map[string]string) (otelTrace.Span, context.Context) {
|
||||
if parent == nil {
|
||||
if logger == nil {
|
||||
logger = kataTraceLogger
|
||||
@@ -139,8 +139,13 @@ func Trace(parent context.Context, logger *logrus.Entry, name string, tags map[s
|
||||
}
|
||||
|
||||
var otelTags []label.KeyValue
|
||||
for k, v := range tags {
|
||||
otelTags = append(otelTags, label.Key(k).String(v))
|
||||
// do not append tags if tracing is disabled
|
||||
if tracing {
|
||||
for _, tagSet := range tags {
|
||||
for k, v := range tagSet {
|
||||
otelTags = append(otelTags, label.Key(k).String(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer := otel.Tracer("kata")
|
||||
|
||||
@@ -29,15 +29,12 @@ import (
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (a *Acrn) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "acrn",
|
||||
"sandbox_id": a.id,
|
||||
}
|
||||
// acrnTracingTags defines tags for the trace span
|
||||
var acrnTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "acrn",
|
||||
}
|
||||
|
||||
// Since ACRN is using the store in a quite abnormal way, let's first draw it back from store to here
|
||||
@@ -159,7 +156,7 @@ func (a *Acrn) kernelParameters() string {
|
||||
|
||||
// Adds all capabilities supported by Acrn implementation of hypervisor interface
|
||||
func (a *Acrn) capabilities(ctx context.Context) types.Capabilities {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "capabilities", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "capabilities", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
return a.arch.capabilities()
|
||||
@@ -284,7 +281,7 @@ func (a *Acrn) buildDevices(ctx context.Context, imagePath string) ([]Device, er
|
||||
|
||||
// setup sets the Acrn structure up.
|
||||
func (a *Acrn) setup(ctx context.Context, id string, hypervisorConfig *HypervisorConfig) error {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "setup", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "setup", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
err := hypervisorConfig.valid()
|
||||
@@ -327,7 +324,7 @@ func (a *Acrn) setup(ctx context.Context, id string, hypervisorConfig *Hyperviso
|
||||
}
|
||||
|
||||
func (a *Acrn) createDummyVirtioBlkDev(ctx context.Context, devices []Device) ([]Device, error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "createDummyVirtioBlkDev", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "createDummyVirtioBlkDev", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Since acrn doesn't support hot-plug, dummy virtio-blk
|
||||
@@ -350,7 +347,7 @@ func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
||||
// Save the tracing context
|
||||
a.ctx = ctx
|
||||
|
||||
span, ctx := katatrace.Trace(ctx, a.Logger(), "createSandbox", a.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, a.Logger(), "createSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
if err := a.setup(ctx, id, hypervisorConfig); err != nil {
|
||||
@@ -415,7 +412,7 @@ func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
||||
|
||||
// startSandbox will start the Sandbox's VM.
|
||||
func (a *Acrn) startSandbox(ctx context.Context, timeoutSecs int) error {
|
||||
span, ctx := katatrace.Trace(ctx, a.Logger(), "startSandbox", a.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, a.Logger(), "startSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
if a.config.Debug {
|
||||
@@ -461,7 +458,7 @@ func (a *Acrn) startSandbox(ctx context.Context, timeoutSecs int) error {
|
||||
|
||||
// waitSandbox will wait for the Sandbox's VM to be up and running.
|
||||
func (a *Acrn) waitSandbox(ctx context.Context, timeoutSecs int) error {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "waitSandbox", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "waitSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
if timeoutSecs < 0 {
|
||||
@@ -475,7 +472,7 @@ func (a *Acrn) waitSandbox(ctx context.Context, timeoutSecs int) error {
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (a *Acrn) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "stopSandbox", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "stopSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
a.Logger().Info("Stopping acrn VM")
|
||||
@@ -547,7 +544,7 @@ func (a *Acrn) updateBlockDevice(drive *config.BlockDrive) error {
|
||||
}
|
||||
|
||||
func (a *Acrn) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "hotplugAddDevice", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "hotplugAddDevice", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
switch devType {
|
||||
@@ -561,7 +558,7 @@ func (a *Acrn) hotplugAddDevice(ctx context.Context, devInfo interface{}, devTyp
|
||||
}
|
||||
|
||||
func (a *Acrn) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "hotplugRemoveDevice", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "hotplugRemoveDevice", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Not supported. return success
|
||||
@@ -570,7 +567,7 @@ func (a *Acrn) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, dev
|
||||
}
|
||||
|
||||
func (a *Acrn) pauseSandbox(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "pauseSandbox", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "pauseSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Not supported. return success
|
||||
@@ -579,7 +576,7 @@ func (a *Acrn) pauseSandbox(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (a *Acrn) resumeSandbox(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "resumeSandbox", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "resumeSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Not supported. return success
|
||||
@@ -590,7 +587,7 @@ func (a *Acrn) resumeSandbox(ctx context.Context) error {
|
||||
// addDevice will add extra devices to acrn command line.
|
||||
func (a *Acrn) addDevice(ctx context.Context, devInfo interface{}, devType deviceType) error {
|
||||
var err error
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "addDevice", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "addDevice", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
switch v := devInfo.(type) {
|
||||
@@ -623,7 +620,7 @@ func (a *Acrn) addDevice(ctx context.Context, devInfo interface{}, devType devic
|
||||
// getSandboxConsole builds the path of the console where we can read
|
||||
// logs coming from the sandbox.
|
||||
func (a *Acrn) getSandboxConsole(ctx context.Context, id string) (string, string, error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "getSandboxConsole", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "getSandboxConsole", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
consoleURL, err := utils.BuildSocketPath(a.store.RunVMStoragePath(), id, acrnConsoleSocket)
|
||||
@@ -643,14 +640,14 @@ func (a *Acrn) saveSandbox() error {
|
||||
}
|
||||
|
||||
func (a *Acrn) disconnect(ctx context.Context) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "disconnect", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "disconnect", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Not supported.
|
||||
}
|
||||
|
||||
func (a *Acrn) getThreadIDs(ctx context.Context) (vcpuThreadIDs, error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "getThreadIDs", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "getThreadIDs", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
// Not supported. return success
|
||||
@@ -668,7 +665,7 @@ func (a *Acrn) resizeVCPUs(ctx context.Context, reqVCPUs uint32) (currentVCPUs u
|
||||
}
|
||||
|
||||
func (a *Acrn) cleanup(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "cleanup", a.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "cleanup", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -38,27 +38,6 @@ func WithNewAgentFunc(ctx context.Context, f newAgentFuncType) context.Context {
|
||||
return context.WithValue(ctx, newAgentFuncKey{}, f)
|
||||
}
|
||||
|
||||
// ProcessListOptions contains the options used to list running
|
||||
// processes inside the container
|
||||
type ProcessListOptions struct {
|
||||
// Format describes the output format to list the running processes.
|
||||
// Formats are unrelated to ps(1) formats, only two formats can be specified:
|
||||
// "json" and "table"
|
||||
Format string
|
||||
|
||||
// Args contains the list of arguments to run ps(1) command.
|
||||
// If Args is empty the agent will use "-ef" as options to ps(1).
|
||||
Args []string
|
||||
}
|
||||
|
||||
// ProcessList represents the list of running processes inside the container
|
||||
type ProcessList []byte
|
||||
|
||||
const (
|
||||
// SocketTypeVSOCK is a VSOCK socket type for talking to an agent.
|
||||
SocketTypeVSOCK = "vsock"
|
||||
)
|
||||
|
||||
// agent is the virtcontainers agent interface.
|
||||
// Agents are running in the guest VM and handling
|
||||
// communications between the host and guest.
|
||||
|
||||
@@ -33,15 +33,12 @@ import (
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (clh *cloudHypervisor) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "clh",
|
||||
"sandbox_id": clh.id,
|
||||
}
|
||||
// clhTracingTags defines tags for the trace span
|
||||
var clhTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "clh",
|
||||
}
|
||||
|
||||
//
|
||||
@@ -196,7 +193,7 @@ var clhDebugKernelParams = []Param{
|
||||
func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||
clh.ctx = ctx
|
||||
|
||||
span, newCtx := katatrace.Trace(clh.ctx, clh.Logger(), "createSandbox", clh.tracingTags())
|
||||
span, newCtx := katatrace.Trace(clh.ctx, clh.Logger(), "createSandbox", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
clh.ctx = newCtx
|
||||
defer span.End()
|
||||
|
||||
@@ -355,7 +352,7 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ
|
||||
|
||||
// startSandbox will start the VMM and boot the virtual machine for the given sandbox.
|
||||
func (clh *cloudHypervisor) startSandbox(ctx context.Context, timeout int) error {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "startSandbox", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "startSandbox", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), clhAPITimeout*time.Second)
|
||||
@@ -522,7 +519,7 @@ func (clh *cloudHypervisor) hotPlugVFIODevice(device config.VFIODev) error {
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "hotplugAddDevice", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "hotplugAddDevice", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
switch devType {
|
||||
@@ -539,7 +536,7 @@ func (clh *cloudHypervisor) hotplugAddDevice(ctx context.Context, devInfo interf
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "hotplugRemoveDevice", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "hotplugRemoveDevice", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
var deviceID string
|
||||
@@ -704,7 +701,7 @@ func (clh *cloudHypervisor) resumeSandbox(ctx context.Context) error {
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (clh *cloudHypervisor) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "stopSandbox", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "stopSandbox", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
clh.Logger().WithField("function", "stopSandbox").Info("Stop Sandbox")
|
||||
return clh.terminate(ctx, waitOnly)
|
||||
@@ -742,11 +739,7 @@ func (clh *cloudHypervisor) check() error {
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) getPids() []int {
|
||||
|
||||
var pids []int
|
||||
pids = append(pids, clh.state.PID)
|
||||
|
||||
return pids
|
||||
return []int{clh.state.PID}
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) getVirtioFsPid() *int {
|
||||
@@ -754,7 +747,7 @@ func (clh *cloudHypervisor) getVirtioFsPid() *int {
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) addDevice(ctx context.Context, devInfo interface{}, devType deviceType) error {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "addDevice", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "addDevice", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
var err error
|
||||
@@ -788,7 +781,7 @@ func (clh *cloudHypervisor) Logger() *log.Entry {
|
||||
|
||||
// Adds all capabilities supported by cloudHypervisor implementation of hypervisor interface
|
||||
func (clh *cloudHypervisor) capabilities(ctx context.Context) types.Capabilities {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "capabilities", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "capabilities", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
clh.Logger().WithField("function", "capabilities").Info("get Capabilities")
|
||||
@@ -799,7 +792,7 @@ func (clh *cloudHypervisor) capabilities(ctx context.Context) types.Capabilities
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) terminate(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "terminate", clh.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "terminate", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
|
||||
pid := clh.state.PID
|
||||
|
||||
@@ -36,13 +36,10 @@ import (
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (c *Container) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "container",
|
||||
"container_id": c.id,
|
||||
}
|
||||
var containerTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "container",
|
||||
}
|
||||
|
||||
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/major.h
|
||||
@@ -619,13 +616,12 @@ func (c *Container) mountSharedDirMounts(ctx context.Context, sharedDirMounts, i
|
||||
}
|
||||
|
||||
func (c *Container) unmountHostMounts(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, c.Logger(), "unmountHostMounts", c.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, c.Logger(), "unmountHostMounts", containerTracingTags, map[string]string{"container_id": c.id})
|
||||
defer span.End()
|
||||
|
||||
for _, m := range c.mounts {
|
||||
if m.HostPath != "" {
|
||||
span, _ := katatrace.Trace(ctx, c.Logger(), "unmount", c.tracingTags())
|
||||
katatrace.AddTag(span, "host-path", m.HostPath)
|
||||
span, _ := katatrace.Trace(ctx, c.Logger(), "unmount", containerTracingTags, map[string]string{"container_id": c.id, "host-path": m.HostPath})
|
||||
|
||||
if err := syscall.Unmount(m.HostPath, syscall.MNT_DETACH|UmountNoFollow); err != nil {
|
||||
c.Logger().WithFields(logrus.Fields{
|
||||
@@ -753,7 +749,7 @@ func (c *Container) initConfigResourcesMemory() {
|
||||
|
||||
// newContainer creates a Container structure from a sandbox and a container configuration.
|
||||
func newContainer(ctx context.Context, sandbox *Sandbox, contConfig *ContainerConfig) (*Container, error) {
|
||||
span, ctx := katatrace.Trace(ctx, sandbox.Logger(), "newContainer", sandbox.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, sandbox.Logger(), "newContainer", containerTracingTags, map[string]string{"container_id": contConfig.ID, "sandbox_id": sandbox.id})
|
||||
defer span.End()
|
||||
|
||||
if !contConfig.valid() {
|
||||
@@ -1049,7 +1045,7 @@ func (c *Container) start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (c *Container) stop(ctx context.Context, force bool) error {
|
||||
span, ctx := katatrace.Trace(ctx, c.Logger(), "stop", c.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, c.Logger(), "stop", containerTracingTags, map[string]string{"container_id": c.id})
|
||||
defer span.End()
|
||||
|
||||
// In case the container status has been updated implicitly because
|
||||
|
||||
@@ -680,7 +680,6 @@ to manage the container lifecycle through the rest of the
|
||||
* [Container `DeviceInfo`](#container-deviceinfo)
|
||||
* [`Process`](#process)
|
||||
* [`ContainerStatus`](#containerstatus)
|
||||
* [`ProcessListOptions`](#processlistoptions)
|
||||
* [`VCContainer`](#vccontainer)
|
||||
|
||||
|
||||
@@ -873,22 +872,6 @@ type ContainerStatus struct {
|
||||
}
|
||||
```
|
||||
|
||||
#### `ProcessListOptions`
|
||||
```Go
|
||||
// ProcessListOptions contains the options used to list running
|
||||
// processes inside the container
|
||||
type ProcessListOptions struct {
|
||||
// Format describes the output format to list the running processes.
|
||||
// Formats are unrelated to ps(1) formats, only two formats can be specified:
|
||||
// "json" and "table"
|
||||
Format string
|
||||
|
||||
// Args contains the list of arguments to run ps(1) command.
|
||||
// If Args is empty the agent will use "-ef" as options to ps(1).
|
||||
Args []string
|
||||
}
|
||||
```
|
||||
|
||||
#### `VCContainer`
|
||||
```Go
|
||||
// VCContainer is the Container interface
|
||||
|
||||
@@ -41,15 +41,12 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (fc *firecracker) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "firecracker",
|
||||
"sandbox_id": fc.id,
|
||||
}
|
||||
// fcTracingTags defines tags for the trace span
|
||||
var fcTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "firecracker",
|
||||
}
|
||||
|
||||
type vmmState uint8
|
||||
@@ -194,7 +191,7 @@ func (fc *firecracker) truncateID(id string) string {
|
||||
func (fc *firecracker) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||
fc.ctx = ctx
|
||||
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "createSandbox", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "createSandbox", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
//TODO: check validity of the hypervisor config provided
|
||||
@@ -237,7 +234,7 @@ func (fc *firecracker) createSandbox(ctx context.Context, id string, networkNS N
|
||||
}
|
||||
|
||||
func (fc *firecracker) newFireClient(ctx context.Context) *client.Firecracker {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "newFireClient", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "newFireClient", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
httpClient := client.NewHTTPClient(strfmt.NewFormats())
|
||||
|
||||
@@ -280,10 +277,18 @@ func (fc *firecracker) getVersionNumber() (string, error) {
|
||||
return "", fmt.Errorf("Running checking FC version command failed: %v", err)
|
||||
}
|
||||
|
||||
return fc.parseVersion(string(data))
|
||||
}
|
||||
|
||||
func (fc *firecracker) parseVersion(data string) (string, error) {
|
||||
// Firecracker versions 0.25 and over contains multiline output on "version" command.
|
||||
// So we have to check it and use first line of output to parse version.
|
||||
lines := strings.Split(data, "\n")
|
||||
|
||||
var version string
|
||||
fields := strings.Split(string(data), " ")
|
||||
fields := strings.Split(lines[0], " ")
|
||||
if len(fields) > 1 {
|
||||
// The output format of `Firecracker --verion` is as follows
|
||||
// The output format of `Firecracker --version` is as follows
|
||||
// Firecracker v0.23.1
|
||||
version = strings.TrimPrefix(strings.TrimSpace(fields[1]), "v")
|
||||
return version, nil
|
||||
@@ -307,7 +312,7 @@ func (fc *firecracker) checkVersion(version string) error {
|
||||
|
||||
// waitVMMRunning will wait for timeout seconds for the VMM to be up and running.
|
||||
func (fc *firecracker) waitVMMRunning(ctx context.Context, timeout int) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "wait VMM to be running", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "wait VMM to be running", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
if timeout < 0 {
|
||||
@@ -329,7 +334,7 @@ func (fc *firecracker) waitVMMRunning(ctx context.Context, timeout int) error {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcInit(ctx context.Context, timeout int) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcInit", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcInit", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
var err error
|
||||
@@ -404,7 +409,7 @@ func (fc *firecracker) fcInit(ctx context.Context, timeout int) error {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcEnd(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcEnd", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcEnd", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
fc.Logger().Info("Stopping firecracker VM")
|
||||
@@ -431,7 +436,7 @@ func (fc *firecracker) fcEnd(ctx context.Context, waitOnly bool) (err error) {
|
||||
}
|
||||
|
||||
func (fc *firecracker) client(ctx context.Context) *client.Firecracker {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "client", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "client", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
if fc.connection == nil {
|
||||
@@ -498,7 +503,7 @@ func (fc *firecracker) fcJailResource(src, dst string) (string, error) {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcSetBootSource(ctx context.Context, path, params string) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetBootSource", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetBootSource", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
fc.Logger().WithFields(logrus.Fields{"kernel-path": path,
|
||||
"kernel-params": params}).Debug("fcSetBootSource")
|
||||
@@ -519,7 +524,7 @@ func (fc *firecracker) fcSetBootSource(ctx context.Context, path, params string)
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcSetVMRootfs(ctx context.Context, path string) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetVMRootfs", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetVMRootfs", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
jailedRootfs, err := fc.fcJailResource(path, fcRootfs)
|
||||
@@ -546,7 +551,7 @@ func (fc *firecracker) fcSetVMRootfs(ctx context.Context, path string) error {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcSetVMBaseConfig(ctx context.Context, mem int64, vcpus int64, htEnabled bool) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetVMBaseConfig", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetVMBaseConfig", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
fc.Logger().WithFields(logrus.Fields{"mem": mem,
|
||||
"vcpus": vcpus,
|
||||
@@ -562,7 +567,7 @@ func (fc *firecracker) fcSetVMBaseConfig(ctx context.Context, mem int64, vcpus i
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcSetLogger(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetLogger", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetLogger", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
fcLogLevel := "Error"
|
||||
@@ -585,7 +590,7 @@ func (fc *firecracker) fcSetLogger(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcSetMetrics(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetMetrics", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcSetMetrics", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
// listen to metrics file and transfer error info
|
||||
@@ -740,7 +745,7 @@ func (fc *firecracker) fcInitConfiguration(ctx context.Context) error {
|
||||
// In the context of firecracker, this will start the hypervisor,
|
||||
// for configuration, but not yet start the actual virtual machine
|
||||
func (fc *firecracker) startSandbox(ctx context.Context, timeout int) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "startSandbox", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "startSandbox", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
if err := fc.fcInitConfiguration(ctx); err != nil {
|
||||
@@ -792,7 +797,7 @@ func fcDriveIndexToID(i int) string {
|
||||
}
|
||||
|
||||
func (fc *firecracker) createDiskPool(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "createDiskPool", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "createDiskPool", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
for i := 0; i < fcDiskPoolSize; i++ {
|
||||
@@ -830,7 +835,7 @@ func (fc *firecracker) umountResource(jailedPath string) {
|
||||
|
||||
// cleanup all jail artifacts
|
||||
func (fc *firecracker) cleanupJail(ctx context.Context) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "cleanupJail", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "cleanupJail", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
fc.umountResource(fcKernel)
|
||||
@@ -853,7 +858,7 @@ func (fc *firecracker) cleanupJail(ctx context.Context) {
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (fc *firecracker) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "stopSandbox", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "stopSandbox", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
return fc.fcEnd(ctx, waitOnly)
|
||||
@@ -872,7 +877,7 @@ func (fc *firecracker) resumeSandbox(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcAddVsock(ctx context.Context, hvs types.HybridVSock) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddVsock", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddVsock", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
udsPath := hvs.UdsPath
|
||||
@@ -892,7 +897,7 @@ func (fc *firecracker) fcAddVsock(ctx context.Context, hvs types.HybridVSock) {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcAddNetDevice(ctx context.Context, endpoint Endpoint) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddNetDevice", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddNetDevice", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
ifaceID := endpoint.Name()
|
||||
@@ -948,7 +953,7 @@ func (fc *firecracker) fcAddNetDevice(ctx context.Context, endpoint Endpoint) {
|
||||
}
|
||||
|
||||
func (fc *firecracker) fcAddBlockDrive(ctx context.Context, drive config.BlockDrive) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddBlockDrive", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcAddBlockDrive", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
driveID := drive.ID
|
||||
@@ -974,7 +979,7 @@ func (fc *firecracker) fcAddBlockDrive(ctx context.Context, drive config.BlockDr
|
||||
|
||||
// Firecracker supports replacing the host drive used once the VM has booted up
|
||||
func (fc *firecracker) fcUpdateBlockDrive(ctx context.Context, path, id string) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcUpdateBlockDrive", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "fcUpdateBlockDrive", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
// Use the global block index as an index into the pool of the devices
|
||||
@@ -998,7 +1003,7 @@ func (fc *firecracker) fcUpdateBlockDrive(ctx context.Context, path, id string)
|
||||
// addDevice will add extra devices to firecracker. Limited to configure before the
|
||||
// virtual machine starts. Devices include drivers and network interfaces only.
|
||||
func (fc *firecracker) addDevice(ctx context.Context, devInfo interface{}, devType deviceType) error {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "addDevice", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "addDevice", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
fc.state.RLock()
|
||||
@@ -1068,7 +1073,7 @@ func (fc *firecracker) hotplugBlockDevice(ctx context.Context, drive config.Bloc
|
||||
|
||||
// hotplugAddDevice supported in Firecracker VMM
|
||||
func (fc *firecracker) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "hotplugAddDevice", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "hotplugAddDevice", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
switch devType {
|
||||
@@ -1084,7 +1089,7 @@ func (fc *firecracker) hotplugAddDevice(ctx context.Context, devInfo interface{}
|
||||
|
||||
// hotplugRemoveDevice supported in Firecracker VMM
|
||||
func (fc *firecracker) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "hotplugRemoveDevice", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "hotplugRemoveDevice", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
switch devType {
|
||||
@@ -1117,7 +1122,7 @@ func (fc *firecracker) disconnect(ctx context.Context) {
|
||||
|
||||
// Adds all capabilities supported by firecracker implementation of hypervisor interface
|
||||
func (fc *firecracker) capabilities(ctx context.Context) types.Capabilities {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "capabilities", fc.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "capabilities", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
var caps types.Capabilities
|
||||
caps.SetBlockDeviceHotplugSupport()
|
||||
|
||||
@@ -52,3 +52,15 @@ func TestRevertBytes(t *testing.T) {
|
||||
num := revertBytes(testNum)
|
||||
assert.Equal(expectedNum, num)
|
||||
}
|
||||
|
||||
func TestFCParseVersion(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
fc := firecracker{}
|
||||
|
||||
for rawVersion, v := range map[string]string{"Firecracker v0.23.1": "0.23.1", "Firecracker v0.25.0\nSupported snapshot data format versions: 0.23.0": "0.25.0"} {
|
||||
parsedVersion, err := fc.parseVersion(rawVersion)
|
||||
assert.NoError(err)
|
||||
assert.Equal(parsedVersion, v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ var rootfsDir = "rootfs"
|
||||
|
||||
var systemMountPrefixes = []string{"/proc", "/sys"}
|
||||
|
||||
// mountTracingTags defines tags for the trace span
|
||||
var mountTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "mount",
|
||||
}
|
||||
|
||||
func mountLogger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "mount")
|
||||
}
|
||||
@@ -240,7 +247,7 @@ func evalMountPath(source, destination string) (string, string, error) {
|
||||
// * ensure the source exists
|
||||
// * recursively create the destination
|
||||
func moveMount(ctx context.Context, source, destination string) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "moveMount", apiTracingTags)
|
||||
span, _ := katatrace.Trace(ctx, nil, "moveMount", mountTracingTags)
|
||||
defer span.End()
|
||||
|
||||
source, destination, err := evalMountPath(source, destination)
|
||||
@@ -258,7 +265,7 @@ func moveMount(ctx context.Context, source, destination string) error {
|
||||
// * recursively create the destination
|
||||
// pgtypes stands for propagation types, which are shared, private, slave, and ubind.
|
||||
func bindMount(ctx context.Context, source, destination string, readonly bool, pgtypes string) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindMount", apiTracingTags)
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindMount", mountTracingTags)
|
||||
defer span.End()
|
||||
span.SetAttributes(otelLabel.String("source", source), otelLabel.String("destination", destination))
|
||||
|
||||
@@ -295,7 +302,7 @@ func bindMount(ctx context.Context, source, destination string, readonly bool, p
|
||||
// The mountflags should match the values used in the original mount() call,
|
||||
// except for those parameters that you are trying to change.
|
||||
func remount(ctx context.Context, mountflags uintptr, src string) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "remount", apiTracingTags)
|
||||
span, _ := katatrace.Trace(ctx, nil, "remount", mountTracingTags)
|
||||
defer span.End()
|
||||
span.SetAttributes(otelLabel.String("source", src))
|
||||
|
||||
@@ -320,7 +327,7 @@ func remountRo(ctx context.Context, src string) error {
|
||||
// bindMountContainerRootfs bind mounts a container rootfs into a 9pfs shared
|
||||
// directory between the guest and the host.
|
||||
func bindMountContainerRootfs(ctx context.Context, shareDir, cid, cRootFs string, readonly bool) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindMountContainerRootfs", apiTracingTags)
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindMountContainerRootfs", mountTracingTags)
|
||||
defer span.End()
|
||||
|
||||
rootfsDest := filepath.Join(shareDir, cid, rootfsDir)
|
||||
@@ -360,7 +367,7 @@ func isSymlink(path string) bool {
|
||||
}
|
||||
|
||||
func bindUnmountContainerRootfs(ctx context.Context, sharedDir, cID string) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindUnmountContainerRootfs", apiTracingTags)
|
||||
span, _ := katatrace.Trace(ctx, nil, "bindUnmountContainerRootfs", mountTracingTags)
|
||||
defer span.End()
|
||||
span.SetAttributes(otelLabel.String("shared_dir", sharedDir), otelLabel.String("container_id", cID))
|
||||
|
||||
@@ -383,7 +390,7 @@ func bindUnmountContainerRootfs(ctx context.Context, sharedDir, cID string) erro
|
||||
}
|
||||
|
||||
func bindUnmountAllRootfs(ctx context.Context, sharedDir string, sandbox *Sandbox) error {
|
||||
span, ctx := katatrace.Trace(ctx, nil, "bindUnmountAllRootfs", apiTracingTags)
|
||||
span, ctx := katatrace.Trace(ctx, nil, "bindUnmountAllRootfs", mountTracingTags)
|
||||
defer span.End()
|
||||
span.SetAttributes(otelLabel.String("shared_dir", sharedDir), otelLabel.String("sandbox_id", sandbox.id))
|
||||
|
||||
|
||||
@@ -38,15 +38,12 @@ import (
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (q *qemu) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "qemu",
|
||||
"sandbox_id": q.id,
|
||||
}
|
||||
// qemuTracingTags defines tags for the trace span
|
||||
var qemuTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "hypervisor",
|
||||
"type": "qemu",
|
||||
}
|
||||
|
||||
// romFile is the file name of the ROM that can be used for virtio-pci devices.
|
||||
@@ -195,7 +192,7 @@ func (q *qemu) kernelParameters() string {
|
||||
|
||||
// Adds all capabilities supported by qemu implementation of hypervisor interface
|
||||
func (q *qemu) capabilities(ctx context.Context) types.Capabilities {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "capabilities", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "capabilities", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
return q.arch.capabilities()
|
||||
@@ -225,7 +222,7 @@ func (q *qemu) qemuPath() (string, error) {
|
||||
|
||||
// setup sets the Qemu structure up.
|
||||
func (q *qemu) setup(ctx context.Context, id string, hypervisorConfig *HypervisorConfig) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "setup", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "setup", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
err := hypervisorConfig.valid()
|
||||
@@ -468,7 +465,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
||||
// Save the tracing context
|
||||
q.ctx = ctx
|
||||
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "createSandbox", q.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "createSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
if err := q.setup(ctx, id, hypervisorConfig); err != nil {
|
||||
@@ -753,7 +750,7 @@ func (q *qemu) setupVirtioMem(ctx context.Context) error {
|
||||
|
||||
// startSandbox will start the Sandbox's VM.
|
||||
func (q *qemu) startSandbox(ctx context.Context, timeout int) error {
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "startSandbox", q.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "startSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
if q.config.Debug {
|
||||
@@ -871,7 +868,7 @@ func (q *qemu) bootFromTemplate() error {
|
||||
|
||||
// waitSandbox will wait for the Sandbox's VM to be up and running.
|
||||
func (q *qemu) waitSandbox(ctx context.Context, timeout int) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "waitSandbox", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "waitSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
if timeout < 0 {
|
||||
@@ -922,7 +919,7 @@ func (q *qemu) waitSandbox(ctx context.Context, timeout int) error {
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (q *qemu) stopSandbox(ctx context.Context, waitOnly bool) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "stopSandbox", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "stopSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
q.Logger().Info("Stopping Sandbox")
|
||||
@@ -1014,7 +1011,7 @@ func (q *qemu) cleanupVM() error {
|
||||
}
|
||||
|
||||
func (q *qemu) togglePauseSandbox(ctx context.Context, pause bool) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "togglePauseSandbox", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "togglePauseSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
if err := q.qmpSetup(); err != nil {
|
||||
@@ -1619,9 +1616,9 @@ func (q *qemu) hotplugDevice(ctx context.Context, devInfo interface{}, devType d
|
||||
}
|
||||
|
||||
func (q *qemu) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "hotplugAddDevice", q.tracingTags())
|
||||
defer span.End()
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "hotplugAddDevice", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
katatrace.AddTag(span, "device", devInfo)
|
||||
defer span.End()
|
||||
|
||||
data, err := q.hotplugDevice(ctx, devInfo, devType, addDevice)
|
||||
if err != nil {
|
||||
@@ -1632,9 +1629,9 @@ func (q *qemu) hotplugAddDevice(ctx context.Context, devInfo interface{}, devTyp
|
||||
}
|
||||
|
||||
func (q *qemu) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "hotplugRemoveDevice", q.tracingTags())
|
||||
defer span.End()
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "hotplugRemoveDevice", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
katatrace.AddTag(span, "device", devInfo)
|
||||
defer span.End()
|
||||
|
||||
data, err := q.hotplugDevice(ctx, devInfo, devType, removeDevice)
|
||||
if err != nil {
|
||||
@@ -1845,14 +1842,14 @@ func (q *qemu) hotplugAddMemory(memDev *memoryDevice) (int, error) {
|
||||
}
|
||||
|
||||
func (q *qemu) pauseSandbox(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "pauseSandbox", q.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "pauseSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
return q.togglePauseSandbox(ctx, true)
|
||||
}
|
||||
|
||||
func (q *qemu) resumeSandbox(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "resumeSandbox", q.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, q.Logger(), "resumeSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
return q.togglePauseSandbox(ctx, false)
|
||||
@@ -1861,9 +1858,9 @@ func (q *qemu) resumeSandbox(ctx context.Context) error {
|
||||
// addDevice will add extra devices to Qemu command line.
|
||||
func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType deviceType) error {
|
||||
var err error
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "addDevice", q.tracingTags())
|
||||
defer span.End()
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "addDevice", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
katatrace.AddTag(span, "device", devInfo)
|
||||
defer span.End()
|
||||
|
||||
switch v := devInfo.(type) {
|
||||
case types.Volume:
|
||||
@@ -1920,7 +1917,7 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic
|
||||
// getSandboxConsole builds the path of the console where we can read
|
||||
// logs coming from the sandbox.
|
||||
func (q *qemu) getSandboxConsole(ctx context.Context, id string) (string, string, error) {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "getSandboxConsole", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "getSandboxConsole", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
consoleURL, err := utils.BuildSocketPath(q.store.RunVMStoragePath(), id, consoleSocket)
|
||||
@@ -1985,7 +1982,7 @@ func (q *qemu) waitMigration() error {
|
||||
}
|
||||
|
||||
func (q *qemu) disconnect(ctx context.Context) {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "disconnect", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "disconnect", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
q.qmpShutdown()
|
||||
@@ -2189,7 +2186,7 @@ func genericAppendPCIeRootPort(devices []govmmQemu.Device, number uint32, machin
|
||||
}
|
||||
|
||||
func (q *qemu) getThreadIDs(ctx context.Context) (vcpuThreadIDs, error) {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "getThreadIDs", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "getThreadIDs", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
tid := vcpuThreadIDs{}
|
||||
@@ -2254,7 +2251,7 @@ func (q *qemu) resizeVCPUs(ctx context.Context, reqVCPUs uint32) (currentVCPUs u
|
||||
}
|
||||
|
||||
func (q *qemu) cleanup(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "cleanup", q.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "cleanup", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
for _, fd := range q.fds {
|
||||
@@ -2280,8 +2277,7 @@ func (q *qemu) getPids() []int {
|
||||
return []int{0}
|
||||
}
|
||||
|
||||
var pids []int
|
||||
pids = append(pids, pid)
|
||||
pids := []int{pid}
|
||||
if q.state.VirtiofsdPid != 0 {
|
||||
pids = append(pids, q.state.VirtiofsdPid)
|
||||
}
|
||||
|
||||
@@ -49,14 +49,11 @@ import (
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
// tracingTags defines tags for the trace span
|
||||
func (s *Sandbox) tracingTags() map[string]string {
|
||||
return map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "sandbox",
|
||||
"sandbox_id": s.id,
|
||||
}
|
||||
// sandboxTracingTags defines tags for the trace span
|
||||
var sandboxTracingTags = map[string]string{
|
||||
"source": "runtime",
|
||||
"package": "virtcontainers",
|
||||
"subsystem": "sandbox",
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -399,9 +396,7 @@ func (s *Sandbox) IOStream(containerID, processID string) (io.WriteCloser, io.Re
|
||||
}
|
||||
|
||||
func createAssets(ctx context.Context, sandboxConfig *SandboxConfig) error {
|
||||
span, _ := katatrace.Trace(ctx, nil, "createAssets", nil)
|
||||
katatrace.AddTag(span, "sandbox_id", sandboxConfig.ID)
|
||||
katatrace.AddTag(span, "subsystem", "sandbox")
|
||||
span, _ := katatrace.Trace(ctx, nil, "createAssets", sandboxTracingTags, map[string]string{"sandbox_id": sandboxConfig.ID})
|
||||
defer span.End()
|
||||
|
||||
for _, name := range types.AssetTypes() {
|
||||
@@ -451,9 +446,7 @@ func (s *Sandbox) getAndStoreGuestDetails(ctx context.Context) error {
|
||||
// to physically create that sandbox i.e. starts a VM for that sandbox to eventually
|
||||
// be started.
|
||||
func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) {
|
||||
span, ctx := katatrace.Trace(ctx, nil, "createSandbox", nil)
|
||||
katatrace.AddTag(span, "sandbox_id", sandboxConfig.ID)
|
||||
katatrace.AddTag(span, "subsystem", "sandbox")
|
||||
span, ctx := katatrace.Trace(ctx, nil, "createSandbox", sandboxTracingTags, map[string]string{"sandbox_id": sandboxConfig.ID})
|
||||
defer span.End()
|
||||
|
||||
if err := createAssets(ctx, &sandboxConfig); err != nil {
|
||||
@@ -491,9 +484,7 @@ func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
|
||||
}
|
||||
|
||||
func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (sb *Sandbox, retErr error) {
|
||||
span, ctx := katatrace.Trace(ctx, nil, "newSandbox", nil)
|
||||
katatrace.AddTag(span, "sandbox_id", sandboxConfig.ID)
|
||||
katatrace.AddTag(span, "subsystem", "sandbox")
|
||||
span, ctx := katatrace.Trace(ctx, nil, "newSandbox", sandboxTracingTags, map[string]string{"sandbox_id": sandboxConfig.ID})
|
||||
defer span.End()
|
||||
|
||||
if !sandboxConfig.valid() {
|
||||
@@ -630,7 +621,7 @@ func (s *Sandbox) createCgroupManager() error {
|
||||
|
||||
// storeSandbox stores a sandbox config.
|
||||
func (s *Sandbox) storeSandbox(ctx context.Context) error {
|
||||
span, _ := katatrace.Trace(ctx, s.Logger(), "storeSandbox", s.tracingTags())
|
||||
span, _ := katatrace.Trace(ctx, s.Logger(), "storeSandbox", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
// flush data to storage
|
||||
@@ -700,7 +691,7 @@ func (s *Sandbox) Delete(ctx context.Context) error {
|
||||
|
||||
for _, c := range s.containers {
|
||||
if err := c.delete(ctx); err != nil {
|
||||
s.Logger().WithError(err).WithField("cid", c.id).Debug("failed to delete container")
|
||||
s.Logger().WithError(err).WithField("container`", c.id).Debug("failed to delete container")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,7 +715,7 @@ func (s *Sandbox) Delete(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (s *Sandbox) startNetworkMonitor(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "startNetworkMonitor", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "startNetworkMonitor", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
binPath, err := os.Executable()
|
||||
@@ -763,7 +754,7 @@ func (s *Sandbox) createNetwork(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "createNetwork", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "createNetwork", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
s.networkNS = NetworkNamespace{
|
||||
@@ -800,7 +791,7 @@ func (s *Sandbox) postCreatedNetwork(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (s *Sandbox) removeNetwork(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "removeNetwork", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "removeNetwork", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
if s.config.NetworkConfig.NetmonConfig.Enable {
|
||||
@@ -1116,7 +1107,7 @@ func (s *Sandbox) cleanSwap(ctx context.Context) {
|
||||
|
||||
// startVM starts the VM.
|
||||
func (s *Sandbox) startVM(ctx context.Context) (err error) {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "startVM", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "startVM", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
s.Logger().Info("Starting VM")
|
||||
@@ -1205,7 +1196,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
|
||||
|
||||
// stopVM: stop the sandbox's VM
|
||||
func (s *Sandbox) stopVM(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "stopVM", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "stopVM", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
s.Logger().Info("Stopping sandbox in the VM")
|
||||
@@ -1264,7 +1255,7 @@ func (s *Sandbox) CreateContainer(ctx context.Context, contConfig ContainerConfi
|
||||
defer func() {
|
||||
// Rollback if error happens.
|
||||
if err != nil {
|
||||
logger := s.Logger().WithFields(logrus.Fields{"container-id": c.id, "sandox-id": s.id, "rollback": true})
|
||||
logger := s.Logger().WithFields(logrus.Fields{"container": c.id, "sandbox": s.id, "rollback": true})
|
||||
logger.WithError(err).Error("Cleaning up partially created container")
|
||||
|
||||
if errStop := c.stop(ctx, true); errStop != nil {
|
||||
@@ -1311,7 +1302,7 @@ func (s *Sandbox) StartContainer(ctx context.Context, containerID string) (VCCon
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.Logger().Info("Container is started")
|
||||
s.Logger().WithField("container", containerID).Info("Container is started")
|
||||
|
||||
// Update sandbox resources in case a stopped container
|
||||
// is started
|
||||
@@ -1558,7 +1549,7 @@ func (s *Sandbox) ResumeContainer(ctx context.Context, containerID string) error
|
||||
// createContainers registers all containers, create the
|
||||
// containers in the guest and starts one shim per container.
|
||||
func (s *Sandbox) createContainers(ctx context.Context) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "createContainers", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "createContainers", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
for i := range s.config.Containers {
|
||||
@@ -1630,7 +1621,7 @@ func (s *Sandbox) Start(ctx context.Context) error {
|
||||
// will be destroyed.
|
||||
// When force is true, ignore guest related stop failures.
|
||||
func (s *Sandbox) Stop(ctx context.Context, force bool) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "Stop", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "Stop", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
if s.state.State == types.StateStopped {
|
||||
@@ -1732,7 +1723,7 @@ func (s *Sandbox) unsetSandboxBlockIndex(index int) error {
|
||||
// HotplugAddDevice is used for add a device to sandbox
|
||||
// Sandbox implement DeviceReceiver interface from device/api/interface.go
|
||||
func (s *Sandbox) HotplugAddDevice(ctx context.Context, device api.Device, devType config.DeviceType) error {
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "HotplugAddDevice", s.tracingTags())
|
||||
span, ctx := katatrace.Trace(ctx, s.Logger(), "HotplugAddDevice", sandboxTracingTags, map[string]string{"sandbox_id": s.id})
|
||||
defer span.End()
|
||||
|
||||
if s.config.SandboxCgroupOnly {
|
||||
@@ -1998,7 +1989,7 @@ func (s *Sandbox) calculateSandboxMemory() (int64, bool, int64) {
|
||||
for _, c := range s.config.Containers {
|
||||
// Do not hot add again non-running containers resources
|
||||
if cont, ok := s.containers[c.ID]; ok && cont.state.State == types.StateStopped {
|
||||
s.Logger().WithField("container-id", c.ID).Debug("Do not taking into account memory resources of not running containers")
|
||||
s.Logger().WithField("container", c.ID).Debug("Do not taking into account memory resources of not running containers")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -2035,7 +2026,7 @@ func (s *Sandbox) calculateSandboxCPUs() (uint32, error) {
|
||||
for _, c := range s.config.Containers {
|
||||
// Do not hot add again non-running containers resources
|
||||
if cont, ok := s.containers[c.ID]; ok && cont.state.State == types.StateStopped {
|
||||
s.Logger().WithField("container-id", c.ID).Debug("Do not taking into account CPU resources of not running containers")
|
||||
s.Logger().WithField("container", c.ID).Debug("Do not taking into account CPU resources of not running containers")
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -384,6 +384,51 @@ func TestToBytes(t *testing.T) {
|
||||
assert.Equal(expected, result)
|
||||
}
|
||||
|
||||
func TestWaitLocalProcess(t *testing.T) {
|
||||
cfg := []struct {
|
||||
command string
|
||||
args []string
|
||||
timeout uint
|
||||
signal syscall.Signal
|
||||
}{
|
||||
{
|
||||
"true",
|
||||
[]string{},
|
||||
waitLocalProcessTimeoutSecs,
|
||||
syscall.SIGKILL,
|
||||
},
|
||||
{
|
||||
"sleep",
|
||||
[]string{"999"},
|
||||
waitLocalProcessTimeoutSecs,
|
||||
syscall.SIGKILL,
|
||||
},
|
||||
{
|
||||
"sleep",
|
||||
[]string{"999"},
|
||||
1,
|
||||
syscall.SIGKILL,
|
||||
},
|
||||
}
|
||||
|
||||
logger := logrus.WithField("foo", "bar")
|
||||
|
||||
for _, opts := range cfg {
|
||||
assert := assert.New(t)
|
||||
|
||||
cmd := exec.Command(opts.command, opts.args...)
|
||||
err := cmd.Start()
|
||||
assert.NoError(err)
|
||||
|
||||
pid := cmd.Process.Pid
|
||||
|
||||
err = WaitLocalProcess(pid, opts.timeout, opts.signal, logger)
|
||||
assert.NoError(err)
|
||||
|
||||
_ = cmd.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitLocalProcessInvalidSignal(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
@@ -424,58 +469,3 @@ func TestWaitLocalProcessInvalidPid(t *testing.T) {
|
||||
assert.Error(err, msg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitLocalProcessBrief(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cmd := exec.Command("true")
|
||||
err := cmd.Start()
|
||||
assert.NoError(err)
|
||||
|
||||
pid := cmd.Process.Pid
|
||||
|
||||
logger := logrus.WithField("foo", "bar")
|
||||
|
||||
err = WaitLocalProcess(pid, waitLocalProcessTimeoutSecs, syscall.SIGKILL, logger)
|
||||
assert.NoError(err)
|
||||
|
||||
_ = cmd.Wait()
|
||||
}
|
||||
|
||||
func TestWaitLocalProcessLongRunningPreKill(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cmd := exec.Command("sleep", "999")
|
||||
err := cmd.Start()
|
||||
assert.NoError(err)
|
||||
|
||||
pid := cmd.Process.Pid
|
||||
|
||||
logger := logrus.WithField("foo", "bar")
|
||||
|
||||
err = WaitLocalProcess(pid, waitLocalProcessTimeoutSecs, syscall.SIGKILL, logger)
|
||||
assert.NoError(err)
|
||||
|
||||
_ = cmd.Wait()
|
||||
}
|
||||
|
||||
func TestWaitLocalProcessLongRunning(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cmd := exec.Command("sleep", "999")
|
||||
err := cmd.Start()
|
||||
assert.NoError(err)
|
||||
|
||||
pid := cmd.Process.Pid
|
||||
|
||||
logger := logrus.WithField("foo", "bar")
|
||||
|
||||
// Don't wait for long as the process isn't actually trying to stop,
|
||||
// so it will have to timeout and then be killed.
|
||||
const timeoutSecs = 1
|
||||
|
||||
err = WaitLocalProcess(pid, timeoutSecs, syscall.Signal(0), logger)
|
||||
assert.NoError(err)
|
||||
|
||||
_ = cmd.Wait()
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ ROOTFS_BUILDER := $(MK_DIR)/rootfs-builder/rootfs.sh
|
||||
INITRD_BUILDER := $(MK_DIR)/initrd-builder/initrd_builder.sh
|
||||
IMAGE_BUILDER := $(MK_DIR)/image-builder/image_builder.sh
|
||||
|
||||
DISTRO := centos
|
||||
DISTRO ?= centos
|
||||
BUILD_METHOD := distro
|
||||
BUILD_METHOD_LIST := distro dracut
|
||||
AGENT_INIT ?= no
|
||||
|
||||
@@ -326,7 +326,11 @@ build_rootfs_distro()
|
||||
trap error_handler ERR
|
||||
fi
|
||||
|
||||
mkdir -p ${ROOTFS_DIR}
|
||||
if [ -d "${ROOTFS_DIR}" ] && [ "${ROOTFS_DIR}" != "/" ]; then
|
||||
rm -rf "${ROOTFS_DIR}"/*
|
||||
else
|
||||
mkdir -p ${ROOTFS_DIR}
|
||||
fi
|
||||
|
||||
# need to detect rustc's version too?
|
||||
detect_rust_version ||
|
||||
@@ -369,6 +373,8 @@ build_rootfs_distro()
|
||||
|
||||
docker_run_args=""
|
||||
docker_run_args+=" --rm"
|
||||
# apt sync scans all possible fds in order to close them, incredibly slow on VMs
|
||||
docker_run_args+=" --ulimit nofile=262144:262144"
|
||||
docker_run_args+=" --runtime ${DOCKER_RUNTIME}"
|
||||
|
||||
if [ -z "${AGENT_SOURCE_BIN}" ] ; then
|
||||
|
||||
@@ -18,7 +18,7 @@ spec:
|
||||
katacontainers.io/kata-runtime: cleanup
|
||||
containers:
|
||||
- name: kube-kata-cleanup
|
||||
image: quay.io/kata-containers/kata-deploy:2.2.0
|
||||
image: quay.io/kata-containers/kata-deploy:2.3.0-alpha0
|
||||
imagePullPolicy: Always
|
||||
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
|
||||
env:
|
||||
|
||||
@@ -16,7 +16,7 @@ spec:
|
||||
serviceAccountName: kata-label-node
|
||||
containers:
|
||||
- name: kube-kata
|
||||
image: quay.io/kata-containers/kata-deploy:2.2.0
|
||||
image: quay.io/kata-containers/kata-deploy:2.3.0-alpha0
|
||||
imagePullPolicy: Always
|
||||
lifecycle:
|
||||
preStop:
|
||||
|
||||
Reference in New Issue
Block a user