mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Remove dead code from pkg/kubelet/...
This commit is contained in:
parent
90df64b75b
commit
3f510c69f6
@ -79,6 +79,8 @@ func allPrimitiveFieldPaths(t *testing.T, tp reflect.Type, path *field.Path) set
|
|||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//lint:file-ignore U1000 Ignore dummy types, used by tests.
|
||||||
|
|
||||||
// dummy helper types
|
// dummy helper types
|
||||||
type foo struct {
|
type foo struct {
|
||||||
foo int
|
foo int
|
||||||
|
@ -110,7 +110,6 @@ type containerManagerImpl struct {
|
|||||||
status Status
|
status Status
|
||||||
// External containers being managed.
|
// External containers being managed.
|
||||||
systemContainers []*systemContainer
|
systemContainers []*systemContainer
|
||||||
qosContainers QOSContainersInfo
|
|
||||||
// Tasks that are run periodically
|
// Tasks that are run periodically
|
||||||
periodicTasks []func()
|
periodicTasks []func()
|
||||||
// Holds all the mounted cgroup subsystems
|
// Holds all the mounted cgroup subsystems
|
||||||
|
@ -52,11 +52,8 @@ type staticPolicyMultiContainerTest struct {
|
|||||||
stAssignments state.ContainerCPUAssignments
|
stAssignments state.ContainerCPUAssignments
|
||||||
stDefaultCPUSet cpuset.CPUSet
|
stDefaultCPUSet cpuset.CPUSet
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
expErr error
|
|
||||||
expCPUAlloc bool
|
|
||||||
expInitCSets []cpuset.CPUSet
|
expInitCSets []cpuset.CPUSet
|
||||||
expCSets []cpuset.CPUSet
|
expCSets []cpuset.CPUSet
|
||||||
expPanic bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStaticPolicyName(t *testing.T) {
|
func TestStaticPolicyName(t *testing.T) {
|
||||||
|
@ -49,7 +49,6 @@ type QOSContainerManager interface {
|
|||||||
|
|
||||||
type qosContainerManagerImpl struct {
|
type qosContainerManagerImpl struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
nodeInfo *v1.Node
|
|
||||||
qosContainersInfo QOSContainersInfo
|
qosContainersInfo QOSContainersInfo
|
||||||
subsystems *CgroupSubsystems
|
subsystems *CgroupSubsystems
|
||||||
cgroupManager CgroupManager
|
cgroupManager CgroupManager
|
||||||
|
@ -130,11 +130,10 @@ func TestWatchFileChanged(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
lock *sync.Mutex
|
lock *sync.Mutex
|
||||||
desc string
|
desc string
|
||||||
linkedFile string
|
pod runtime.Object
|
||||||
pod runtime.Object
|
expected kubetypes.PodUpdate
|
||||||
expected kubetypes.PodUpdate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestCases(hostname types.NodeName) []*testCase {
|
func getTestCases(hostname types.NodeName) []*testCase {
|
||||||
|
@ -64,10 +64,6 @@ const (
|
|||||||
// ebtables Chain to store dedup rules
|
// ebtables Chain to store dedup rules
|
||||||
dedupChain = utilebtables.Chain("KUBE-DEDUP")
|
dedupChain = utilebtables.Chain("KUBE-DEDUP")
|
||||||
|
|
||||||
// defaultIPAMDir is the default location for the checkpoint files stored by host-local ipam
|
|
||||||
// https://github.com/containernetworking/cni/tree/master/plugins/ipam/host-local#backends
|
|
||||||
defaultIPAMDir = "/var/lib/cni/networks"
|
|
||||||
|
|
||||||
zeroCIDRv6 = "::/0"
|
zeroCIDRv6 = "::/0"
|
||||||
zeroCIDRv4 = "0.0.0.0/0"
|
zeroCIDRv4 = "0.0.0.0/0"
|
||||||
|
|
||||||
|
@ -159,11 +159,6 @@ func (kl *Kubelet) getPodResourcesDir() string {
|
|||||||
return filepath.Join(kl.getRootDir(), config.DefaultKubeletPodResourcesDirName)
|
return filepath.Join(kl.getRootDir(), config.DefaultKubeletPodResourcesDirName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPluginsDirSELinuxLabel returns the selinux label to be applied on plugin directories
|
|
||||||
func (kl *Kubelet) getPluginsDirSELinuxLabel() string {
|
|
||||||
return config.KubeletPluginsDirSELinuxLabel
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPods returns all pods bound to the kubelet and their spec, and the mirror
|
// GetPods returns all pods bound to the kubelet and their spec, and the mirror
|
||||||
// pods.
|
// pods.
|
||||||
func (kl *Kubelet) GetPods() []*v1.Pod {
|
func (kl *Kubelet) GetPods() []*v1.Pod {
|
||||||
|
@ -160,15 +160,6 @@ func (lcm *localCM) GetCapacity() v1.ResourceList {
|
|||||||
return lcm.capacity
|
return lcm.capacity
|
||||||
}
|
}
|
||||||
|
|
||||||
// sortableNodeAddress is a type for sorting []v1.NodeAddress
|
|
||||||
type sortableNodeAddress []v1.NodeAddress
|
|
||||||
|
|
||||||
func (s sortableNodeAddress) Len() int { return len(s) }
|
|
||||||
func (s sortableNodeAddress) Less(i, j int) bool {
|
|
||||||
return (string(s[i].Type) + s[i].Address) < (string(s[j].Type) + s[j].Address)
|
|
||||||
}
|
|
||||||
func (s sortableNodeAddress) Swap(i, j int) { s[j], s[i] = s[i], s[j] }
|
|
||||||
|
|
||||||
func TestUpdateNewNodeStatus(t *testing.T) {
|
func TestUpdateNewNodeStatus(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
|
@ -22,8 +22,6 @@ import (
|
|||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const configMapConfigKey = "kubelet"
|
|
||||||
|
|
||||||
// configMapPayload implements Payload, backed by a v1/ConfigMap config source object
|
// configMapPayload implements Payload, backed by a v1/ConfigMap config source object
|
||||||
type configMapPayload struct {
|
type configMapPayload struct {
|
||||||
cm *apiv1.ConfigMap
|
cm *apiv1.ConfigMap
|
||||||
|
@ -49,8 +49,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
// timeFormat is the time format used in the log.
|
// timeFormat is the time format used in the log.
|
||||||
timeFormat = time.RFC3339Nano
|
timeFormat = time.RFC3339Nano
|
||||||
// blockSize is the block size used in tail.
|
|
||||||
blockSize = 1024
|
|
||||||
|
|
||||||
// stateCheckPeriod is the period to check container state while following
|
// stateCheckPeriod is the period to check container state while following
|
||||||
// the container log. Kubelet should not keep following the log when the
|
// the container log. Kubelet should not keep following the log when the
|
||||||
|
@ -26,9 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
quantity = *resource.NewQuantity(1, resource.DecimalSI)
|
quantity = *resource.NewQuantity(1, resource.DecimalSI)
|
||||||
extendedResourceName1 = "example.com/er1"
|
|
||||||
extendedResourceName2 = "example.com/er2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRemoveMissingExtendedResources(t *testing.T) {
|
func TestRemoveMissingExtendedResources(t *testing.T) {
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pluginNameNotAvailable = "N/A"
|
|
||||||
// Metric keys for Plugin Manager.
|
// Metric keys for Plugin Manager.
|
||||||
pluginManagerTotalPlugins = "plugin_manager_total_plugins"
|
pluginManagerTotalPlugins = "plugin_manager_total_plugins"
|
||||||
)
|
)
|
||||||
|
@ -31,27 +31,15 @@ import (
|
|||||||
pluginwatcherapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1"
|
pluginwatcherapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1"
|
||||||
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1"
|
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/pluginwatcher"
|
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/pluginwatcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
testHostname = "test-hostname"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
socketDir string
|
socketDir string
|
||||||
deprecatedSocketDir string
|
deprecatedSocketDir string
|
||||||
supportedVersions = []string{"v1beta1", "v1beta2"}
|
supportedVersions = []string{"v1beta1", "v1beta2"}
|
||||||
)
|
)
|
||||||
|
|
||||||
// fake cache.PluginHandler
|
|
||||||
type PluginHandler interface {
|
|
||||||
ValidatePlugin(pluginName string, endpoint string, versions []string, foundInDeprecatedDir bool) error
|
|
||||||
RegisterPlugin(pluginName, endpoint string, versions []string) error
|
|
||||||
DeRegisterPlugin(pluginName string)
|
|
||||||
}
|
|
||||||
|
|
||||||
type fakePluginHandler struct {
|
type fakePluginHandler struct {
|
||||||
validatePluginCalled bool
|
validatePluginCalled bool
|
||||||
registerPluginCalled bool
|
registerPluginCalled bool
|
||||||
@ -113,20 +101,6 @@ func cleanup(t *testing.T) {
|
|||||||
os.MkdirAll(deprecatedSocketDir, 0755)
|
os.MkdirAll(deprecatedSocketDir, 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWatcher(
|
|
||||||
t *testing.T, testDeprecatedDir bool,
|
|
||||||
desiredStateOfWorldCache cache.DesiredStateOfWorld) *pluginwatcher.Watcher {
|
|
||||||
|
|
||||||
depSocketDir := ""
|
|
||||||
if testDeprecatedDir {
|
|
||||||
depSocketDir = deprecatedSocketDir
|
|
||||||
}
|
|
||||||
w := pluginwatcher.NewWatcher(socketDir, depSocketDir, desiredStateOfWorldCache)
|
|
||||||
require.NoError(t, w.Start(wait.NeverStop))
|
|
||||||
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
|
|
||||||
func waitForRegistration(t *testing.T, fakePluginHandler *fakePluginHandler) {
|
func waitForRegistration(t *testing.T, fakePluginHandler *fakePluginHandler) {
|
||||||
err := retryWithExponentialBackOff(
|
err := retryWithExponentialBackOff(
|
||||||
time.Duration(500*time.Millisecond),
|
time.Duration(500*time.Millisecond),
|
||||||
|
@ -39,8 +39,7 @@ type exampleHandler struct {
|
|||||||
|
|
||||||
eventChans map[string]chan examplePluginEvent // map[pluginName]eventChan
|
eventChans map[string]chan examplePluginEvent // map[pluginName]eventChan
|
||||||
|
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
count int
|
|
||||||
|
|
||||||
permitDeprecatedDir bool
|
permitDeprecatedDir bool
|
||||||
}
|
}
|
||||||
|
@ -287,27 +287,6 @@ func TestPluginRegistrationAtKubeletStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForPluginRegistrationStatus(t *testing.T, statusChan chan registerapi.RegistrationStatus) bool {
|
|
||||||
select {
|
|
||||||
case status := <-statusChan:
|
|
||||||
return status.PluginRegistered
|
|
||||||
case <-time.After(wait.ForeverTestTimeout):
|
|
||||||
t.Fatalf("Timed out while waiting for registration status")
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func waitForEvent(t *testing.T, expected examplePluginEvent, eventChan chan examplePluginEvent) bool {
|
|
||||||
select {
|
|
||||||
case event := <-eventChan:
|
|
||||||
return event == expected
|
|
||||||
case <-time.After(wait.ForeverTestTimeout):
|
|
||||||
t.Fatalf("Timed out while waiting for registration status %v", expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func newWatcher(t *testing.T, testDeprecatedDir bool, desiredStateOfWorldCache cache.DesiredStateOfWorld, stopCh <-chan struct{}) *Watcher {
|
func newWatcher(t *testing.T, testDeprecatedDir bool, desiredStateOfWorldCache cache.DesiredStateOfWorld, stopCh <-chan struct{}) *Watcher {
|
||||||
depSocketDir := ""
|
depSocketDir := ""
|
||||||
if testDeprecatedDir {
|
if testDeprecatedDir {
|
||||||
|
@ -115,9 +115,7 @@ func retryWithExponentialBackOff(initialDuration time.Duration, fn wait.Conditio
|
|||||||
return wait.ExponentialBackoff(backoff, fn)
|
return wait.ExponentialBackoff(backoff, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DummyImpl struct {
|
type DummyImpl struct{}
|
||||||
dummy string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDummyImpl() *DummyImpl {
|
func NewDummyImpl() *DummyImpl {
|
||||||
return &DummyImpl{}
|
return &DummyImpl{}
|
||||||
|
@ -661,9 +661,7 @@ func getPortForwardRequestParams(req *restful.Request) portForwardRequestParams
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type responder struct {
|
type responder struct{}
|
||||||
errorMessage string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *responder) Error(w http.ResponseWriter, req *http.Request, err error) {
|
func (r *responder) Error(w http.ResponseWriter, req *http.Request, err error) {
|
||||||
klog.Errorf("Error while proxying request: %v", err)
|
klog.Errorf("Error while proxying request: %v", err)
|
||||||
|
@ -288,13 +288,11 @@ func (f *fakeAuth) Authorize(a authorizer.Attributes) (authorized authorizer.Dec
|
|||||||
}
|
}
|
||||||
|
|
||||||
type serverTestFramework struct {
|
type serverTestFramework struct {
|
||||||
serverUnderTest *Server
|
serverUnderTest *Server
|
||||||
fakeKubelet *fakeKubelet
|
fakeKubelet *fakeKubelet
|
||||||
fakeAuth *fakeAuth
|
fakeAuth *fakeAuth
|
||||||
testHTTPServer *httptest.Server
|
testHTTPServer *httptest.Server
|
||||||
fakeRuntime *fakeRuntime
|
criHandler *utiltesting.FakeHandler
|
||||||
testStreamingHTTPServer *httptest.Server
|
|
||||||
criHandler *utiltesting.FakeHandler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newServerTest() *serverTestFramework {
|
func newServerTest() *serverTestFramework {
|
||||||
@ -676,11 +674,6 @@ func assertHealthFails(t *testing.T, httpURL string, expectedErrorCode int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type authTestCase struct {
|
|
||||||
Method string
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure all registered handlers & services have an associated testcase.
|
// Ensure all registered handlers & services have an associated testcase.
|
||||||
func TestAuthzCoverage(t *testing.T) {
|
func TestAuthzCoverage(t *testing.T) {
|
||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
|
@ -28,6 +28,3 @@ func dirExists(path string) bool {
|
|||||||
}
|
}
|
||||||
return s.IsDir()
|
return s.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
// empty is a placeholder type used to implement a set
|
|
||||||
type empty struct{}
|
|
||||||
|
@ -125,7 +125,6 @@ type reconciler struct {
|
|||||||
kubeClient clientset.Interface
|
kubeClient clientset.Interface
|
||||||
controllerAttachDetachEnabled bool
|
controllerAttachDetachEnabled bool
|
||||||
loopSleepDuration time.Duration
|
loopSleepDuration time.Duration
|
||||||
syncDuration time.Duration
|
|
||||||
waitForAttachTimeout time.Duration
|
waitForAttachTimeout time.Duration
|
||||||
nodeName types.NodeName
|
nodeName types.NodeName
|
||||||
desiredStateOfWorld cache.DesiredStateOfWorld
|
desiredStateOfWorld cache.DesiredStateOfWorld
|
||||||
@ -355,7 +354,6 @@ type reconstructedVolume struct {
|
|||||||
attachablePlugin volumepkg.AttachableVolumePlugin
|
attachablePlugin volumepkg.AttachableVolumePlugin
|
||||||
volumeGidValue string
|
volumeGidValue string
|
||||||
devicePath string
|
devicePath string
|
||||||
reportedInUse bool
|
|
||||||
mounter volumepkg.Mounter
|
mounter volumepkg.Mounter
|
||||||
blockVolumeMapper volumepkg.BlockVolumeMapper
|
blockVolumeMapper volumepkg.BlockVolumeMapper
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user