Merge pull request #122373 from danwinship/linux-proxy

Properly build-tag the Linux kube-proxy backend code
This commit is contained in:
Kubernetes Prow Robot 2024-01-04 18:00:34 +01:00 committed by GitHub
commit c0dc42073d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 107 additions and 314 deletions

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2018 The Kubernetes Authors.

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2014 The Kubernetes Authors.

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2018 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2023 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2016 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2022 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2019 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,82 +0,0 @@
//go:build !linux
// +build !linux
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ipvs
import (
"fmt"
"net"
"k8s.io/apimachinery/pkg/util/sets"
)
// The type must match the one in proxier_test.go
type netlinkHandle struct {
isIPv6 bool
}
// NewNetLinkHandle will create an EmptyHandle
func NewNetLinkHandle(ipv6 bool) NetLinkHandle {
return &netlinkHandle{}
}
// EnsureAddressBind checks if address is bound to the interface and, if not, binds it. If the address is already bound, return true.
func (h *netlinkHandle) EnsureAddressBind(address, devName string) (exist bool, err error) {
return false, fmt.Errorf("netlink not supported for this platform")
}
// UnbindAddress unbind address from the interface
func (h *netlinkHandle) UnbindAddress(address, devName string) error {
return fmt.Errorf("netlink not supported for this platform")
}
// EnsureDummyDevice is part of interface
func (h *netlinkHandle) EnsureDummyDevice(devName string) (bool, error) {
return false, fmt.Errorf("netlink is not supported in this platform")
}
// DeleteDummyDevice is part of interface.
func (h *netlinkHandle) DeleteDummyDevice(devName string) error {
return fmt.Errorf("netlink is not supported in this platform")
}
// ListBindAddress is part of interface.
func (h *netlinkHandle) ListBindAddress(devName string) ([]string, error) {
return nil, fmt.Errorf("netlink is not supported in this platform")
}
// GetAllLocalAddresses is part of interface.
func (h *netlinkHandle) GetAllLocalAddresses() (sets.Set[string], error) {
return nil, fmt.Errorf("netlink is not supported in this platform")
}
// GetLocalAddresses is part of interface.
func (h *netlinkHandle) GetLocalAddresses(dev string) (sets.Set[string], error) {
return nil, fmt.Errorf("netlink is not supported in this platform")
}
// GetAllLocalAddressesExcept is part of interface.
func (h *netlinkHandle) GetAllLocalAddressesExcept(dev string) (sets.Set[string], error) {
return nil, fmt.Errorf("netlink is not supported in this platform")
}
// Must match the one in proxier_test.go
func (h *netlinkHandle) isValidForSet(ip net.IP) bool {
return false
}

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.
@ -489,10 +492,8 @@ func NewDualStackProxier(
initOnly bool,
) (proxy.Provider, error) {
safeIpset := newSafeIpset(ipset)
// Create an ipv4 instance of the single-stack proxier
ipv4Proxier, err := NewProxier(v1.IPv4Protocol, ipt[0], ipvs, safeIpset, sysctl,
ipv4Proxier, err := NewProxier(v1.IPv4Protocol, ipt[0], ipvs, ipset, sysctl,
exec, syncPeriod, minSyncPeriod, filterCIDRs(false, excludeCIDRs), strictARP,
tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit,
localDetectors[0], hostname, nodeIPs[v1.IPv4Protocol], recorder,
@ -501,7 +502,7 @@ func NewDualStackProxier(
return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err)
}
ipv6Proxier, err := NewProxier(v1.IPv6Protocol, ipt[1], ipvs, safeIpset, sysctl,
ipv6Proxier, err := NewProxier(v1.IPv6Protocol, ipt[1], ipvs, ipset, sysctl,
exec, syncPeriod, minSyncPeriod, filterCIDRs(true, excludeCIDRs), strictARP,
tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit,
localDetectors[1], hostname, nodeIPs[v1.IPv6Protocol], recorder,

View File

@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,104 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ipvs
import (
"sync"
"k8s.io/kubernetes/pkg/proxy/ipvs/ipset"
)
type safeIpset struct {
ipset ipset.Interface
mu sync.Mutex
}
func newSafeIpset(ipset ipset.Interface) ipset.Interface {
return &safeIpset{
ipset: ipset,
}
}
// FlushSet deletes all entries from a named set.
func (s *safeIpset) FlushSet(set string) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.FlushSet(set)
}
// DestroySet deletes a named set.
func (s *safeIpset) DestroySet(set string) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.DestroySet(set)
}
// DestroyAllSets deletes all sets.
func (s *safeIpset) DestroyAllSets() error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.DestroyAllSets()
}
// CreateSet creates a new set. It will ignore error when the set already exists if ignoreExistErr=true.
func (s *safeIpset) CreateSet(set *ipset.IPSet, ignoreExistErr bool) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.CreateSet(set, ignoreExistErr)
}
// AddEntry adds a new entry to the named set. It will ignore error when the entry already exists if ignoreExistErr=true.
func (s *safeIpset) AddEntry(entry string, set *ipset.IPSet, ignoreExistErr bool) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.AddEntry(entry, set, ignoreExistErr)
}
// DelEntry deletes one entry from the named set
func (s *safeIpset) DelEntry(entry string, set string) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.DelEntry(entry, set)
}
// Test test if an entry exists in the named set
func (s *safeIpset) TestEntry(entry string, set string) (bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.TestEntry(entry, set)
}
// ListEntries lists all the entries from a named set
func (s *safeIpset) ListEntries(set string) ([]string, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.ListEntries(set)
}
// ListSets list all set names from kernel
func (s *safeIpset) ListSets() ([]string, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.ListSets()
}
// GetVersion returns the "X.Y" version string for ipset.
func (s *safeIpset) GetVersion() (string, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.ipset.GetVersion()
}

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,79 +0,0 @@
//go:build !linux
// +build !linux
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ipvs
import (
"fmt"
"time"
)
// New returns a dummy Interface for unsupported platform.
func New() Interface {
return &runner{}
}
type runner struct {
}
func (runner *runner) Flush() error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) AddVirtualServer(*VirtualServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) UpdateVirtualServer(*VirtualServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) DeleteVirtualServer(*VirtualServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) GetVirtualServer(*VirtualServer) (*VirtualServer, error) {
return nil, fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) GetVirtualServers() ([]*VirtualServer, error) {
return nil, fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) AddRealServer(*VirtualServer, *RealServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) GetRealServers(*VirtualServer) ([]*RealServer, error) {
return nil, fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) DeleteRealServer(*VirtualServer, *RealServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) UpdateRealServer(*VirtualServer, *RealServer) error {
return fmt.Errorf("IPVS not supported for this platform")
}
func (runner *runner) ConfigureTimeouts(time.Duration, time.Duration, time.Duration) error {
return fmt.Errorf("IPVS not supported for this platform")
}
var _ = Interface(&runner{})

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2017 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2014 The Kubernetes Authors.

View File

@ -1,33 +0,0 @@
//go:build !linux
// +build !linux
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package iptables
import (
"fmt"
"os"
)
func grabIptablesLocks(lock14filePath, lock16filePath string) (iptablesLocker, error) {
return nil, fmt.Errorf("iptables unsupported on this platform")
}
func grabIptablesFileLock(f *os.File) error {
return fmt.Errorf("iptables unsupported on this platform")
}

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2014 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2018 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2022 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2022 The Kubernetes Authors.

View File

@ -1,3 +1,6 @@
//go:build linux
// +build linux
/*
Copyright 2022 The Kubernetes Authors.