Skip to content

Commit

Permalink
Small ps and stop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjug committed Oct 22, 2018
1 parent 763e717 commit 751adcd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func validateFlags(c *cli.Context, flags []cli.Flag) error {

// getContext returns a non-nil, empty context
func getContext(c *cli.Context) context.Context {
if c.GlobalBool("trace") {
if c != nil && c.GlobalBool("trace") {
return c.Ctx
}
return context.TODO()
Expand Down
6 changes: 6 additions & 0 deletions cmd/podman/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -50,6 +51,11 @@ var (
)

func startCmd(c *cli.Context) error {
if c.GlobalBool("trace") {
span, _ := opentracing.StartSpanFromContext(c.Ctx, "startCmd")
defer span.Finish()
}

args := c.Args()
if len(args) < 1 && !c.Bool("latest") {
return errors.Errorf("you must provide at least one container name or id")
Expand Down
6 changes: 6 additions & 0 deletions cmd/podman/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -44,6 +45,11 @@ var (
)

func stopCmd(c *cli.Context) error {
if c.GlobalBool("trace") {
span, _ := opentracing.StartSpanFromContext(c.Ctx, "stopCmd")
defer span.Finish()
}

args := c.Args()
if (c.Bool("all") || c.Bool("latest")) && len(args) > 0 {
return errors.Errorf("no arguments are needed with --all or --latest")
Expand Down
18 changes: 7 additions & 11 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package libpod
r

import (
"bytes"
"context"
Expand Down Expand Up @@ -817,10 +817,6 @@ func (c *Container) mountStorage() (err error) {

// cleanupStorage unmounts and cleans up the container's root filesystem
func (c *Container) cleanupStorage() error {
span, _ := opentracing.StartSpanFromContext(ctx, "cleanupStorage")
span.SetTag("struct", "container")
defer span.Finish()

if !c.state.Mounted {
// Already unmounted, do nothing
logrus.Debugf("Storage is already unmounted, skipping...")
Expand Down Expand Up @@ -896,9 +892,9 @@ func (c *Container) cleanup(ctx context.Context) error {
// delete deletes the container and runs any configured poststop
// hooks.
func (c *Container) delete(ctx context.Context) (err error) {
span, _ := opentracing.StartSpanFromContext(ctx, "delete")
span.SetTag("struct", "container")
defer span.Finish()
span, _ := opentracing.StartSpanFromContext(ctx, "delete")
span.SetTag("struct", "container")
defer span.Finish()

if err := c.runtime.ociRuntime.deleteContainer(c); err != nil {
return errors.Wrapf(err, "error removing container %s from runtime", c.ID())
Expand All @@ -915,9 +911,9 @@ func (c *Container) delete(ctx context.Context) (err error) {
// the OCI Runtime Specification (which requires them to run
// post-delete, despite the stage name).
func (c *Container) postDeleteHooks(ctx context.Context) (err error) {
span, _ := opentracing.StartSpanFromContext(ctx, "postDeleteHooks")
span.SetTag("struct", "container")
defer span.Finish()
span, _ := opentracing.StartSpanFromContext(ctx, "postDeleteHooks")
span.SetTag("struct", "container")
defer span.Finish()

if c.state.ExtensionStageHooks != nil {
extensionHooks, ok := c.state.ExtensionStageHooks["poststop"]
Expand Down

0 comments on commit 751adcd

Please sign in to comment.