Automatic merge from submit-queue (batch tested with PRs 55247, 55324, 55261, 55147, 54052). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Implement dummy device operation by netlink for ipvs proxier **What this PR does / why we need it**: Currently, we implement network interface operations, e.g. create a dummy device and delete a dummy interface via ip cmd and then collect the exist code. For example, we assume the following command: ``` ip link add kube-ipvs0 type dummy ``` returns 2 means the dummy device `kube-ipvs0` exists, see https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/proxier.go#L1529 . However, from the man page of ip command, exit status 2 just means an error was reported by the kernel, see http://man7.org/linux/man-pages/man8/ip.8.html#EXIT_STATUS. So, that's a bug. This PR implements dummy device operation by netlink for ipvs proxier so that can get ride of ip command operations. **Which issue this PR fixes**: fixes #54054 **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` /sig network /area kube-proxy /kind bug
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
/*
|
|
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 testing
|
|
|
|
//FakeNetlinkHandle mock implementation of proxy NetlinkHandle
|
|
type FakeNetlinkHandle struct {
|
|
}
|
|
|
|
//NewFakeNetlinkHandle will create a new FakeNetlinkHandle
|
|
func NewFakeNetlinkHandle() *FakeNetlinkHandle {
|
|
return &FakeNetlinkHandle{}
|
|
}
|
|
|
|
//EnsureAddressBind is a mock implementation
|
|
func (h *FakeNetlinkHandle) EnsureAddressBind(address, devName string) (exist bool, err error) {
|
|
return false, nil
|
|
}
|
|
|
|
//UnbindAddress is a mock implementation
|
|
func (h *FakeNetlinkHandle) UnbindAddress(address, devName string) error {
|
|
return nil
|
|
}
|
|
|
|
// EnsureDummyDevice is a mock implementation
|
|
func (h *FakeNetlinkHandle) EnsureDummyDevice(devName string) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
// DeleteDummyDevice is a mock implementation
|
|
func (h *FakeNetlinkHandle) DeleteDummyDevice(devName string) error {
|
|
return nil
|
|
}
|