kubectl replace --grace-period=0 --force ends with nil pointer dereference #64401
Description
Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
/sig CLI
What happened:
Running ./kubernetes/cluster/kubectl.sh replace -f pod2.yaml --grace-period=0 --force
leads to nil pointer dereference:
./kubernetes/cluster/kubectl.sh replace -f pod2.yaml --grace-period=0 --force
pod "nginx" deleted
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1028416]
goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource.(*Result).Visit(0x0, 0xc420fa7910, 0x0, 0x124d21d)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource/result.go:96 +0x26
k8s.io/kubernetes/pkg/kubectl/cmd/wait.(*WaitOptions).RunWait(0xc4206f2150, 0x0, 0x184a9c0)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/wait/wait.go:168 +0x9a
k8s.io/kubernetes/pkg/kubectl/cmd.(*DeleteOptions).DeleteResult(0xc4200bed80, 0xc4200bd000, 0xc4200bed80, 0xc4206c8f20)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/delete.go:286 +0x287
k8s.io/kubernetes/pkg/kubectl/cmd.(*ReplaceOptions).forceReplace(0xc4200be480, 0x0, 0x0)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/replace.go:276 +0x368
k8s.io/kubernetes/pkg/kubectl/cmd.(*ReplaceOptions).Run(0xc4200be480, 0x0, 0x0)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/replace.go:208 +0x1d6
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdReplace.func1(0xc42054aa00, 0xc42007b7c0, 0x0, 0x4)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/replace.go:119 +0xc3
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc42054aa00, 0xc42007b740, 0x4, 0x4, 0xc42054aa00, 0xc42007b740)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:760 +0x2c1
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc420140280, 0xc42079d3e0, 0x12a05f200, 0xc420857ee8)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:846 +0x30a
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc420140280, 0x17a38d8, 0x2388d00)
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:794 +0x2b
main.main()
/home/nilebox/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:50 +0x196
What you expected to happen:
kubectl replace
is expected to run delete with wait in that case
How to reproduce it (as minimally and precisely as possible):
./kubernetes/cluster/kubectl.sh replace -f pod2.yaml --grace-period=0 --force
(with any valid resource yaml)
Anything else we need to know?:
Discovered in #64375 when accidentally enabled wait for deletion from other commands than kubectl delete
and saw failing integration tests in https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/64375/pull-kubernetes-integration/13560/
Environment:
- Kubernetes version (use
kubectl version
): latest master - Cloud provider or hardware configuration:
- OS (e.g. from /etc/os-release):
- Kernel (e.g.
uname -a
): - Install tools:
- Others: