Remove kubectl run validate replicas logic

This commit is contained in:
zhouya0 2020-06-16 17:01:33 +08:00
parent 73fa63a86d
commit 4b82d5ae08
2 changed files with 0 additions and 17 deletions

View File

@ -280,10 +280,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
if o.TTY && !o.Interactive {
return cmdutil.UsageErrorf(cmd, "-i/--stdin is required for containers with -t/--tty=true")
}
replicas := cmdutil.GetFlagInt(cmd, "replicas")
if o.Interactive && replicas != 1 {
return cmdutil.UsageErrorf(cmd, "-i/--stdin requires that replicas is 1, found %d", replicas)
}
if o.Expose && len(o.Port) == 0 {
return cmdutil.UsageErrorf(cmd, "--port must be set when exposing a service")
}
@ -296,9 +292,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
if err != nil {
return err
}
if restartPolicy != corev1.RestartPolicyAlways && replicas != 1 {
return cmdutil.UsageErrorf(cmd, "--restart=%s requires that --replicas=1, found %d", restartPolicy, replicas)
}
remove := cmdutil.GetFlagBool(cmd, "rm")
if !o.Attach && remove {

View File

@ -441,16 +441,6 @@ func TestRunValidations(t *testing.T) {
},
expectedErr: "Invalid image name",
},
{
name: "test stdin replicas value",
args: []string{"test"},
flags: map[string]string{
"image": "busybox",
"stdin": "true",
"replicas": "2",
},
expectedErr: "stdin requires that replicas is 1",
},
{
name: "test rm errors when used on non-attached containers",
args: []string{"test"},