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

@@ -36,7 +36,7 @@ func (n *mockAgent) longLiveConn() bool {
}
// createSandbox is the Noop agent sandbox creation implementation. It does nothing.
func (n *mockAgent) createSandbox(sandbox *Sandbox) error {
func (n *mockAgent) createSandbox(ctx context.Context, sandbox *Sandbox) error {
return nil
}
@@ -46,137 +46,137 @@ func (n *mockAgent) capabilities() types.Capabilities {
}
// disconnect is the Noop agent connection closer. It does nothing.
func (n *mockAgent) disconnect() error {
func (n *mockAgent) disconnect(ctx context.Context) error {
return nil
}
// exec is the Noop agent command execution implementation. It does nothing.
func (n *mockAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
func (n *mockAgent) exec(ctx context.Context, sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
return nil, nil
}
// startSandbox is the Noop agent Sandbox starting implementation. It does nothing.
func (n *mockAgent) startSandbox(sandbox *Sandbox) error {
func (n *mockAgent) startSandbox(ctx context.Context, sandbox *Sandbox) error {
return nil
}
// stopSandbox is the Noop agent Sandbox stopping implementation. It does nothing.
func (n *mockAgent) stopSandbox(sandbox *Sandbox) error {
func (n *mockAgent) stopSandbox(ctx context.Context, sandbox *Sandbox) error {
return nil
}
// createContainer is the Noop agent Container creation implementation. It does nothing.
func (n *mockAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
func (n *mockAgent) createContainer(ctx context.Context, sandbox *Sandbox, c *Container) (*Process, error) {
return &Process{}, nil
}
// startContainer is the Noop agent Container starting implementation. It does nothing.
func (n *mockAgent) startContainer(sandbox *Sandbox, c *Container) error {
func (n *mockAgent) startContainer(ctx context.Context, sandbox *Sandbox, c *Container) error {
return nil
}
// stopContainer is the Noop agent Container stopping implementation. It does nothing.
func (n *mockAgent) stopContainer(sandbox *Sandbox, c Container) error {
func (n *mockAgent) stopContainer(ctx context.Context, sandbox *Sandbox, c Container) error {
return nil
}
// signalProcess is the Noop agent Container signaling implementation. It does nothing.
func (n *mockAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
func (n *mockAgent) signalProcess(ctx context.Context, c *Container, processID string, signal syscall.Signal, all bool) error {
return nil
}
// processListContainer is the Noop agent Container ps implementation. It does nothing.
func (n *mockAgent) processListContainer(sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
func (n *mockAgent) processListContainer(ctx context.Context, sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
return nil, nil
}
// updateContainer is the Noop agent Container update implementation. It does nothing.
func (n *mockAgent) updateContainer(sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
func (n *mockAgent) updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
return nil
}
// memHotplugByProbe is the Noop agent notify meomory hotplug event via probe interface implementation. It does nothing.
func (n *mockAgent) memHotplugByProbe(addr uint64, sizeMB uint32, memorySectionSizeMB uint32) error {
func (n *mockAgent) memHotplugByProbe(ctx context.Context, addr uint64, sizeMB uint32, memorySectionSizeMB uint32) error {
return nil
}
// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
func (n *mockAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
func (n *mockAgent) onlineCPUMem(ctx context.Context, cpus uint32, cpuOnly bool) error {
return nil
}
// updateInterface is the Noop agent Interface update implementation. It does nothing.
func (n *mockAgent) updateInterface(inf *pbTypes.Interface) (*pbTypes.Interface, error) {
func (n *mockAgent) updateInterface(ctx context.Context, inf *pbTypes.Interface) (*pbTypes.Interface, error) {
return nil, nil
}
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
func (n *mockAgent) listInterfaces() ([]*pbTypes.Interface, error) {
func (n *mockAgent) listInterfaces(ctx context.Context) ([]*pbTypes.Interface, error) {
return nil, nil
}
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
func (n *mockAgent) updateRoutes(routes []*pbTypes.Route) ([]*pbTypes.Route, error) {
func (n *mockAgent) updateRoutes(ctx context.Context, routes []*pbTypes.Route) ([]*pbTypes.Route, error) {
return nil, nil
}
// listRoutes is the Noop agent Routes list implementation. It does nothing.
func (n *mockAgent) listRoutes() ([]*pbTypes.Route, error) {
func (n *mockAgent) listRoutes(ctx context.Context) ([]*pbTypes.Route, error) {
return nil, nil
}
// check is the Noop agent health checker. It does nothing.
func (n *mockAgent) check() error {
func (n *mockAgent) check(ctx context.Context) error {
return nil
}
// statsContainer is the Noop agent Container stats implementation. It does nothing.
func (n *mockAgent) statsContainer(sandbox *Sandbox, c Container) (*ContainerStats, error) {
func (n *mockAgent) statsContainer(ctx context.Context, sandbox *Sandbox, c Container) (*ContainerStats, error) {
return &ContainerStats{}, nil
}
// waitProcess is the Noop agent process waiter. It does nothing.
func (n *mockAgent) waitProcess(c *Container, processID string) (int32, error) {
func (n *mockAgent) waitProcess(ctx context.Context, c *Container, processID string) (int32, error) {
return 0, nil
}
// winsizeProcess is the Noop agent process tty resizer. It does nothing.
func (n *mockAgent) winsizeProcess(c *Container, processID string, height, width uint32) error {
func (n *mockAgent) winsizeProcess(ctx context.Context, c *Container, processID string, height, width uint32) error {
return nil
}
// writeProcessStdin is the Noop agent process stdin writer. It does nothing.
func (n *mockAgent) writeProcessStdin(c *Container, ProcessID string, data []byte) (int, error) {
func (n *mockAgent) writeProcessStdin(ctx context.Context, c *Container, ProcessID string, data []byte) (int, error) {
return 0, nil
}
// closeProcessStdin is the Noop agent process stdin closer. It does nothing.
func (n *mockAgent) closeProcessStdin(c *Container, ProcessID string) error {
func (n *mockAgent) closeProcessStdin(ctx context.Context, c *Container, ProcessID string) error {
return nil
}
// readProcessStdout is the Noop agent process stdout reader. It does nothing.
func (n *mockAgent) readProcessStdout(c *Container, processID string, data []byte) (int, error) {
func (n *mockAgent) readProcessStdout(ctx context.Context, c *Container, processID string, data []byte) (int, error) {
return 0, nil
}
// readProcessStderr is the Noop agent process stderr reader. It does nothing.
func (n *mockAgent) readProcessStderr(c *Container, processID string, data []byte) (int, error) {
func (n *mockAgent) readProcessStderr(ctx context.Context, c *Container, processID string, data []byte) (int, error) {
return 0, nil
}
// pauseContainer is the Noop agent Container pause implementation. It does nothing.
func (n *mockAgent) pauseContainer(sandbox *Sandbox, c Container) error {
func (n *mockAgent) pauseContainer(ctx context.Context, sandbox *Sandbox, c Container) error {
return nil
}
// resumeContainer is the Noop agent Container resume implementation. It does nothing.
func (n *mockAgent) resumeContainer(sandbox *Sandbox, c Container) error {
func (n *mockAgent) resumeContainer(ctx context.Context, sandbox *Sandbox, c Container) error {
return nil
}
// configHypervisor is the Noop agent hypervisor configuration implementation. It does nothing.
func (n *mockAgent) configure(h hypervisor, id, sharePath string, config interface{}) error {
func (n *mockAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config interface{}) error {
return nil
}
@@ -185,7 +185,7 @@ func (n *mockAgent) configureFromGrpc(h hypervisor, id string, config interface{
}
// reseedRNG is the Noop agent RND reseeder. It does nothing.
func (n *mockAgent) reseedRNG(data []byte) error {
func (n *mockAgent) reseedRNG(ctx context.Context, data []byte) error {
return nil
}
@@ -205,24 +205,24 @@ func (n *mockAgent) setAgentURL() error {
}
// getGuestDetails is the Noop agent GuestDetails queryer. It does nothing.
func (n *mockAgent) getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error) {
func (n *mockAgent) getGuestDetails(context.Context, *grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error) {
return nil, nil
}
// setGuestDateTime is the Noop agent guest time setter. It does nothing.
func (n *mockAgent) setGuestDateTime(time.Time) error {
func (n *mockAgent) setGuestDateTime(context.Context, time.Time) error {
return nil
}
// copyFile is the Noop agent copy file. It does nothing.
func (n *mockAgent) copyFile(src, dst string) error {
func (n *mockAgent) copyFile(ctx context.Context, src, dst string) error {
return nil
}
func (n *mockAgent) markDead() {
func (n *mockAgent) markDead(ctx context.Context) {
}
func (n *mockAgent) cleanup(s *Sandbox) {
func (n *mockAgent) cleanup(ctx context.Context, s *Sandbox) {
}
// save is the Noop agent state saver. It does nothing.
@@ -233,10 +233,10 @@ func (n *mockAgent) save() (s persistapi.AgentState) {
// load is the Noop agent state loader. It does nothing.
func (n *mockAgent) load(s persistapi.AgentState) {}
func (n *mockAgent) getOOMEvent() (string, error) {
func (n *mockAgent) getOOMEvent(ctx context.Context) (string, error) {
return "", nil
}
func (k *mockAgent) getAgentMetrics(req *grpc.GetMetricsRequest) (*grpc.Metrics, error) {
func (k *mockAgent) getAgentMetrics(ctx context.Context, req *grpc.GetMetricsRequest) (*grpc.Metrics, error) {
return nil, nil
}