@@ -36,6 +36,8 @@ import (
36
36
// validateClusterIPFlags is expected to be called after Complete()
37
37
func validateClusterIPFlags (options * ServerRunOptions ) []error {
38
38
var errs []error
39
+ // maxCIDRbits is used to define the maximum CIDR size for the cluster ip(s)
40
+ const maxCIDRbits = 20
39
41
40
42
// validate that primary has been processed by user provided values or it has been defaulted
41
43
if options .PrimaryServiceClusterIPRange .IP == nil {
@@ -50,8 +52,8 @@ func validateClusterIPFlags(options *ServerRunOptions) []error {
50
52
// Complete() expected to have set Primary* and Secondary*
51
53
// primary CIDR validation
52
54
var ones , bits = options .PrimaryServiceClusterIPRange .Mask .Size ()
53
- if bits - ones > 20 {
54
- errs = append (errs , errors . New ("specified --service-cluster-ip-range is too large" ))
55
+ if bits - ones > maxCIDRbits {
56
+ errs = append (errs , fmt . Errorf ("specified --service-cluster-ip-range is too large. Network CIDR should not be bigger than /%d" , bits - maxCIDRbits ))
55
57
}
56
58
57
59
// Secondary IP validation
@@ -79,8 +81,8 @@ func validateClusterIPFlags(options *ServerRunOptions) []error {
79
81
// bigger cidr (specially those offered by IPv6) will add no value
80
82
// significantly increase snapshotting time.
81
83
var ones , bits = options .SecondaryServiceClusterIPRange .Mask .Size ()
82
- if bits - ones > 20 {
83
- errs = append (errs , errors . New ("specified --secondary- service-cluster-ip-range is too large" ))
84
+ if bits - ones > maxCIDRbits {
85
+ errs = append (errs , fmt . Errorf ("specified --service-cluster-ip-range is too large. Network CIDR should not be bigger than /%d" , bits - maxCIDRbits ))
84
86
}
85
87
}
86
88
0 commit comments