runtime: Fix ordering of trace spans

A significant number of trace calls did not use a parent context that
would create proper span ordering in trace output. Add local context to
functions for use in trace calls to facilitate proper span ordering.
Additionally, change whether trace function returns context in some
functions in virtcontainers and use existing context rather than
background context in bindMount() so that span exists as a child of a
parent span.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
Chelsea Mafrica
2021-02-09 16:30:50 -08:00
parent 50f317dcff
commit 6b0dc60dda
67 changed files with 1103 additions and 1056 deletions

View File

@@ -6,6 +6,7 @@
package virtcontainers
import (
"context"
"encoding/hex"
"fmt"
"os"
@@ -75,7 +76,7 @@ func (endpoint *VhostUserEndpoint) NetworkPair() *NetworkInterfacePair {
}
// Attach for vhostuser endpoint
func (endpoint *VhostUserEndpoint) Attach(s *Sandbox) error {
func (endpoint *VhostUserEndpoint) Attach(ctx context.Context, s *Sandbox) error {
// Generate a unique ID to be used for hypervisor commandline fields
randBytes, err := utils.GenerateRandomBytes(8)
if err != nil {
@@ -90,21 +91,21 @@ func (endpoint *VhostUserEndpoint) Attach(s *Sandbox) error {
Type: config.VhostUserNet,
}
return s.hypervisor.addDevice(d, vhostuserDev)
return s.hypervisor.addDevice(ctx, d, vhostuserDev)
}
// Detach for vhostuser endpoint
func (endpoint *VhostUserEndpoint) Detach(netNsCreated bool, netNsPath string) error {
func (endpoint *VhostUserEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
return nil
}
// HotAttach for vhostuser endpoint not supported yet
func (endpoint *VhostUserEndpoint) HotAttach(h hypervisor) error {
func (endpoint *VhostUserEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
return fmt.Errorf("VhostUserEndpoint does not support Hot attach")
}
// HotDetach for vhostuser endpoint not supported yet
func (endpoint *VhostUserEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error {
func (endpoint *VhostUserEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
return fmt.Errorf("VhostUserEndpoint does not support Hot detach")
}