From f56ce29a0ac8485ffcf0afd1d3d0dd455cd5d91c Mon Sep 17 00:00:00 2001 From: wackxu Date: Mon, 30 Oct 2017 20:17:04 +0800 Subject: [PATCH] fix TODO one of min-available/max-available must be specified when create pdb --- pkg/kubectl/pdb.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/kubectl/pdb.go b/pkg/kubectl/pdb.go index 0c93b27b57c..24632b0c3ce 100644 --- a/pkg/kubectl/pdb.go +++ b/pkg/kubectl/pdb.go @@ -18,7 +18,6 @@ package kubectl import ( "fmt" - "os" policy "k8s.io/api/policy/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -167,15 +166,6 @@ func (s *PodDisruptionBudgetV2Generator) StructuredGenerate() (runtime.Object, e return nil, err } - if len(s.MaxUnavailable) == 0 && len(s.MinAvailable) == 0 { - s.MinAvailable = "1" - - // This behavior is intended for backward compatibility. - // TODO: remove in Kubernetes 1.8 - fmt.Fprintln(os.Stderr, "Deprecated behavior in kubectl create pdb: Defaulting min-available to 1. "+ - "Kubernetes 1.8 will remove this default, and one of min-available/max-available must be specified. ") - } - if len(s.MaxUnavailable) > 0 { maxUnavailable := intstr.Parse(s.MaxUnavailable) return &policy.PodDisruptionBudget{ @@ -213,6 +203,9 @@ func (s *PodDisruptionBudgetV2Generator) validate() error { if len(s.Selector) == 0 { return fmt.Errorf("a selector must be specified") } + if len(s.MaxUnavailable) == 0 && len(s.MinAvailable) == 0 { + return fmt.Errorf("one of min-available/max-available must be specified") + } if len(s.MaxUnavailable) > 0 && len(s.MinAvailable) > 0 { return fmt.Errorf("min-available and max-unavailable cannot be both specified") }