Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1779331: Fix a number of issues around debugging daemonset pods and init containers #166

Merged
merged 5 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -11876,6 +11876,9 @@ _oc_debug()
flags_with_completion+=("--template")
flags_completion+=("_filedir")
local_nonpersistent_flags+=("--template=")
flags+=("--to-namespace=")
two_word_flags+=("--to-namespace")
local_nonpersistent_flags+=("--to-namespace=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
3 changes: 3 additions & 0 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -12018,6 +12018,9 @@ _oc_debug()
flags_with_completion+=("--template")
flags_completion+=("_filedir")
local_nonpersistent_flags+=("--template=")
flags+=("--to-namespace=")
two_word_flags+=("--to-namespace")
local_nonpersistent_flags+=("--to-namespace=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
5 changes: 5 additions & 0 deletions pkg/cli/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ type DebugOptions struct {
DryRun bool
FullCmdName string
Image string
ToNamespace string

// IsNode is set after we see the object we're debugging. We use it to be able to print pertinent advice.
IsNode bool
Expand Down Expand Up @@ -204,6 +205,7 @@ func NewCmdDebug(fullName string, f kcmdutil.Factory, streams genericclioptions.
cmd.Flags().BoolVar(&o.AsRoot, "as-root", o.AsRoot, "If true, try to run the container as the root user")
cmd.Flags().Int64Var(&o.AsUser, "as-user", o.AsUser, "Try to run the container as a specific user UID (note: admins may limit your ability to use this flag)")
cmd.Flags().StringVar(&o.Image, "image", o.Image, "Override the image used by the targeted container.")
cmd.Flags().StringVar(&o.ToNamespace, "to-namespace", o.ToNamespace, "Override the namespace to create the pod into (instead of using --namespace).")

o.PrintFlags.AddFlags(cmd)
kcmdutil.AddDryRunFlag(cmd)
Expand Down Expand Up @@ -362,6 +364,9 @@ func (o *DebugOptions) RunDebug() error {
if len(ns) == 0 {
ns = o.Namespace
}
if len(o.ToNamespace) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from explicitly using --namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example is:

oc debug istag/cli:latest -n openshift —to-namespace=my-test-ns

For when you don’t have write access in the namespace that contains the thing you want to debug.

ns = o.ToNamespace
}
pod.Name, pod.Namespace = fmt.Sprintf("%s-debug", generateapp.MakeSimpleName(infos[0].Name)), ns
o.Attach.Pod = pod

Expand Down