diff --git a/go.mod b/go.mod index 4485d3e77d..6d294772f5 100644 --- a/go.mod +++ b/go.mod @@ -7,42 +7,34 @@ require ( github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/beorn7/perks v1.0.0 // indirect github.com/emicklei/go-restful v2.9.3+incompatible // indirect - github.com/evanphx/json-patch v4.1.0+incompatible // indirect github.com/go-openapi/spec v0.19.0 github.com/go-openapi/swag v0.19.0 // indirect github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect github.com/google/go-cmp v0.3.0 - github.com/google/gofuzz v1.0.0 // indirect github.com/googleapis/gnostic v0.2.0 // indirect github.com/imdario/mergo v0.3.7 // indirect - github.com/json-iterator/go v1.1.6 // indirect github.com/kr/pretty v0.1.0 github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect github.com/mdempsky/maligned v0.0.0-20180708014732-6e39bd26a8c8 // indirect - github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 - github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect - github.com/prometheus/common v0.3.0 // indirect - github.com/prometheus/procfs v0.0.0-20190416084830-8368d24ba045 // indirect - github.com/spf13/pflag v1.0.3 + github.com/prometheus/client_golang v1.0.0 + github.com/spf13/pflag v1.0.5 github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 // indirect golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 gopkg.in/gcfg.v1 v1.2.3 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect istio.io/api v0.0.0-20190809125725-591cf32c1d0e - k8s.io/api v0.0.0 + k8s.io/api v0.17.0 k8s.io/apiextensions-apiserver v0.0.0 - k8s.io/apimachinery v0.0.0 - k8s.io/client-go v0.0.0 - k8s.io/cloud-provider v0.0.0 - k8s.io/component-base v0.0.0 - k8s.io/klog v0.4.0 - k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 + k8s.io/apimachinery v0.17.0 + k8s.io/client-go v0.17.0 + k8s.io/cloud-provider v0.17.0 + k8s.io/component-base v0.17.0 + k8s.io/klog v1.0.0 + k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a k8s.io/kubernetes v1.15.0 k8s.io/legacy-cloud-providers v0.0.0 - k8s.io/utils v0.0.0-20190801114015-581e00157fb1 + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f ) replace ( @@ -92,7 +84,7 @@ replace ( k8s.io/component-base => k8s.io/component-base v0.0.0-20190620085131-4cd66be69262 k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190531030430-6117653b35f1 k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20190620090114-816aa063c73d - k8s.io/klog => k8s.io/klog v0.3.0 + k8s.io/klog => k8s.io/klog v1.0.0 k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20190620085316-c835efc41000 k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20190620085943-52018c8ce3c1 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 @@ -100,7 +92,7 @@ replace ( k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20190620085909-5dfb14b3a101 k8s.io/kubelet => k8s.io/kubelet v0.0.0-20190620085837-98477dc0c87c k8s.io/kubernetes => k8s.io/kubernetes v1.15.0 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20191114112650-ed060d80c11c + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20191114112650-b5fed2ccee23 k8s.io/metrics => k8s.io/metrics v0.0.0-20190620085627-5b02f62e9559 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20190620085357-8191e314a1f7 ) diff --git a/go.sum b/go.sum index 262e0d15e4..e2284db19b 100644 --- a/go.sum +++ b/go.sum @@ -2,7 +2,7 @@ bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690/go.mod h1: cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= github.com/Azure/azure-sdk-for-go v21.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v32.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest v11.1.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest v11.1.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= @@ -117,6 +117,7 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.17.2/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= @@ -165,6 +166,7 @@ github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkY github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1sTX6NE48= github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= @@ -176,6 +178,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= @@ -187,6 +190,7 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= @@ -262,10 +266,12 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420 h1:Yu3681ykYHDfLoI6XVjL4JWmkE+3TX9yfIWwRCh1kFM= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v0.0.0-20170604055404-372ad780f634/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= @@ -325,6 +331,7 @@ github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRci github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/syndtr/gocapability v0.0.0-20160928074757-e7cb7fa329f4/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -335,6 +342,7 @@ github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKn github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vmware/govmomi v0.20.1/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc/go.mod h1:e6humHha1ekIwTCm+A5Qed5mG8V4JL+ChHcUOJ+L/8U= github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57/go.mod h1:s3eL3z5pNXF5FVybcT+LIVdId8pYn709yv6v5mrkrQE= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -424,6 +432,7 @@ google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs= @@ -452,6 +461,8 @@ k8s.io/api v0.0.0-20190418212532-b8e4ab4b136a h1:dQUlNDGA5R4bkG882FlNHw+zSvc8VSg k8s.io/api v0.0.0-20190418212532-b8e4ab4b136a/go.mod h1:B0cvvXrD9UkqARVdlFhdZB9SNL0TzJ13UB/p410skE4= k8s.io/api v0.0.0-20190620085002-8f739060a0b3 h1:Cgi5AmittRgKVpjIoEKQf6S4bvQjcDxdfDg16TdrUoY= k8s.io/api v0.0.0-20190620085002-8f739060a0b3/go.mod h1:TBhBqb1AWbBQbW3XRusr7n7E4v2+5ZY8r8sAMnyFC5A= +k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM= +k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA= k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE= k8s.io/apiextensions-apiserver v0.0.0-20190620085550-3a2f62f126c9 h1:k9vwVsnIfkX2eTHTTfJoYo6pGwwVBUAr7VZzinSrjLM= @@ -460,6 +471,8 @@ k8s.io/apimachinery v0.0.0-20190418212431-b3683fe6b520 h1:+MKM1EKVdEjboGj1nG5Su2 k8s.io/apimachinery v0.0.0-20190418212431-b3683fe6b520/go.mod h1:tXkZEnPhecLuffcJcEuO/iNpM8w0n42dM5fNrr9OVVE= k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 h1:uV4S5IB5g4Nvi+TBVNf3e9L4wrirlwYJ6w88jUQxTUw= k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719/go.mod h1:I4A+glKBHiTgiEjQiCCQfCAIcIMFGt291SmsvcrFzJA= +k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo= +k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= k8s.io/apiserver v0.0.0-20190418213308-0a718f081a3a h1:z7INMWaYTzAqxHmm6GMvYR4jpIx/UQTejTKRob4FlKE= k8s.io/apiserver v0.0.0-20190418213308-0a718f081a3a/go.mod h1:N5AgsQJZaLvPYb5xEZpqCBitO+/5rAvUQrr7geOk3m0= k8s.io/apiserver v0.0.0-20190620085203-5d32fb3b42f4 h1:+lRbilES3x1WjsGGkSjWxMmBxczwHPYuOxSVWqrm4EM= @@ -469,18 +482,24 @@ k8s.io/client-go v0.0.0-20190418212717-1d2e9628a1ee h1:rrPtu1HCMs1ZpuLIoov/aPg30 k8s.io/client-go v0.0.0-20190418212717-1d2e9628a1ee/go.mod h1:XVGgfiW2lYCXo3EruwtPpqXRsZyVeeW1LcABt0M8P4Y= k8s.io/client-go v0.0.0-20190620085041-d697df55dbe9 h1:AC1FlaIvKQ9YlTqArz9AjHt93etRMIO3kOIuVFncdBE= k8s.io/client-go v0.0.0-20190620085041-d697df55dbe9/go.mod h1:tJOzO9NIWw9Uik0XLSObd2NqQJ8jcW6ZW3n0y10S35o= +k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg= +k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= k8s.io/cloud-provider v0.0.0-20190418214227-029ecc113e6d h1:CAm4WUaMRJ3gwN94k8FHO87CvfJUJh1Ub3RlgQaGXr0= k8s.io/cloud-provider v0.0.0-20190418214227-029ecc113e6d/go.mod h1:4e1m/GhXK5bG+dZbaybPdhZFbVIM1dbQMZ2SZ5x9/Qo= k8s.io/cloud-provider v0.0.0-20190620090041-1a7e1f6630cd h1:3rNeJmlNQjzcuUi6h1loRsqKjMQSxWDAWYDMittuTGE= k8s.io/cloud-provider v0.0.0-20190620090041-1a7e1f6630cd/go.mod h1:Un5YLpjmC+XZ9zO19edNEnyy9bQ9gt2H210665c4FWc= k8s.io/cloud-provider v0.0.0-20191114112026-556fa5a14fdf h1:PLIMcSmqcgtLeROLUsGW65d9ol3R7BmH5v66+lOz6eM= k8s.io/cloud-provider v0.0.0-20191114112026-556fa5a14fdf/go.mod h1:p8FbcuUZwp5h8EJnxVPclzsHu5EKckx9Oa/6xFYfchE= +k8s.io/cloud-provider v0.17.0 h1:BQZPD1Ja/vnTOj1GKI9/wSpd3qgIDZp9q2NAS3568Ac= +k8s.io/cloud-provider v0.17.0/go.mod h1:Ze4c3w2C0bRsjkBUoHpFi+qWe3ob1wI2/7cUn+YQIDE= k8s.io/cluster-bootstrap v0.0.0-20190620090010-a60497bb9ffa/go.mod h1:nKdJhweDROdvToPucD2iin6nuJ0zg8qRxBu2i/LqxL0= k8s.io/code-generator v0.0.0-20190612205613-18da4a14b22b/go.mod h1:G8bQwmHm2eafm5bgtX67XDZQ8CWKSGu9DekI+yN4Y5I= k8s.io/component-base v0.0.0-20190418213057-380654ddefc0 h1:XTFWZogFXoy92vIEaXX9vaajKjiWBldOgrnjOYijv3Q= k8s.io/component-base v0.0.0-20190418213057-380654ddefc0/go.mod h1:t3l+mQYxvfsiaTg+cT4MxOjO7MEMbT+CUhF601VYD70= k8s.io/component-base v0.0.0-20190620085131-4cd66be69262 h1:2j4mE+jKntnIcQjOOWyzb/2GsJIuPqjORLMDeHnagpM= k8s.io/component-base v0.0.0-20190620085131-4cd66be69262/go.mod h1:VLedAFwENz2swOjm0zmUXpAP2mV55c49xgaOzPBI/QQ= +k8s.io/component-base v0.17.0 h1:BnDFcmBDq+RPpxXjmuYnZXb59XNN9CaFrX8ba9+3xrA= +k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc= k8s.io/cri-api v0.0.0-20190531030430-6117653b35f1/go.mod h1:K6Ux7uDbzKhacgqW0OJg3rjXk/SR9kprCPfSUDXGB5A= k8s.io/csi-translation-lib v0.0.0-20190620090114-816aa063c73d/go.mod h1:q5k0Vv3qsOTu2PUrTh+4mRAj+Pt+1BRyWiiwr5LBFOM= k8s.io/gengo v0.0.0-20190116091435-f8a0810f38af/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= @@ -488,6 +507,8 @@ k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8 k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM= k8s.io/klog v0.3.0 h1:0VPpR+sizsiivjIfIAQH/rl8tan6jvWkS7lU+0di3lE= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-aggregator v0.0.0-20190620085316-c835efc41000/go.mod h1:VQ+wumV2o4KXe3arqjS/+4l3Hd+3cZOOCf1wcGPzPJg= k8s.io/kube-controller-manager v0.0.0-20190620085943-52018c8ce3c1/go.mod h1:E2bR8dj02P7Ydp/oaGjos0ydxIps1dcqvA21BsAGr9I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= @@ -503,8 +524,8 @@ k8s.io/kubernetes v1.15.0 h1:0P6jAdZ1cF5/wSc14HqHCjWlbnwYzmFJBYeXBezZEE0= k8s.io/kubernetes v1.15.0/go.mod h1:3RE5ikMc73WK+dSxk4pQuQ6ZaJcPXiZX2dj98RcdCuM= k8s.io/legacy-cloud-providers v0.0.0-20190620090159-a9e4f3cb5bf3 h1:M7/X/e8icd2qvUe0MJk/qn9rcF4Oc+TzodGa/GWMqz0= k8s.io/legacy-cloud-providers v0.0.0-20190620090159-a9e4f3cb5bf3/go.mod h1:vN4qQ5sBl+8105txtOVlFFNAXTc8lYvM41krV0K7xXc= -k8s.io/legacy-cloud-providers v0.0.0-20191114112650-ed060d80c11c h1:4Qv7AngmzEzFYMMSjP8Z+n8ZiibFrVX0AchRuIxxPqc= -k8s.io/legacy-cloud-providers v0.0.0-20191114112650-ed060d80c11c/go.mod h1:c5Qs9nhpsgsYaKjdWJfrwpEHKHbVAhPYvDa/7shMvGs= +k8s.io/legacy-cloud-providers v0.0.0-20191114112650-b5fed2ccee23 h1:bTJRQQAdp8b4KQ7Km30l7JjQbgPsjeEaRWbrQhmOFVs= +k8s.io/legacy-cloud-providers v0.0.0-20191114112650-b5fed2ccee23/go.mod h1:DdzaepJ3RtRy+e5YhNtrCYwlgyK87j/5+Yfp0L9Syp8= k8s.io/metrics v0.0.0-20190620085627-5b02f62e9559/go.mod h1:f5M7Wu7aoJPaYxys9OpQdzhfOVWhuS/WE20voRy8KEY= k8s.io/repo-infra v0.0.0-20181204233714-00fe14e3d1a3/go.mod h1:+G1xBfZDfVFsm1Tj/HNCvg4QqWx8rJ2Fxpqr1rqp/gQ= k8s.io/sample-apiserver v0.0.0-20190620085357-8191e314a1f7/go.mod h1:RVMdQ03C5ZqPz82uV82L72wju27+zFFnyzKje9DVBZI= @@ -512,8 +533,9 @@ k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 h1:8r+l4bNWjRlsFYlQJnKJ2p7s1YQPj4XyXiJVqDHRx7c= k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/pkg/cmconfig/controller_test.go b/pkg/cmconfig/controller_test.go index ff32306922..80a727ce8d 100644 --- a/pkg/cmconfig/controller_test.go +++ b/pkg/cmconfig/controller_test.go @@ -1,6 +1,7 @@ package cmconfig import ( + "flag" "strings" "testing" "time" @@ -8,7 +9,7 @@ import ( "bytes" "os" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" informerv1 "k8s.io/client-go/informers/core/v1" "k8s.io/client-go/kubernetes/fake" @@ -39,6 +40,8 @@ func TestNewConfigMapConfigControllerDefaultValue(t *testing.T) { func TestController(t *testing.T) { defaultConfig := NewConfig() + klog.InitFlags(nil) + flag.CommandLine.Parse([]string{"--logtostderr=false"}) testcases := []struct { desc string defaultConfigMapData map[string]string @@ -90,7 +93,6 @@ func TestController(t *testing.T) { donotWantLog: "", }, } - for _, tc := range testcases { t.Run(tc.desc, func(t *testing.T) { var logBuf bytes.Buffer diff --git a/pkg/firewalls/controller.go b/pkg/firewalls/controller.go index 514dc09bc8..f026d3a63d 100644 --- a/pkg/firewalls/controller.go +++ b/pkg/firewalls/controller.go @@ -61,7 +61,7 @@ type FirewallController struct { func NewFirewallController( ctx *context.ControllerContext, portRanges []string) *FirewallController { - firewallPool := NewFirewallPool(ctx.Cloud, ctx.ClusterNamer, gce.LoadBalancerSrcRanges(), portRanges) + firewallPool := NewFirewallPool(ctx.Cloud, ctx.ClusterNamer, gce.L4LoadBalancerSrcRanges(), portRanges) fwc := &FirewallController{ ctx: ctx, diff --git a/vendor/k8s.io/klog/.travis.yml b/vendor/k8s.io/klog/.travis.yml index 0f508dae66..5677664c21 100644 --- a/vendor/k8s.io/klog/.travis.yml +++ b/vendor/k8s.io/klog/.travis.yml @@ -5,11 +5,12 @@ go: - 1.9.x - 1.10.x - 1.11.x + - 1.12.x script: - go get -t -v ./... - diff -u <(echo -n) <(gofmt -d .) - diff -u <(echo -n) <(golint $(go list -e ./...)) - - go tool vet . + - go tool vet . || go vet . - go test -v -race ./... install: - go get golang.org/x/lint/golint diff --git a/vendor/k8s.io/klog/README.md b/vendor/k8s.io/klog/README.md index bee306f398..841468b4b6 100644 --- a/vendor/k8s.io/klog/README.md +++ b/vendor/k8s.io/klog/README.md @@ -31,7 +31,7 @@ How to use klog - Use `klog.InitFlags(nil)` explicitly for initializing global flags as we no longer use `init()` method to register the flags - You can now use `log-file` instead of `log-dir` for logging to a single file (See `examples/log_file/usage_log_file.go`) - If you want to redirect everything logged using klog somewhere else (say syslog!), you can use `klog.SetOutput()` method and supply a `io.Writer`. (See `examples/set_output/usage_set_output.go`) -- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md)) +- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md)) ### Coexisting with glog This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and syncronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`. diff --git a/vendor/k8s.io/klog/go.mod b/vendor/k8s.io/klog/go.mod new file mode 100644 index 0000000000..3877d8546a --- /dev/null +++ b/vendor/k8s.io/klog/go.mod @@ -0,0 +1,5 @@ +module k8s.io/klog + +go 1.12 + +require github.com/go-logr/logr v0.1.0 diff --git a/vendor/k8s.io/klog/go.sum b/vendor/k8s.io/klog/go.sum new file mode 100644 index 0000000000..fb64d277a7 --- /dev/null +++ b/vendor/k8s.io/klog/go.sum @@ -0,0 +1,2 @@ +github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= diff --git a/vendor/k8s.io/klog/klog.go b/vendor/k8s.io/klog/klog.go index 887ea62dff..2712ce0afc 100644 --- a/vendor/k8s.io/klog/klog.go +++ b/vendor/k8s.io/klog/klog.go @@ -20,26 +20,26 @@ // // Basic examples: // -// glog.Info("Prepare to repel boarders") +// klog.Info("Prepare to repel boarders") // -// glog.Fatalf("Initialization failed: %s", err) +// klog.Fatalf("Initialization failed: %s", err) // // See the documentation for the V function for an explanation of these examples: // -// if glog.V(2) { -// glog.Info("Starting transaction...") +// if klog.V(2) { +// klog.Info("Starting transaction...") // } // -// glog.V(2).Infoln("Processed", nItems, "elements") +// klog.V(2).Infoln("Processed", nItems, "elements") // // Log output is buffered and written periodically using Flush. Programs // should call Flush before exiting to guarantee all log output is written. // -// By default, all log statements write to files in a temporary directory. +// By default, all log statements write to standard error. // This package provides several flags that modify this behavior. // As a result, flag.Parse must be called before any logging is done. // -// -logtostderr=false +// -logtostderr=true // Logs are written to standard error instead of to files. // -alsologtostderr=false // Logs are written to standard error as well as to files. @@ -142,7 +142,7 @@ func (s *severity) Set(value string) error { if v, ok := severityByName(value); ok { threshold = v } else { - v, err := strconv.Atoi(value) + v, err := strconv.ParseInt(value, 10, 32) if err != nil { return err } @@ -226,7 +226,7 @@ func (l *Level) Get() interface{} { // Set is part of the flag.Value interface. func (l *Level) Set(value string) error { - v, err := strconv.Atoi(value) + v, err := strconv.ParseInt(value, 10, 32) if err != nil { return err } @@ -294,7 +294,7 @@ func (m *moduleSpec) Set(value string) error { return errVmoduleSyntax } pattern := patLev[0] - v, err := strconv.Atoi(patLev[1]) + v, err := strconv.ParseInt(patLev[1], 10, 32) if err != nil { return errors.New("syntax error: expect comma-separated list of filename=N") } @@ -396,29 +396,38 @@ type flushSyncWriter interface { io.Writer } +// init sets up the defaults and runs flushDaemon. func init() { - // Default stderrThreshold is ERROR. - logging.stderrThreshold = errorLog - + logging.stderrThreshold = errorLog // Default stderrThreshold is ERROR. logging.setVState(0, nil, false) + logging.logDir = "" + logging.logFile = "" + logging.logFileMaxSizeMB = 1800 + logging.toStderr = true + logging.alsoToStderr = false + logging.skipHeaders = false + logging.addDirHeader = false + logging.skipLogHeaders = false go logging.flushDaemon() } -// InitFlags is for explicitly initializing the flags +// InitFlags is for explicitly initializing the flags. func InitFlags(flagset *flag.FlagSet) { if flagset == nil { flagset = flag.CommandLine } - flagset.StringVar(&logging.logDir, "log_dir", "", "If non-empty, write log files in this directory") - flagset.StringVar(&logging.logFile, "log_file", "", "If non-empty, use this log file") - flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", 1800, + + flagset.StringVar(&logging.logDir, "log_dir", logging.logDir, "If non-empty, write log files in this directory") + flagset.StringVar(&logging.logFile, "log_file", logging.logFile, "If non-empty, use this log file") + flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", logging.logFileMaxSizeMB, "Defines the maximum size a log file can grow to. Unit is megabytes. "+ "If the value is 0, the maximum file size is unlimited.") - flagset.BoolVar(&logging.toStderr, "logtostderr", true, "log to standard error instead of files") - flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files") + flagset.BoolVar(&logging.toStderr, "logtostderr", logging.toStderr, "log to standard error instead of files") + flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", logging.alsoToStderr, "log to standard error as well as files") flagset.Var(&logging.verbosity, "v", "number for the log level verbosity") - flagset.BoolVar(&logging.skipHeaders, "skip_headers", false, "If true, avoid header prefixes in the log messages") - flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", false, "If true, avoid headers when openning log files") + flagset.BoolVar(&logging.skipHeaders, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header") + flagset.BoolVar(&logging.skipHeaders, "skip_headers", logging.skipHeaders, "If true, avoid header prefixes in the log messages") + flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", logging.skipLogHeaders, "If true, avoid headers when opening log files") flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr") flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging") flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace") @@ -485,6 +494,9 @@ type loggingT struct { // If true, do not add the headers to log files skipLogHeaders bool + + // If true, add the file directory to the header + addDirHeader bool } // buffer holds a byte Buffer for reuse. The zero value is ready for use. @@ -570,9 +582,14 @@ func (l *loggingT) header(s severity, depth int) (*buffer, string, int) { file = "???" line = 1 } else { - slash := strings.LastIndex(file, "/") - if slash >= 0 { - file = file[slash+1:] + if slash := strings.LastIndex(file, "/"); slash >= 0 { + path := file + file = path[slash+1:] + if l.addDirHeader { + if dirsep := strings.LastIndex(path[:slash], "/"); dirsep >= 0 { + file = path[dirsep+1:] + } + } } } return l.formatHeader(s, file, line), file, line @@ -721,6 +738,8 @@ func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) { // SetOutput sets the output destination for all severities func SetOutput(w io.Writer) { + logging.mu.Lock() + defer logging.mu.Unlock() for s := fatalLog; s >= infoLog; s-- { rb := &redirectBuffer{ w: w, @@ -731,6 +750,8 @@ func SetOutput(w io.Writer) { // SetOutputBySeverity sets the output destination for specific severity func SetOutputBySeverity(name string, w io.Writer) { + logging.mu.Lock() + defer logging.mu.Unlock() sev, ok := severityByName(name) if !ok { panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name)) @@ -756,24 +777,38 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() { os.Stderr.Write(data) } - if l.file[s] == nil { - if err := l.createFiles(s); err != nil { - os.Stderr.Write(data) // Make sure the message appears somewhere. - l.exit(err) + + if logging.logFile != "" { + // Since we are using a single log file, all of the items in l.file array + // will point to the same file, so just use one of them to write data. + if l.file[infoLog] == nil { + if err := l.createFiles(infoLog); err != nil { + os.Stderr.Write(data) // Make sure the message appears somewhere. + l.exit(err) + } } - } - switch s { - case fatalLog: - l.file[fatalLog].Write(data) - fallthrough - case errorLog: - l.file[errorLog].Write(data) - fallthrough - case warningLog: - l.file[warningLog].Write(data) - fallthrough - case infoLog: l.file[infoLog].Write(data) + } else { + if l.file[s] == nil { + if err := l.createFiles(s); err != nil { + os.Stderr.Write(data) // Make sure the message appears somewhere. + l.exit(err) + } + } + + switch s { + case fatalLog: + l.file[fatalLog].Write(data) + fallthrough + case errorLog: + l.file[errorLog].Write(data) + fallthrough + case warningLog: + l.file[warningLog].Write(data) + fallthrough + case infoLog: + l.file[infoLog].Write(data) + } } } if s == fatalLog { @@ -812,7 +847,7 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo // timeoutFlush calls Flush and returns when it completes or after timeout // elapses, whichever happens first. This is needed because the hooks invoked -// by Flush may deadlock when glog.Fatal is called from a hook that holds +// by Flush may deadlock when klog.Fatal is called from a hook that holds // a lock. func timeoutFlush(timeout time.Duration) { done := make(chan bool, 1) @@ -823,7 +858,7 @@ func timeoutFlush(timeout time.Duration) { select { case <-done: case <-time.After(timeout): - fmt.Fprintln(os.Stderr, "glog: Flush took longer than", timeout) + fmt.Fprintln(os.Stderr, "klog: Flush took longer than", timeout) } } @@ -1079,9 +1114,9 @@ type Verbose bool // The returned value is a boolean of type Verbose, which implements Info, Infoln // and Infof. These methods will write to the Info log if called. // Thus, one may write either -// if glog.V(2) { glog.Info("log this") } +// if klog.V(2) { klog.Info("log this") } // or -// glog.V(2).Info("log this") +// klog.V(2).Info("log this") // The second form is shorter but the first is cheaper if logging is off because it does // not evaluate its arguments. // @@ -1155,7 +1190,7 @@ func InfoDepth(depth int, args ...interface{}) { } // Infoln logs to the INFO log. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. func Infoln(args ...interface{}) { logging.println(infoLog, args...) } @@ -1179,7 +1214,7 @@ func WarningDepth(depth int, args ...interface{}) { } // Warningln logs to the WARNING and INFO logs. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. func Warningln(args ...interface{}) { logging.println(warningLog, args...) } @@ -1203,7 +1238,7 @@ func ErrorDepth(depth int, args ...interface{}) { } // Errorln logs to the ERROR, WARNING, and INFO logs. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. func Errorln(args ...interface{}) { logging.println(errorLog, args...) } @@ -1229,7 +1264,7 @@ func FatalDepth(depth int, args ...interface{}) { // Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, // including a stack trace of all running goroutines, then calls os.Exit(255). -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +// Arguments are handled in the manner of fmt.Println; a newline is always appended. func Fatalln(args ...interface{}) { logging.println(fatalLog, args...) } diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce.go index 1de777909c..70f46dc3a4 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce.go @@ -607,11 +607,9 @@ func (g *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, g.clientBuilder = clientBuilder g.client = clientBuilder.ClientOrDie("cloud-provider") - if g.OnXPN() { - g.eventBroadcaster = record.NewBroadcaster() - g.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: g.client.CoreV1().Events("")}) - g.eventRecorder = g.eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "g-cloudprovider"}) - } + g.eventBroadcaster = record.NewBroadcaster() + g.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: g.client.CoreV1().Events("")}) + g.eventRecorder = g.eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "g-cloudprovider"}) go g.watchClusterID(stop) } diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_alpha.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_alpha.go index 70b84d35b1..8cccd66a2c 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_alpha.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_alpha.go @@ -27,6 +27,9 @@ const ( // AlphaFeatureILBSubsets allows InternalLoadBalancer services to include a subset // of cluster nodes as backends instead of all nodes. AlphaFeatureILBSubsets = "ILBSubsets" + // AlphaFeatureILBCustomSubnet allows InternalLoadBalancer services to specify a + // network subnet to allocate ip addresses from. + AlphaFeatureILBCustomSubnet = "ILBCustomSubnet" ) // AlphaFeatureGate contains a mapping of alpha features to whether they are enabled diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_annotations.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_annotations.go index c2a3602f71..2280f26d91 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_annotations.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_annotations.go @@ -58,6 +58,11 @@ const ( // created in. ServiceAnnotationILBAllowGlobalAccess = "networking.gke.io/internal-load-balancer-allow-global-access" + // ServiceAnnotationILBSubnet is annotated on a service with the name of the subnetwork + // the ILB IP Address should be assigned from. By default, this is the subnetwork that the + // cluster is created in. + ServiceAnnotationILBSubnet = "networking.gke.io/internal-load-balancer-subnet" + // NetworkTierAnnotationKey is annotated on a Service object to indicate which // network tier a GCP LB should use. The valid values are "Standard" and // "Premium" (default). @@ -132,6 +137,8 @@ func GetServiceNetworkTier(service *v1.Service) (cloud.NetworkTier, error) { type ILBOptions struct { // AllowGlobalAccess Indicates whether global access is allowed for the LoadBalancer AllowGlobalAccess bool + // SubnetName indicates which subnet the LoadBalancer VIPs should be assigned from + SubnetName string } // GetLoadBalancerAnnotationAllowGlobalAccess returns if global access is enabled @@ -139,3 +146,11 @@ type ILBOptions struct { func GetLoadBalancerAnnotationAllowGlobalAccess(service *v1.Service) bool { return service.Annotations[ServiceAnnotationILBAllowGlobalAccess] == "true" } + +// GetLoadBalancerAnnotationSubnet returns the configured subnet to assign LoadBalancer IP from. +func GetLoadBalancerAnnotationSubnet(service *v1.Service) string { + if val, exists := service.Annotations[ServiceAnnotationILBSubnet]; exists { + return val + } + return "" +} diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer.go index 35e871d7e5..61cdcb5eca 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer.go @@ -40,18 +40,25 @@ type cidrs struct { } var ( - lbSrcRngsFlag cidrs + l4LbSrcRngsFlag cidrs + l7lbSrcRngsFlag cidrs ) func init() { var err error - // LB L7 proxies and all L3/4/7 health checkers have client addresses within these known CIDRs. - lbSrcRngsFlag.ipn, err = utilnet.ParseIPNets([]string{"130.211.0.0/22", "35.191.0.0/16", "209.85.152.0/22", "209.85.204.0/22"}...) + // L3/4 health checkers have client addresses within these known CIDRs. + l4LbSrcRngsFlag.ipn, err = utilnet.ParseIPNets([]string{"130.211.0.0/22", "35.191.0.0/16", "209.85.152.0/22", "209.85.204.0/22"}...) + if err != nil { + panic("Incorrect default GCE L3/4 source ranges") + } + // L7 health checkers have client addresses within these known CIDRs. + l7lbSrcRngsFlag.ipn, err = utilnet.ParseIPNets([]string{"130.211.0.0/22", "35.191.0.0/16"}...) if err != nil { panic("Incorrect default GCE L7 source ranges") } - flag.Var(&lbSrcRngsFlag, "cloud-provider-gce-lb-src-cidrs", "CIDRs opened in GCE firewall for LB traffic proxy & health checks") + flag.Var(&l4LbSrcRngsFlag, "cloud-provider-gce-lb-src-cidrs", "CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks") + flag.Var(&l7lbSrcRngsFlag, "cloud-provider-gce-l7lb-src-cidrs", "CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks") } // String is the method to format the flag's value, part of the flag.Value interface. @@ -82,10 +89,16 @@ func (c *cidrs) Set(value string) error { return nil } -// LoadBalancerSrcRanges contains the ranges of ips used by the GCE load balancers (l4 & L7) +// L4LoadBalancerSrcRanges contains the ranges of ips used by the L3/L4 GCE load balancers +// for proxying client requests and performing health checks. +func L4LoadBalancerSrcRanges() []string { + return l4LbSrcRngsFlag.ipn.StringSlice() +} + +// L7LoadBalancerSrcRanges contains the ranges of ips used by the GCE load balancers L7 // for proxying client requests and performing health checks. -func LoadBalancerSrcRanges() []string { - return lbSrcRngsFlag.ipn.StringSlice() +func L7LoadBalancerSrcRanges() []string { + return l7lbSrcRngsFlag.ipn.StringSlice() } // GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go index f9ff6853ac..f8a7074c02 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go @@ -876,7 +876,7 @@ func (g *Cloud) ensureHTTPHealthCheckFirewall(svc *v1.Service, serviceName, ipAd if !isNodesHealthCheck { desc = makeFirewallDescription(serviceName, ipAddress) } - sourceRanges := lbSrcRngsFlag.ipn + sourceRanges := l4LbSrcRngsFlag.ipn ports := []v1.ServicePort{{Protocol: "tcp", Port: hcPort}} fwName := MakeHealthCheckFirewallName(clusterID, hcName, isNodesHealthCheck) diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal.go index 31a8beb488..72d554756d 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal.go @@ -22,11 +22,12 @@ import ( "context" "encoding/json" "fmt" - "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" + "sort" "strconv" "strings" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" computebeta "google.golang.org/api/compute/v0.beta" compute "google.golang.org/api/compute/v1" "k8s.io/api/core/v1" @@ -48,7 +49,7 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v } nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace} - ports, protocol := getPortsAndProtocol(svc.Spec.Ports) + ports, _, protocol := getPortsAndProtocol(svc.Spec.Ports) if protocol != v1.ProtocolTCP && protocol != v1.ProtocolUDP { return nil, fmt.Errorf("Invalid protocol %s, only TCP and UDP are supported", string(protocol)) } @@ -58,6 +59,12 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v g.eventRecorder.Event(svc, v1.EventTypeWarning, "ILBOptionsIgnored", "Internal LoadBalancer options are not supported with Legacy Networks.") options = ILBOptions{} } + if !g.AlphaFeatureGate.Enabled(AlphaFeatureILBCustomSubnet) { + if options.SubnetName != "" { + g.eventRecorder.Event(svc, v1.EventTypeWarning, "ILBCustomSubnetOptionIgnored", "Internal LoadBalancer CustomSubnet options ignored as the feature gate is disabled.") + options.SubnetName = "" + } + } loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, svc) sharedBackend := shareBackendService(svc) @@ -98,23 +105,32 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v return nil, err } + subnetworkURL := g.SubnetworkURL() + if g.AlphaFeatureGate.Enabled(AlphaFeatureILBCustomSubnet) { + // If this feature is enabled, changes to subnet annotation will be + // picked up and reflected in the forwarding rule. + // Removing the annotation will set the forwarding rule to use the default subnet. + if options.SubnetName != "" { + subnetworkURL = gceSubnetworkURL("", g.networkProjectID, g.region, options.SubnetName) + } + } else { + // TODO(84885) remove this once ILBCustomSubnet goes beta. + if existingFwdRule != nil && existingFwdRule.Subnetwork != "" { + // If the ILB already exists, continue using the subnet that it's already using. + // This is to support existing ILBs that were setup using the wrong subnet - https://github.com/kubernetes/kubernetes/pull/57861 + subnetworkURL = existingFwdRule.Subnetwork + } + } // Determine IP which will be used for this LB. If no forwarding rule has been established // or specified in the Service spec, then requestedIP = "". - requestedIP := determineRequestedIP(svc, existingFwdRule) - ipToUse := requestedIP + ipToUse := ilbIPToUse(svc, existingFwdRule, subnetworkURL) - // If the ILB already exists, continue using the subnet that it's already using. - // This is to support existing ILBs that were setup using the wrong subnet. - subnetworkURL := g.SubnetworkURL() - if existingFwdRule != nil && existingFwdRule.Subnetwork != "" { - // external LBs have an empty Subnetwork field. - subnetworkURL = existingFwdRule.Subnetwork - } + klog.V(2).Infof("ensureInternalLoadBalancer(%v): Using subnet %s for LoadBalancer IP %s", loadBalancerName, options.SubnetName, ipToUse) var addrMgr *addressManager // If the network is not a legacy network, use the address manager if !g.IsLegacyNetwork() { - addrMgr = newAddressManager(g, nm.String(), g.Region(), subnetworkURL, loadBalancerName, requestedIP, cloud.SchemeInternal) + addrMgr = newAddressManager(g, nm.String(), g.Region(), subnetworkURL, loadBalancerName, ipToUse, cloud.SchemeInternal) ipToUse, err = addrMgr.HoldAddress() if err != nil { return nil, err @@ -216,7 +232,7 @@ func (g *Cloud) updateInternalLoadBalancer(clusterName, clusterID string, svc *v } // Generate the backend service name - _, protocol := getPortsAndProtocol(svc.Spec.Ports) + _, _, protocol := getPortsAndProtocol(svc.Spec.Ports) scheme := cloud.SchemeInternal loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, svc) backendServiceName := makeBackendServiceName(loadBalancerName, clusterID, shareBackendService(svc), scheme, protocol, svc.Spec.SessionAffinity) @@ -226,7 +242,7 @@ func (g *Cloud) updateInternalLoadBalancer(clusterName, clusterID string, svc *v func (g *Cloud) ensureInternalLoadBalancerDeleted(clusterName, clusterID string, svc *v1.Service) error { loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, svc) - _, protocol := getPortsAndProtocol(svc.Spec.Ports) + _, _, protocol := getPortsAndProtocol(svc.Spec.Ports) scheme := cloud.SchemeInternal sharedBackend := shareBackendService(svc) sharedHealthCheck := !servicehelpers.RequestsOnlyLocalTraffic(svc) @@ -248,14 +264,26 @@ func (g *Cloud) ensureInternalLoadBalancerDeleted(clusterName, clusterID string, return err } - klog.V(2).Infof("ensureInternalLoadBalancerDeleted(%v): deleting firewall for traffic", loadBalancerName) - if err := ignoreNotFound(g.DeleteFirewall(loadBalancerName)); err != nil { - if isForbidden(err) && g.OnXPN() { - klog.V(2).Infof("ensureInternalLoadBalancerDeleted(%v): could not delete traffic firewall on XPN cluster. Raising event.", loadBalancerName) - g.raiseFirewallChangeNeededEvent(svc, FirewallToGCloudDeleteCmd(loadBalancerName, g.NetworkProjectID())) - } else { + deleteFunc := func(fwName string) error { + if err := ignoreNotFound(g.DeleteFirewall(fwName)); err != nil { + if isForbidden(err) && g.OnXPN() { + klog.V(2).Infof("ensureInternalLoadBalancerDeleted(%v): could not delete traffic firewall on XPN cluster. Raising event.", loadBalancerName) + g.raiseFirewallChangeNeededEvent(svc, FirewallToGCloudDeleteCmd(fwName, g.NetworkProjectID())) + return nil + } return err } + return nil + } + fwName := MakeFirewallName(loadBalancerName) + klog.V(2).Infof("ensureInternalLoadBalancerDeleted(%v): deleting firewall %s for traffic", + loadBalancerName, fwName) + if err := deleteFunc(fwName); err != nil { + return err + } + klog.V(2).Infof("ensureInternalLoadBalancerDeleted(%v): deleting legacy name firewall for traffic", loadBalancerName) + if err := deleteFunc(loadBalancerName); err != nil { + return err } hcName := makeHealthCheckName(loadBalancerName, clusterID, sharedHealthCheck) @@ -317,7 +345,7 @@ func (g *Cloud) teardownInternalHealthCheckAndFirewall(svc *v1.Service, hcName s return nil } -func (g *Cloud) ensureInternalFirewall(svc *v1.Service, fwName, fwDesc string, sourceRanges []string, ports []string, protocol v1.Protocol, nodes []*v1.Node) error { +func (g *Cloud) ensureInternalFirewall(svc *v1.Service, fwName, fwDesc string, sourceRanges []string, portRanges []string, protocol v1.Protocol, nodes []*v1.Node, legacyFwName string) error { klog.V(2).Infof("ensureInternalFirewall(%v): checking existing firewall", fwName) targetTags, err := g.GetNodeTags(nodeNames(nodes)) if err != nil { @@ -328,6 +356,29 @@ func (g *Cloud) ensureInternalFirewall(svc *v1.Service, fwName, fwDesc string, s if err != nil && !isNotFound(err) { return err } + // TODO(84821) Remove legacyFwName logic after 3 releases, so there would have been atleast 2 master upgrades that would + // have triggered service sync and deletion of the legacy rules. + if legacyFwName != "" { + // Check for firewall named with the legacy naming scheme and delete if found. + legacyFirewall, err := g.GetFirewall(legacyFwName) + if err != nil && !isNotFound(err) { + return err + } + if legacyFirewall != nil && existingFirewall != nil { + // Delete the legacyFirewall rule if the new one was already created. If not, it will be deleted in the + // next sync or when the service is deleted. + defer func() { + err = g.DeleteFirewall(legacyFwName) + if err != nil { + klog.Errorf("Failed to delete legacy firewall %s for service %s/%s, err %v", + legacyFwName, svc.Namespace, svc.Name, err) + } else { + klog.V(2).Infof("Successfully deleted legacy firewall %s for service %s/%s", + legacyFwName, svc.Namespace, svc.Name) + } + }() + } + } expectedFirewall := &compute.Firewall{ Name: fwName, @@ -338,7 +389,7 @@ func (g *Cloud) ensureInternalFirewall(svc *v1.Service, fwName, fwDesc string, s Allowed: []*compute.FirewallAllowed{ { IPProtocol: strings.ToLower(string(protocol)), - Ports: ports, + Ports: portRanges, }, }, } @@ -371,20 +422,20 @@ func (g *Cloud) ensureInternalFirewall(svc *v1.Service, fwName, fwDesc string, s func (g *Cloud) ensureInternalFirewalls(loadBalancerName, ipAddress, clusterID string, nm types.NamespacedName, svc *v1.Service, healthCheckPort string, sharedHealthCheck bool, nodes []*v1.Node) error { // First firewall is for ingress traffic fwDesc := makeFirewallDescription(nm.String(), ipAddress) - ports, protocol := getPortsAndProtocol(svc.Spec.Ports) + _, portRanges, protocol := getPortsAndProtocol(svc.Spec.Ports) sourceRanges, err := servicehelpers.GetLoadBalancerSourceRanges(svc) if err != nil { return err } - err = g.ensureInternalFirewall(svc, loadBalancerName, fwDesc, sourceRanges.StringSlice(), ports, protocol, nodes) + err = g.ensureInternalFirewall(svc, MakeFirewallName(loadBalancerName), fwDesc, sourceRanges.StringSlice(), portRanges, protocol, nodes, loadBalancerName) if err != nil { return err } // Second firewall is for health checking nodes / services fwHCName := makeHealthCheckFirewallName(loadBalancerName, clusterID, sharedHealthCheck) - hcSrcRanges := LoadBalancerSrcRanges() - return g.ensureInternalFirewall(svc, fwHCName, "", hcSrcRanges, []string{healthCheckPort}, v1.ProtocolTCP, nodes) + hcSrcRanges := L4LoadBalancerSrcRanges() + return g.ensureInternalFirewall(svc, fwHCName, "", hcSrcRanges, []string{healthCheckPort}, v1.ProtocolTCP, nodes, "") } func (g *Cloud) ensureInternalHealthCheck(name string, svcName types.NamespacedName, shared bool, path string, port int32) (*compute.HealthCheck, error) { @@ -697,17 +748,62 @@ func backendSvcEqual(a, b *compute.BackendService) bool { backendsListEqual(a.Backends, b.Backends) } -func getPortsAndProtocol(svcPorts []v1.ServicePort) (ports []string, protocol v1.Protocol) { +func getPortsAndProtocol(svcPorts []v1.ServicePort) (ports []string, portRanges []string, protocol v1.Protocol) { if len(svcPorts) == 0 { - return []string{}, v1.ProtocolUDP + return []string{}, []string{}, v1.ProtocolUDP } // GCP doesn't support multiple protocols for a single load balancer protocol = svcPorts[0].Protocol + portInts := []int{} for _, p := range svcPorts { ports = append(ports, strconv.Itoa(int(p.Port))) + portInts = append(portInts, int(p.Port)) } - return ports, protocol + + return ports, getPortRanges(portInts), protocol +} + +func getPortRanges(ports []int) (ranges []string) { + if len(ports) < 1 { + return ranges + } + sort.Ints(ports) + + start := ports[0] + prev := ports[0] + for ix, current := range ports { + switch { + case current == prev: + // Loop over duplicates, except if the end of list is reached. + if ix == len(ports)-1 { + if start == current { + ranges = append(ranges, fmt.Sprintf("%d", current)) + } else { + ranges = append(ranges, fmt.Sprintf("%d-%d", start, current)) + } + } + case current == prev+1: + // continue the streak, create the range if this is the last element in the list. + if ix == len(ports)-1 { + ranges = append(ranges, fmt.Sprintf("%d-%d", start, current)) + } + default: + // current is not prev + 1, streak is broken. Construct the range and handle last element case. + if start == prev { + ranges = append(ranges, fmt.Sprintf("%d", prev)) + } else { + ranges = append(ranges, fmt.Sprintf("%d-%d", start, prev)) + } + if ix == len(ports)-1 { + ranges = append(ranges, fmt.Sprintf("%d", current)) + } + // reset start element + start = current + } + prev = current + } + return ranges } func (g *Cloud) getBackendServiceLink(name string) string { @@ -723,20 +819,27 @@ func getNameFromLink(link string) string { return fields[len(fields)-1] } -func determineRequestedIP(svc *v1.Service, fwdRule *compute.ForwardingRule) string { +// ilbIPToUse determines which IP address needs to be used in the ForwardingRule. If an IP has been +// specified by the user, that is used. If there is an existing ForwardingRule, the ip address from +// that is reused. In case a subnetwork change is requested, the existing ForwardingRule IP is ignored. +func ilbIPToUse(svc *v1.Service, fwdRule *compute.ForwardingRule, requestedSubnet string) string { if svc.Spec.LoadBalancerIP != "" { return svc.Spec.LoadBalancerIP } - - if fwdRule != nil { - return fwdRule.IPAddress + if fwdRule == nil { + return "" } - - return "" + if requestedSubnet != fwdRule.Subnetwork { + // reset ip address since subnet is being changed. + return "" + } + return fwdRule.IPAddress } func getILBOptions(svc *v1.Service) ILBOptions { - return ILBOptions{AllowGlobalAccess: GetLoadBalancerAnnotationAllowGlobalAccess(svc)} + return ILBOptions{AllowGlobalAccess: GetLoadBalancerAnnotationAllowGlobalAccess(svc), + SubnetName: GetLoadBalancerAnnotationSubnet(svc), + } } // forwardingRuleComposite is a composite type encapsulating both the GA and Beta ForwardingRules. @@ -765,7 +868,8 @@ func (f *forwardingRuleComposite) Equal(other *forwardingRuleComposite) bool { f.lbScheme == other.lbScheme && equalStringSets(f.ports, other.ports) && f.backendService == other.backendService && - f.allowGlobalAccess == other.allowGlobalAccess + f.allowGlobalAccess == other.allowGlobalAccess && + f.subnetwork == other.subnetwork } // toForwardingRuleComposite converts a compute beta or GA ForwardingRule into the composite type diff --git a/vendor/k8s.io/legacy-cloud-providers/gce/gce_util.go b/vendor/k8s.io/legacy-cloud-providers/gce/gce_util.go index a871c54d5d..046c599dd4 100644 --- a/vendor/k8s.io/legacy-cloud-providers/gce/gce_util.go +++ b/vendor/k8s.io/legacy-cloud-providers/gce/gce_util.go @@ -110,7 +110,7 @@ func getProjectAndZone() (string, string, error) { } func (g *Cloud) raiseFirewallChangeNeededEvent(svc *v1.Service, cmd string) { - msg := fmt.Sprintf("Firewall change required by network admin: `%v`", cmd) + msg := fmt.Sprintf("Firewall change required by security admin: `%v`", cmd) if g.eventRecorder != nil && svc != nil { g.eventRecorder.Event(svc, v1.EventTypeNormal, "LoadBalancerManualChange", msg) } diff --git a/vendor/k8s.io/utils/net/net.go b/vendor/k8s.io/utils/net/net.go index 13449ac1c5..2690aa0c20 100644 --- a/vendor/k8s.io/utils/net/net.go +++ b/vendor/k8s.io/utils/net/net.go @@ -17,8 +17,12 @@ limitations under the License. package net import ( + "errors" "fmt" + "math" + "math/big" "net" + "strconv" ) // ParseCIDRs parses a list of cidrs and return error if any is invalid. @@ -132,3 +136,54 @@ func IsIPv6CIDR(cidr *net.IPNet) bool { ip := cidr.IP return IsIPv6(ip) } + +// ParsePort parses a string representing an IP port. If the string is not a +// valid port number, this returns an error. +func ParsePort(port string, allowZero bool) (int, error) { + portInt, err := strconv.ParseUint(port, 10, 16) + if err != nil { + return 0, err + } + if portInt == 0 && !allowZero { + return 0, errors.New("0 is not a valid port number") + } + return int(portInt), nil +} + +// BigForIP creates a big.Int based on the provided net.IP +func BigForIP(ip net.IP) *big.Int { + b := ip.To4() + if b == nil { + b = ip.To16() + } + return big.NewInt(0).SetBytes(b) +} + +// AddIPOffset adds the provided integer offset to a base big.Int representing a +// net.IP +func AddIPOffset(base *big.Int, offset int) net.IP { + return net.IP(big.NewInt(0).Add(base, big.NewInt(int64(offset))).Bytes()) +} + +// RangeSize returns the size of a range in valid addresses. +// returns the size of the subnet (or math.MaxInt64 if the range size would overflow int64) +func RangeSize(subnet *net.IPNet) int64 { + ones, bits := subnet.Mask.Size() + if bits == 32 && (bits-ones) >= 31 || bits == 128 && (bits-ones) >= 127 { + return 0 + } + // this checks that we are not overflowing an int64 + if bits-ones >= 63 { + return math.MaxInt64 + } + return int64(1) << uint(bits-ones) +} + +// GetIndexedIP returns a net.IP that is subnet.IP + index in the contiguous IP space. +func GetIndexedIP(subnet *net.IPNet, index int) (net.IP, error) { + ip := AddIPOffset(BigForIP(subnet.IP), index) + if !subnet.Contains(ip) { + return nil, fmt.Errorf("can't generate IP with index %d from subnet. subnet too small. subnet: %q", index, subnet) + } + return ip, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2be84052e4..6600e7f265 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -18,7 +18,7 @@ github.com/davecgh/go-spew/spew # github.com/emicklei/go-restful v2.9.3+incompatible => github.com/emicklei/go-restful v2.9.3+incompatible github.com/emicklei/go-restful github.com/emicklei/go-restful/log -# github.com/evanphx/json-patch v4.1.0+incompatible => github.com/evanphx/json-patch v4.1.0+incompatible +# github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550 => github.com/evanphx/json-patch v4.1.0+incompatible github.com/evanphx/json-patch # github.com/go-openapi/jsonpointer v0.19.0 github.com/go-openapi/jsonpointer @@ -48,7 +48,7 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/gofuzz v1.0.0 => github.com/google/gofuzz v1.0.0 +# github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf => github.com/google/gofuzz v1.0.0 github.com/google/gofuzz # github.com/googleapis/gnostic v0.2.0 => github.com/googleapis/gnostic v0.2.0 github.com/googleapis/gnostic/OpenAPIv2 @@ -59,7 +59,7 @@ github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/imdario/mergo v0.3.7 => github.com/imdario/mergo v0.3.7 github.com/imdario/mergo -# github.com/json-iterator/go v1.1.6 => github.com/json-iterator/go v1.1.6 +# github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be => github.com/json-iterator/go v1.1.6 github.com/json-iterator/go # github.com/kr/pretty v0.1.0 => github.com/kr/pretty v0.1.0 github.com/kr/pretty @@ -75,19 +75,19 @@ github.com/matttproud/golang_protobuf_extensions/pbutil github.com/modern-go/concurrent # github.com/modern-go/reflect2 v1.0.1 github.com/modern-go/reflect2 -# github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 => github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 +# github.com/prometheus/client_golang v1.0.0 => github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/promhttp github.com/prometheus/client_golang/prometheus/internal -# github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 => github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 +# github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f => github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.3.0 => github.com/prometheus/common v0.3.0 +# github.com/prometheus/common v0.2.0 => github.com/prometheus/common v0.3.0 github.com/prometheus/common/expfmt github.com/prometheus/common/model github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg -# github.com/prometheus/procfs v0.0.0-20190416084830-8368d24ba045 => github.com/prometheus/procfs v0.0.0-20190416084830-8368d24ba045 +# github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 => github.com/prometheus/procfs v0.0.0-20190416084830-8368d24ba045 github.com/prometheus/procfs -# github.com/spf13/pflag v1.0.3 => github.com/spf13/pflag v1.0.3 +# github.com/spf13/pflag v1.0.5 => github.com/spf13/pflag v1.0.3 github.com/spf13/pflag # go.opencensus.io v0.21.0 => go.opencensus.io v0.20.2 go.opencensus.io/plugin/ochttp @@ -106,7 +106,7 @@ go.opencensus.io/trace/internal go.opencensus.io/trace/tracestate go.opencensus.io/resource go.opencensus.io -# golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 => golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd +# golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 => golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c => golang.org/x/net v0.0.0-20190420063019-afa5a82059c6 golang.org/x/net/http2 @@ -123,7 +123,7 @@ golang.org/x/oauth2 golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f => golang.org/x/sys v0.0.0-20190422165155-953cdadca894 +# golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b => golang.org/x/sys v0.0.0-20190422165155-953cdadca894 golang.org/x/sys/unix golang.org/x/sys/windows # golang.org/x/text v0.3.2 @@ -132,7 +132,7 @@ golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm golang.org/x/text/width golang.org/x/text/transform -# golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 => golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 +# golang.org/x/time v0.0.0-20181108054448-85acf8d2951c => golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate # google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 => google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 google.golang.org/api/compute/v1 @@ -199,7 +199,7 @@ gopkg.in/gcfg.v1 gopkg.in/gcfg.v1/scanner gopkg.in/gcfg.v1/token gopkg.in/gcfg.v1/types -# gopkg.in/inf.v0 v0.9.1 => gopkg.in/inf.v0 v0.9.1 +# gopkg.in/inf.v0 v0.9.0 => gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 # gopkg.in/warnings.v0 v0.1.2 => gopkg.in/warnings.v0 v0.1.2 gopkg.in/warnings.v0 @@ -207,7 +207,7 @@ gopkg.in/warnings.v0 gopkg.in/yaml.v2 # istio.io/api v0.0.0-20190809125725-591cf32c1d0e istio.io/api/networking/v1alpha3 -# k8s.io/api v0.0.0 => k8s.io/api v0.0.0-20190620085002-8f739060a0b3 +# k8s.io/api v0.17.0 => k8s.io/api v0.0.0-20190620085002-8f739060a0b3 k8s.io/api/core/v1 k8s.io/api/networking/v1beta1 k8s.io/api/apps/v1 @@ -252,7 +252,7 @@ k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake -# k8s.io/apimachinery v0.0.0 => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 +# k8s.io/apimachinery v0.17.0 => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 k8s.io/apimachinery/pkg/util/intstr k8s.io/apimachinery/pkg/apis/meta/v1 k8s.io/apimachinery/pkg/labels @@ -297,7 +297,7 @@ k8s.io/apimachinery/third_party/forked/golang/reflect k8s.io/apimachinery/pkg/apis/meta/internalversion k8s.io/apimachinery/pkg/util/framer k8s.io/apimachinery/pkg/apis/meta/v1beta1 -# k8s.io/client-go v0.0.0 => k8s.io/client-go v0.0.0-20190620085041-d697df55dbe9 +# k8s.io/client-go v0.17.0 => k8s.io/client-go v0.0.0-20190620085041-d697df55dbe9 k8s.io/client-go/plugin/pkg/client/auth/gcp k8s.io/client-go/plugin/pkg/client/auth/oidc k8s.io/client-go/kubernetes @@ -495,27 +495,27 @@ k8s.io/client-go/listers/settings/v1alpha1 k8s.io/client-go/listers/storage/v1 k8s.io/client-go/listers/storage/v1alpha1 k8s.io/client-go/listers/storage/v1beta1 -# k8s.io/cloud-provider v0.0.0 => k8s.io/cloud-provider v0.0.0-20191114112026-556fa5a14fdf +# k8s.io/cloud-provider v0.17.0 => k8s.io/cloud-provider v0.0.0-20191114112026-556fa5a14fdf k8s.io/cloud-provider k8s.io/cloud-provider/service/helpers k8s.io/cloud-provider/volume k8s.io/cloud-provider/volume/errors k8s.io/cloud-provider/volume/helpers -# k8s.io/component-base v0.0.0 => k8s.io/component-base v0.0.0-20190620085131-4cd66be69262 +# k8s.io/component-base v0.17.0 => k8s.io/component-base v0.0.0-20190620085131-4cd66be69262 k8s.io/component-base/config k8s.io/component-base/metrics k8s.io/component-base/metrics/legacyregistry -# k8s.io/klog v0.4.0 => k8s.io/klog v0.3.0 +# k8s.io/klog v1.0.0 => k8s.io/klog v1.0.0 k8s.io/klog -# k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 +# k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 k8s.io/kube-openapi/pkg/common k8s.io/kube-openapi/pkg/util/proto # k8s.io/kubernetes v1.15.0 => k8s.io/kubernetes v1.15.0 k8s.io/kubernetes/pkg/client/leaderelectionconfig k8s.io/kubernetes/pkg/util/slice -# k8s.io/legacy-cloud-providers v0.0.0 => k8s.io/legacy-cloud-providers v0.0.0-20191114112650-ed060d80c11c +# k8s.io/legacy-cloud-providers v0.0.0 => k8s.io/legacy-cloud-providers v0.0.0-20191114112650-b5fed2ccee23 k8s.io/legacy-cloud-providers/gce -# k8s.io/utils v0.0.0-20190801114015-581e00157fb1 +# k8s.io/utils v0.0.0-20191114184206-e782cd3c129f k8s.io/utils/net k8s.io/utils/buffer k8s.io/utils/trace