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

@@ -74,19 +74,19 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
// cleanup sandbox resources in case of any failure
defer func() {
if err != nil {
s.Delete()
s.Delete(ctx)
}
}()
// Create the sandbox network
if err = s.createNetwork(); err != nil {
if err = s.createNetwork(ctx); err != nil {
return nil, err
}
// network rollback
defer func() {
if err != nil {
s.removeNetwork()
s.removeNetwork(ctx)
}
}()
@@ -102,30 +102,30 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
}
// Start the VM
if err = s.startVM(); err != nil {
if err = s.startVM(ctx); err != nil {
return nil, err
}
// rollback to stop VM if error occurs
defer func() {
if err != nil {
s.stopVM()
s.stopVM(ctx)
}
}()
s.postCreatedNetwork()
s.postCreatedNetwork(ctx)
if err = s.getAndStoreGuestDetails(); err != nil {
if err = s.getAndStoreGuestDetails(ctx); err != nil {
return nil, err
}
// Create Containers
if err = s.createContainers(); err != nil {
if err = s.createContainers(ctx); err != nil {
return nil, err
}
// The sandbox is completely created now, we can store it.
if err = s.storeSandbox(); err != nil {
if err = s.storeSandbox(ctx); err != nil {
return nil, err
}
@@ -157,14 +157,14 @@ func CleanupContainer(ctx context.Context, sandboxID, containerID string, force
if err != nil {
return err
}
defer s.Release()
defer s.Release(ctx)
_, err = s.StopContainer(containerID, force)
_, err = s.StopContainer(ctx, containerID, force)
if err != nil && !force {
return err
}
_, err = s.DeleteContainer(containerID)
_, err = s.DeleteContainer(ctx, containerID)
if err != nil && !force {
return err
}
@@ -173,11 +173,11 @@ func CleanupContainer(ctx context.Context, sandboxID, containerID string, force
return nil
}
if err = s.Stop(force); err != nil && !force {
if err = s.Stop(ctx, force); err != nil && !force {
return err
}
if err = s.Delete(); err != nil {
if err = s.Delete(ctx); err != nil {
return err
}