Skip to content

Commit

Permalink
feat(cmd/run): pass pod uid to trace run
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <[email protected]>
  • Loading branch information
fntlnz committed Dec 24, 2018
1 parent bb56e8b commit b2d8641
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (o *RunOptions) Complete(factory factory.Factory, cmd *cobra.Command, args
case *v1.Pod:
o.isPod = true
found := false
o.podUID = string(v.UID)
for _, c := range v.Spec.Containers {
// default if no container provided
if len(o.container) == 0 {
Expand All @@ -193,6 +194,11 @@ func (o *RunOptions) Complete(factory factory.Factory, cmd *cobra.Command, args
}
}

if len(v.Spec.NodeName) == 0 {
return fmt.Errorf("cannot attach a trace program to a pod that is not currently scheduled on a node")
}
o.nodeName = v.Spec.NodeName

if !found {
return fmt.Errorf("no containers found for the provided pod/container combination")
}
Expand Down

0 comments on commit b2d8641

Please sign in to comment.