From 0949e08336b2225e8826c34d9a455a17eabdec3c Mon Sep 17 00:00:00 2001 From: AdoHe Date: Tue, 26 Jul 2016 02:37:55 -0400 Subject: [PATCH] fix kubectl rolling update empty file cause panic issue --- pkg/kubectl/cmd/rollingupdate.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/kubectl/cmd/rollingupdate.go b/pkg/kubectl/cmd/rollingupdate.go index 1f2eb032460..5cede1a00bf 100644 --- a/pkg/kubectl/cmd/rollingupdate.go +++ b/pkg/kubectl/cmd/rollingupdate.go @@ -220,6 +220,9 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg if len(list.Items) > 1 { return cmdutil.UsageError(cmd, "%s specifies multiple items", filename) } + if len(list.Items) == 0 { + return cmdutil.UsageError(cmd, "please make sure %s exists and is not empty", filename) + } obj = list.Items[0] } newRc, ok = obj.(*api.ReplicationController)