runtime: Fix trace span ordering

Return ctx in trace() functions to correct span ordering.

Fixes #1550

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
Chelsea Mafrica 2021-03-25 10:42:25 -07:00
parent 5b5b5cc611
commit f3ebbb1f1a
10 changed files with 52 additions and 52 deletions

View File

@ -301,7 +301,7 @@ func trace(ctx context.Context, name string) (otelTrace.Span, context.Context) {
} }
func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err error) { func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err error) {
span, _ := trace(s.rootCtx, "Cleanup") span, spanCtx := trace(s.rootCtx, "Cleanup")
defer span.End() defer span.End()
//Since the binary cleanup will return the DeleteResponse from stdout to //Since the binary cleanup will return the DeleteResponse from stdout to
@ -335,7 +335,7 @@ func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err e
switch containerType { switch containerType {
case vc.PodSandbox: case vc.PodSandbox:
err = cleanupContainer(ctx, s.id, s.id, path) err = cleanupContainer(spanCtx, s.id, s.id, path)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -345,7 +345,7 @@ func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err e
return nil, err return nil, err
} }
err = cleanupContainer(ctx, sandboxID, s.id, path) err = cleanupContainer(spanCtx, sandboxID, s.id, path)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -416,7 +416,7 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
// Start a process // Start a process
func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAPI.StartResponse, err error) { func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAPI.StartResponse, err error) {
span, _ := trace(s.rootCtx, "Start") span, spanCtx := trace(s.rootCtx, "Start")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -439,7 +439,7 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAP
//start a container //start a container
if r.ExecID == "" { if r.ExecID == "" {
err = startContainer(ctx, s, c) err = startContainer(spanCtx, s, c)
if err != nil { if err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
@ -449,7 +449,7 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAP
}) })
} else { } else {
//start an exec //start an exec
_, err = startExec(ctx, s, r.ID, r.ExecID) _, err = startExec(spanCtx, s, r.ID, r.ExecID)
if err != nil { if err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
@ -467,7 +467,7 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (_ *taskAP
// Delete the initial process and container // Delete the initial process and container
func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *taskAPI.DeleteResponse, err error) { func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *taskAPI.DeleteResponse, err error) {
span, _ := trace(s.rootCtx, "Delete") span, spanCtx := trace(s.rootCtx, "Delete")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -485,7 +485,7 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *task
} }
if r.ExecID == "" { if r.ExecID == "" {
if err = deleteContainer(ctx, s, c); err != nil { if err = deleteContainer(spanCtx, s, c); err != nil {
return nil, err return nil, err
} }
@ -557,7 +557,7 @@ func (s *service) Exec(ctx context.Context, r *taskAPI.ExecProcessRequest) (_ *p
// ResizePty of a process // ResizePty of a process
func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (_ *ptypes.Empty, err error) { func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (_ *ptypes.Empty, err error) {
span, _ := trace(s.rootCtx, "ResizePty") span, spanCtx := trace(s.rootCtx, "ResizePty")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -586,7 +586,7 @@ func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (_
processID = execs.id processID = execs.id
} }
err = s.sandbox.WinsizeProcess(ctx, c.id, processID, r.Height, r.Width) err = s.sandbox.WinsizeProcess(spanCtx, c.id, processID, r.Height, r.Width)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -648,7 +648,7 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (_ *taskAP
// Pause the container // Pause the container
func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes.Empty, err error) { func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes.Empty, err error) {
span, _ := trace(s.rootCtx, "Pause") span, spanCtx := trace(s.rootCtx, "Pause")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -667,7 +667,7 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes
c.status = task.StatusPausing c.status = task.StatusPausing
err = s.sandbox.PauseContainer(ctx, r.ID) err = s.sandbox.PauseContainer(spanCtx, r.ID)
if err == nil { if err == nil {
c.status = task.StatusPaused c.status = task.StatusPaused
s.send(&eventstypes.TaskPaused{ s.send(&eventstypes.TaskPaused{
@ -687,7 +687,7 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes
// Resume the container // Resume the container
func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptypes.Empty, err error) { func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptypes.Empty, err error) {
span, _ := trace(s.rootCtx, "Resume") span, spanCtx := trace(s.rootCtx, "Resume")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -704,7 +704,7 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptyp
return nil, err return nil, err
} }
err = s.sandbox.ResumeContainer(ctx, c.id) err = s.sandbox.ResumeContainer(spanCtx, c.id)
if err == nil { if err == nil {
c.status = task.StatusRunning c.status = task.StatusRunning
s.send(&eventstypes.TaskResumed{ s.send(&eventstypes.TaskResumed{
@ -724,7 +724,7 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptyp
// Kill a process with the provided signal // Kill a process with the provided signal
func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.Empty, err error) { func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.Empty, err error) {
span, _ := trace(s.rootCtx, "Kill") span, spanCtx := trace(s.rootCtx, "Kill")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -778,7 +778,7 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.E
return empty, nil return empty, nil
} }
return empty, s.sandbox.SignalProcess(ctx, c.id, processID, signum, r.All) return empty, s.sandbox.SignalProcess(spanCtx, c.id, processID, signum, r.All)
} }
// Pids returns all pids inside the container // Pids returns all pids inside the container
@ -911,7 +911,7 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *
} }
func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAPI.StatsResponse, err error) { func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAPI.StatsResponse, err error) {
span, _ := trace(s.rootCtx, "Stats") span, spanCtx := trace(s.rootCtx, "Stats")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -928,7 +928,7 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAP
return nil, err return nil, err
} }
data, err := marshalMetrics(ctx, s, c.id) data, err := marshalMetrics(spanCtx, s, c.id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -940,7 +940,7 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (_ *taskAP
// Update a running container // Update a running container
func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (_ *ptypes.Empty, err error) { func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (_ *ptypes.Empty, err error) {
span, _ := trace(s.rootCtx, "Update") span, spanCtx := trace(s.rootCtx, "Update")
defer span.End() defer span.End()
start := time.Now() start := time.Now()
@ -962,7 +962,7 @@ func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (_ *
return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, "Invalid resources type for %s", s.id) return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, "Invalid resources type for %s", s.id)
} }
err = s.sandbox.UpdateContainer(ctx, r.ID, *resources) err = s.sandbox.UpdateContainer(spanCtx, r.ID, *resources)
if err != nil { if err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }

View File

@ -420,7 +420,7 @@ func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNa
// startSandbox will start the Sandbox's VM. // startSandbox will start the Sandbox's VM.
func (a *Acrn) startSandbox(ctx context.Context, timeoutSecs int) error { func (a *Acrn) startSandbox(ctx context.Context, timeoutSecs int) error {
span, _ := a.trace(ctx, "startSandbox") span, ctx := a.trace(ctx, "startSandbox")
defer span.End() defer span.End()
if a.config.Debug { if a.config.Debug {

View File

@ -53,7 +53,7 @@ func SetLogger(ctx context.Context, logger *logrus.Entry) {
// CreateSandbox is the virtcontainers sandbox creation entry point. // CreateSandbox is the virtcontainers sandbox creation entry point.
// CreateSandbox creates a sandbox and its containers. It does not start them. // CreateSandbox creates a sandbox and its containers. It does not start them.
func CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (VCSandbox, error) { func CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (VCSandbox, error) {
span, _ := trace(ctx, "CreateSandbox") span, ctx := trace(ctx, "CreateSandbox")
defer span.End() defer span.End()
s, err := createSandboxFromConfig(ctx, sandboxConfig, factory) s, err := createSandboxFromConfig(ctx, sandboxConfig, factory)
@ -62,7 +62,7 @@ func CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
} }
func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (_ *Sandbox, err error) { func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (_ *Sandbox, err error) {
span, _ := trace(ctx, "createSandboxFromConfig") span, ctx := trace(ctx, "createSandboxFromConfig")
defer span.End() defer span.End()
// Create the sandbox. // Create the sandbox.
@ -136,7 +136,7 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
// in the sandbox left, do stop the sandbox and delete it. Those serial operations will be done exclusively by // in the sandbox left, do stop the sandbox and delete it. Those serial operations will be done exclusively by
// locking the sandbox. // locking the sandbox.
func CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error { func CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error {
span, _ := trace(ctx, "CleanupContainer") span, ctx := trace(ctx, "CleanupContainer")
defer span.End() defer span.End()
if sandboxID == "" { if sandboxID == "" {

View File

@ -700,7 +700,7 @@ func (c *Container) createBlockDevices(ctx context.Context) error {
// newContainer creates a Container structure from a sandbox and a container configuration. // newContainer creates a Container structure from a sandbox and a container configuration.
func newContainer(ctx context.Context, sandbox *Sandbox, contConfig *ContainerConfig) (*Container, error) { func newContainer(ctx context.Context, sandbox *Sandbox, contConfig *ContainerConfig) (*Container, error) {
span, _ := sandbox.trace(ctx, "newContainer") span, ctx := sandbox.trace(ctx, "newContainer")
defer span.End() defer span.End()
if !contConfig.valid() { if !contConfig.valid() {

View File

@ -141,7 +141,7 @@ func (f *factory) checkConfig(config vc.VMConfig) error {
// GetVM returns a working blank VM created by the factory. // GetVM returns a working blank VM created by the factory.
func (f *factory) GetVM(ctx context.Context, config vc.VMConfig) (*vc.VM, error) { func (f *factory) GetVM(ctx context.Context, config vc.VMConfig) (*vc.VM, error) {
span, _ := trace(ctx, "GetVM") span, ctx := trace(ctx, "GetVM")
defer span.End() defer span.End()
hypervisorConfig := config.HypervisorConfig hypervisorConfig := config.HypervisorConfig

View File

@ -495,7 +495,7 @@ func (k *kataAgent) setupSharedPath(ctx context.Context, sandbox *Sandbox) error
} }
func (k *kataAgent) createSandbox(ctx context.Context, sandbox *Sandbox) error { func (k *kataAgent) createSandbox(ctx context.Context, sandbox *Sandbox) error {
span, _ := k.trace(ctx, "createSandbox") span, ctx := k.trace(ctx, "createSandbox")
defer span.End() defer span.End()
if err := k.setupSharedPath(ctx, sandbox); err != nil { if err := k.setupSharedPath(ctx, sandbox); err != nil {
@ -582,7 +582,7 @@ func cmdEnvsToStringSlice(ev []types.EnvVar) []string {
} }
func (k *kataAgent) exec(ctx context.Context, sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) { func (k *kataAgent) exec(ctx context.Context, sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
span, _ := k.trace(ctx, "exec") span, ctx := k.trace(ctx, "exec")
defer span.End() defer span.End()
var kataProcess *grpc.Process var kataProcess *grpc.Process
@ -754,7 +754,7 @@ func (k *kataAgent) getDNS(sandbox *Sandbox) ([]string, error) {
} }
func (k *kataAgent) startSandbox(ctx context.Context, sandbox *Sandbox) error { func (k *kataAgent) startSandbox(ctx context.Context, sandbox *Sandbox) error {
span, _ := k.trace(ctx, "startSandbox") span, ctx := k.trace(ctx, "startSandbox")
defer span.End() defer span.End()
if err := k.setAgentURL(); err != nil { if err := k.setAgentURL(); err != nil {
@ -909,7 +909,7 @@ func setupStorages(ctx context.Context, sandbox *Sandbox) []*grpc.Storage {
} }
func (k *kataAgent) stopSandbox(ctx context.Context, sandbox *Sandbox) error { func (k *kataAgent) stopSandbox(ctx context.Context, sandbox *Sandbox) error {
span, _ := k.trace(ctx, "stopSandbox") span, ctx := k.trace(ctx, "stopSandbox")
defer span.End() defer span.End()
req := &grpc.DestroySandboxRequest{} req := &grpc.DestroySandboxRequest{}
@ -1271,7 +1271,7 @@ func (k *kataAgent) buildContainerRootfs(ctx context.Context, sandbox *Sandbox,
} }
func (k *kataAgent) createContainer(ctx context.Context, sandbox *Sandbox, c *Container) (p *Process, err error) { func (k *kataAgent) createContainer(ctx context.Context, sandbox *Sandbox, c *Container) (p *Process, err error) {
span, _ := k.trace(ctx, "createContainer") span, ctx := k.trace(ctx, "createContainer")
defer span.End() defer span.End()
var ctrStorages []*grpc.Storage var ctrStorages []*grpc.Storage
@ -1593,7 +1593,7 @@ func (k *kataAgent) handlePidNamespace(grpcSpec *grpc.Spec, sandbox *Sandbox) bo
} }
func (k *kataAgent) startContainer(ctx context.Context, sandbox *Sandbox, c *Container) error { func (k *kataAgent) startContainer(ctx context.Context, sandbox *Sandbox, c *Container) error {
span, _ := k.trace(ctx, "startContainer") span, ctx := k.trace(ctx, "startContainer")
defer span.End() defer span.End()
req := &grpc.StartContainerRequest{ req := &grpc.StartContainerRequest{
@ -1605,7 +1605,7 @@ func (k *kataAgent) startContainer(ctx context.Context, sandbox *Sandbox, c *Con
} }
func (k *kataAgent) stopContainer(ctx context.Context, sandbox *Sandbox, c Container) error { func (k *kataAgent) stopContainer(ctx context.Context, sandbox *Sandbox, c Container) error {
span, _ := k.trace(ctx, "stopContainer") span, ctx := k.trace(ctx, "stopContainer")
defer span.End() defer span.End()
_, err := k.sendReq(ctx, &grpc.RemoveContainerRequest{ContainerId: c.id}) _, err := k.sendReq(ctx, &grpc.RemoveContainerRequest{ContainerId: c.id})
@ -1815,7 +1815,7 @@ func (k *kataAgent) disconnect(ctx context.Context) error {
// check grpc server is serving // check grpc server is serving
func (k *kataAgent) check(ctx context.Context) error { func (k *kataAgent) check(ctx context.Context) error {
span, _ := k.trace(ctx, "check") span, ctx := k.trace(ctx, "check")
defer span.End() defer span.End()
_, err := k.sendReq(ctx, &grpc.CheckRequest{}) _, err := k.sendReq(ctx, &grpc.CheckRequest{})
@ -1826,7 +1826,7 @@ func (k *kataAgent) check(ctx context.Context) error {
} }
func (k *kataAgent) waitProcess(ctx context.Context, c *Container, processID string) (int32, error) { func (k *kataAgent) waitProcess(ctx context.Context, c *Container, processID string) (int32, error) {
span, _ := k.trace(ctx, "waitProcess") span, ctx := k.trace(ctx, "waitProcess")
defer span.End() defer span.End()
resp, err := k.sendReq(ctx, &grpc.WaitProcessRequest{ resp, err := k.sendReq(ctx, &grpc.WaitProcessRequest{

View File

@ -347,7 +347,7 @@ func bindUnmountContainerRootfs(ctx context.Context, sharedDir, cID string) erro
} }
func bindUnmountAllRootfs(ctx context.Context, sharedDir string, sandbox *Sandbox) error { func bindUnmountAllRootfs(ctx context.Context, sharedDir string, sandbox *Sandbox) error {
span, _ := trace(ctx, "bindUnmountAllRootfs") span, ctx := trace(ctx, "bindUnmountAllRootfs")
defer span.End() defer span.End()
var errors *merr.Error var errors *merr.Error

View File

@ -1273,7 +1273,7 @@ func (n *Network) Run(ctx context.Context, networkNSPath string, cb func() error
// Add adds all needed interfaces inside the network namespace. // Add adds all needed interfaces inside the network namespace.
func (n *Network) Add(ctx context.Context, config *NetworkConfig, s *Sandbox, hotplug bool) ([]Endpoint, error) { func (n *Network) Add(ctx context.Context, config *NetworkConfig, s *Sandbox, hotplug bool) ([]Endpoint, error) {
span, _ := n.trace(ctx, "Add") span, ctx := n.trace(ctx, "Add")
defer span.End() defer span.End()
endpoints, err := createEndpointsFromScan(config.NetNSPath, config) endpoints, err := createEndpointsFromScan(config.NetNSPath, config)
@ -1354,7 +1354,7 @@ func (n *Network) PostAdd(ctx context.Context, ns *NetworkNamespace, hotplug boo
// Remove network endpoints in the network namespace. It also deletes the network // Remove network endpoints in the network namespace. It also deletes the network
// namespace in case the namespace has been created by us. // namespace in case the namespace has been created by us.
func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor) error { func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor) error {
span, _ := n.trace(ctx, "Remove") span, ctx := n.trace(ctx, "Remove")
defer span.End() defer span.End()
for _, endpoint := range ns.Endpoints { for _, endpoint := range ns.Endpoints {

View File

@ -468,7 +468,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
// Save the tracing context // Save the tracing context
q.ctx = ctx q.ctx = ctx
span, _ := q.trace(ctx, "createSandbox") span, ctx := q.trace(ctx, "createSandbox")
defer span.End() defer span.End()
if err := q.setup(ctx, id, hypervisorConfig); err != nil { if err := q.setup(ctx, id, hypervisorConfig); err != nil {
@ -772,7 +772,7 @@ func (q *qemu) setupVirtioMem() error {
// startSandbox will start the Sandbox's VM. // startSandbox will start the Sandbox's VM.
func (q *qemu) startSandbox(ctx context.Context, timeout int) error { func (q *qemu) startSandbox(ctx context.Context, timeout int) error {
span, _ := q.trace(ctx, "startSandbox") span, ctx := q.trace(ctx, "startSandbox")
defer span.End() defer span.End()
if q.config.Debug { if q.config.Debug {
@ -1609,7 +1609,7 @@ func (q *qemu) hotplugDevice(ctx context.Context, devInfo interface{}, devType d
} }
func (q *qemu) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) { func (q *qemu) hotplugAddDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
span, _ := q.trace(ctx, "hotplugAddDevice") span, ctx := q.trace(ctx, "hotplugAddDevice")
defer span.End() defer span.End()
data, err := q.hotplugDevice(ctx, devInfo, devType, addDevice) data, err := q.hotplugDevice(ctx, devInfo, devType, addDevice)
@ -1621,7 +1621,7 @@ func (q *qemu) hotplugAddDevice(ctx context.Context, devInfo interface{}, devTyp
} }
func (q *qemu) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) { func (q *qemu) hotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType deviceType) (interface{}, error) {
span, _ := q.trace(ctx, "hotplugRemoveDevice") span, ctx := q.trace(ctx, "hotplugRemoveDevice")
defer span.End() defer span.End()
data, err := q.hotplugDevice(ctx, devInfo, devType, removeDevice) data, err := q.hotplugDevice(ctx, devInfo, devType, removeDevice)
@ -1833,14 +1833,14 @@ func (q *qemu) hotplugAddMemory(memDev *memoryDevice) (int, error) {
} }
func (q *qemu) pauseSandbox(ctx context.Context) error { func (q *qemu) pauseSandbox(ctx context.Context) error {
span, _ := q.trace(ctx, "pauseSandbox") span, ctx := q.trace(ctx, "pauseSandbox")
defer span.End() defer span.End()
return q.togglePauseSandbox(ctx, true) return q.togglePauseSandbox(ctx, true)
} }
func (q *qemu) resumeSandbox(ctx context.Context) error { func (q *qemu) resumeSandbox(ctx context.Context) error {
span, _ := q.trace(ctx, "resumeSandbox") span, ctx := q.trace(ctx, "resumeSandbox")
defer span.End() defer span.End()
return q.togglePauseSandbox(ctx, false) return q.togglePauseSandbox(ctx, false)

View File

@ -445,7 +445,7 @@ func (s *Sandbox) getAndStoreGuestDetails(ctx context.Context) error {
// to physically create that sandbox i.e. starts a VM for that sandbox to eventually // to physically create that sandbox i.e. starts a VM for that sandbox to eventually
// be started. // be started.
func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) { func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) {
span, _ := trace(ctx, "createSandbox") span, ctx := trace(ctx, "createSandbox")
defer span.End() defer span.End()
if err := createAssets(ctx, &sandboxConfig); err != nil { if err := createAssets(ctx, &sandboxConfig); err != nil {
@ -483,7 +483,7 @@ func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
} }
func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (sb *Sandbox, retErr error) { func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (sb *Sandbox, retErr error) {
span, _ := trace(ctx, "newSandbox") span, ctx := trace(ctx, "newSandbox")
defer span.End() defer span.End()
if !sandboxConfig.valid() { if !sandboxConfig.valid() {
@ -752,7 +752,7 @@ func (s *Sandbox) createNetwork(ctx context.Context) error {
return nil return nil
} }
span, _ := s.trace(ctx, "createNetwork") span, ctx := s.trace(ctx, "createNetwork")
defer span.End() defer span.End()
s.networkNS = NetworkNamespace{ s.networkNS = NetworkNamespace{
@ -994,7 +994,7 @@ func (cw *consoleWatcher) stop() {
// startVM starts the VM. // startVM starts the VM.
func (s *Sandbox) startVM(ctx context.Context) (err error) { func (s *Sandbox) startVM(ctx context.Context) (err error) {
span, _ := s.trace(ctx, "startVM") span, ctx := s.trace(ctx, "startVM")
defer span.End() defer span.End()
s.Logger().Info("Starting VM") s.Logger().Info("Starting VM")
@ -1075,7 +1075,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
// stopVM: stop the sandbox's VM // stopVM: stop the sandbox's VM
func (s *Sandbox) stopVM(ctx context.Context) error { func (s *Sandbox) stopVM(ctx context.Context) error {
span, _ := s.trace(ctx, "stopVM") span, ctx := s.trace(ctx, "stopVM")
defer span.End() defer span.End()
s.Logger().Info("Stopping sandbox in the VM") s.Logger().Info("Stopping sandbox in the VM")
@ -1451,7 +1451,7 @@ func (s *Sandbox) ResumeContainer(ctx context.Context, containerID string) error
// createContainers registers all containers, create the // createContainers registers all containers, create the
// containers in the guest and starts one shim per container. // containers in the guest and starts one shim per container.
func (s *Sandbox) createContainers(ctx context.Context) error { func (s *Sandbox) createContainers(ctx context.Context) error {
span, _ := s.trace(ctx, "createContainers") span, ctx := s.trace(ctx, "createContainers")
defer span.End() defer span.End()
for _, contConfig := range s.config.Containers { for _, contConfig := range s.config.Containers {
@ -1523,7 +1523,7 @@ func (s *Sandbox) Start(ctx context.Context) error {
// will be destroyed. // will be destroyed.
// When force is true, ignore guest related stop failures. // When force is true, ignore guest related stop failures.
func (s *Sandbox) Stop(ctx context.Context, force bool) error { func (s *Sandbox) Stop(ctx context.Context, force bool) error {
span, _ := s.trace(ctx, "Stop") span, ctx := s.trace(ctx, "Stop")
defer span.End() defer span.End()
if s.state.State == types.StateStopped { if s.state.State == types.StateStopped {
@ -1634,7 +1634,7 @@ func (s *Sandbox) unsetSandboxBlockIndex(index int) error {
// HotplugAddDevice is used for add a device to sandbox // HotplugAddDevice is used for add a device to sandbox
// Sandbox implement DeviceReceiver interface from device/api/interface.go // Sandbox implement DeviceReceiver interface from device/api/interface.go
func (s *Sandbox) HotplugAddDevice(ctx context.Context, device api.Device, devType config.DeviceType) error { func (s *Sandbox) HotplugAddDevice(ctx context.Context, device api.Device, devType config.DeviceType) error {
span, _ := s.trace(ctx, "HotplugAddDevice") span, ctx := s.trace(ctx, "HotplugAddDevice")
defer span.End() defer span.End()
if s.config.SandboxCgroupOnly { if s.config.SandboxCgroupOnly {