aboutsummaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/util
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-12 12:19:22 +0200
committerGitHub <noreply@github.com>2021-04-12 12:19:22 +0200
commit0ee1da50f5e221383c236ccee258cb7592ccabd6 (patch)
tree08b3798ab08a621920eff4d1f6a3a5f940d3a944 /vendor/k8s.io/apimachinery/pkg/util
parent669311d8d8a8881571ccc81ce48b9202b15b9def (diff)
parent14375f35ee00c16327edcd0f5883cc66810fc7db (diff)
downloadpodman-0ee1da50f5e221383c236ccee258cb7592ccabd6.tar.gz
podman-0ee1da50f5e221383c236ccee258cb7592ccabd6.tar.bz2
podman-0ee1da50f5e221383c236ccee258cb7592ccabd6.zip
Merge pull request #9981 from containers/dependabot/go_modules/k8s.io/api-0.21.0
Bump k8s.io/api from 0.20.5 to 0.21.0
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/util')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go5
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/http.go4
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/interface.go46
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/validation/field/path.go23
4 files changed, 70 insertions, 8 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
index ec1cb70f2..a4792034a 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
@@ -268,10 +268,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
if err != nil {
return err
}
- if skippy < 0 {
- return ErrInvalidLengthGenerated
- }
- if (iNdEx + skippy) < 0 {
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenerated
}
if (iNdEx + skippy) > l {
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/http.go b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
index ba63d02df..ce69b8054 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/http.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
@@ -131,7 +131,7 @@ func SetTransportDefaults(t *http.Transport) *http.Transport {
t = SetOldTransportDefaults(t)
// Allow clients to disable http2 if needed.
if s := os.Getenv("DISABLE_HTTP2"); len(s) > 0 {
- klog.Infof("HTTP2 has been explicitly disabled")
+ klog.Info("HTTP2 has been explicitly disabled")
} else if allowsHTTP2(t) {
if err := configureHTTP2Transport(t); err != nil {
klog.Warningf("Transport failed http2 configuration: %v", err)
@@ -693,7 +693,7 @@ func parseQuotedString(quotedString string) (string, string, error) {
var remainder string
escaping := false
closedQuote := false
- result := &bytes.Buffer{}
+ result := &strings.Builder{}
loop:
for i := 0; i < len(quotedString); i++ {
b := quotedString[i]
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/interface.go b/vendor/k8s.io/apimachinery/pkg/util/net/interface.go
index 204e223ca..9adf4cfe4 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/interface.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/interface.go
@@ -266,6 +266,36 @@ func getIPFromInterface(intfName string, forFamily AddressFamily, nw networkInte
return nil, nil
}
+// getIPFromLoopbackInterface gets the IPs on a loopback interface and returns a global unicast address, if any.
+// The loopback interface must be up, the IP must in the family requested, and the IP must be a global unicast address.
+func getIPFromLoopbackInterface(forFamily AddressFamily, nw networkInterfacer) (net.IP, error) {
+ intfs, err := nw.Interfaces()
+ if err != nil {
+ return nil, err
+ }
+ for _, intf := range intfs {
+ if !isInterfaceUp(&intf) {
+ continue
+ }
+ if intf.Flags&(net.FlagLoopback) != 0 {
+ addrs, err := nw.Addrs(&intf)
+ if err != nil {
+ return nil, err
+ }
+ klog.V(4).Infof("Interface %q has %d addresses :%v.", intf.Name, len(addrs), addrs)
+ matchingIP, err := getMatchingGlobalIP(addrs, forFamily)
+ if err != nil {
+ return nil, err
+ }
+ if matchingIP != nil {
+ klog.V(4).Infof("Found valid IPv%d address %v for interface %q.", int(forFamily), matchingIP, intf.Name)
+ return matchingIP, nil
+ }
+ }
+ }
+ return nil, nil
+}
+
// memberOf tells if the IP is of the desired family. Used for checking interface addresses.
func memberOf(ip net.IP, family AddressFamily) bool {
if ip.To4() != nil {
@@ -393,8 +423,9 @@ func getAllDefaultRoutes() ([]Route, error) {
}
// chooseHostInterfaceFromRoute cycles through each default route provided, looking for a
-// global IP address from the interface for the route. addressFamilies determines whether it
-// prefers IPv4 or IPv6
+// global IP address from the interface for the route. If there are routes but no global
+// address is obtained from the interfaces, it checks if the loopback interface has a global address.
+// addressFamilies determines whether it prefers IPv4 or IPv6
func chooseHostInterfaceFromRoute(routes []Route, nw networkInterfacer, addressFamilies AddressFamilyPreference) (net.IP, error) {
for _, family := range addressFamilies {
klog.V(4).Infof("Looking for default routes with IPv%d addresses", uint(family))
@@ -411,6 +442,17 @@ func chooseHostInterfaceFromRoute(routes []Route, nw networkInterfacer, addressF
klog.V(4).Infof("Found active IP %v ", finalIP)
return finalIP, nil
}
+ // In case of network setups where default routes are present, but network
+ // interfaces use only link-local addresses (e.g. as described in RFC5549).
+ // the global IP is assigned to the loopback interface, and we should use it
+ loopbackIP, err := getIPFromLoopbackInterface(family, nw)
+ if err != nil {
+ return nil, err
+ }
+ if loopbackIP != nil {
+ klog.V(4).Infof("Found active IP %v on Loopback interface", loopbackIP)
+ return loopbackIP, nil
+ }
}
}
klog.V(4).Infof("No active IP found by looking at default routes")
diff --git a/vendor/k8s.io/apimachinery/pkg/util/validation/field/path.go b/vendor/k8s.io/apimachinery/pkg/util/validation/field/path.go
index f9be7ac33..daccb0589 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/validation/field/path.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/validation/field/path.go
@@ -22,6 +22,29 @@ import (
"strconv"
)
+type pathOptions struct {
+ path *Path
+}
+
+// PathOption modifies a pathOptions
+type PathOption func(o *pathOptions)
+
+// WithPath generates a PathOption
+func WithPath(p *Path) PathOption {
+ return func(o *pathOptions) {
+ o.path = p
+ }
+}
+
+// ToPath produces *Path from a set of PathOption
+func ToPath(opts ...PathOption) *Path {
+ c := &pathOptions{}
+ for _, opt := range opts {
+ opt(c)
+ }
+ return c.path
+}
+
// Path represents the path from some root to a particular field.
type Path struct {
name string // the name of this field or "" if this is an index