mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +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
|
||||
}
|
||||
|
||||
//lint:file-ignore U1000 Ignore dummy types, used by tests.
|
||||
|
||||
// dummy helper types
|
||||
type foo struct {
|
||||
foo int
|
||||
|
@ -110,7 +110,6 @@ type containerManagerImpl struct {
|
||||
status Status
|
||||
// External containers being managed.
|
||||
systemContainers []*systemContainer
|
||||
qosContainers QOSContainersInfo
|
||||
// Tasks that are run periodically
|
||||
periodicTasks []func()
|
||||
// Holds all the mounted cgroup subsystems
|
||||
|
@ -52,11 +52,8 @@ type staticPolicyMultiContainerTest struct {
|
||||
stAssignments state.ContainerCPUAssignments
|
||||
stDefaultCPUSet cpuset.CPUSet
|
||||
pod *v1.Pod
|
||||
expErr error
|
||||
expCPUAlloc bool
|
||||
expInitCSets []cpuset.CPUSet
|
||||
expCSets []cpuset.CPUSet
|
||||
expPanic bool
|
||||
}
|
||||
|
||||
func TestStaticPolicyName(t *testing.T) {
|
||||
|
@ -49,7 +49,6 @@ type QOSContainerManager interface {
|
||||
|
||||
type qosContainerManagerImpl struct {
|
||||
sync.Mutex
|
||||
nodeInfo *v1.Node
|
||||
qosContainersInfo QOSContainersInfo
|
||||
subsystems *CgroupSubsystems
|
||||
cgroupManager CgroupManager
|
||||
|
@ -130,11 +130,10 @@ func TestWatchFileChanged(t *testing.T) {
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
lock *sync.Mutex
|
||||
desc string
|
||||
linkedFile string
|
||||
pod runtime.Object
|
||||
expected kubetypes.PodUpdate
|
||||
lock *sync.Mutex
|
||||
desc string
|
||||
pod runtime.Object
|
||||
expected kubetypes.PodUpdate
|
||||
}
|
||||
|
||||
func getTestCases(hostname types.NodeName) []*testCase {
|
||||
|
@ -64,10 +64,6 @@ const (
|
||||
// ebtables Chain to store dedup rules
|
||||
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"
|
||||
zeroCIDRv4 = "0.0.0.0/0"
|
||||
|
||||
|
@ -159,11 +159,6 @@ func (kl *Kubelet) getPodResourcesDir() string {
|
||||
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
|
||||
// pods.
|
||||
func (kl *Kubelet) GetPods() []*v1.Pod {
|
||||
|
@ -160,15 +160,6 @@ func (lcm *localCM) GetCapacity() v1.ResourceList {
|
||||
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) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
|
@ -22,8 +22,6 @@ import (
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const configMapConfigKey = "kubelet"
|
||||
|
||||
// configMapPayload implements Payload, backed by a v1/ConfigMap config source object
|
||||
type configMapPayload struct {
|
||||
cm *apiv1.ConfigMap
|
||||
|
@ -49,8 +49,6 @@ import (
|
||||
const (
|
||||
// timeFormat is the time format used in the log.
|
||||
timeFormat = time.RFC3339Nano
|
||||
// blockSize is the block size used in tail.
|
||||
blockSize = 1024
|
||||
|
||||
// stateCheckPeriod is the period to check container state while following
|
||||
// the container log. Kubelet should not keep following the log when the
|
||||
|
@ -26,9 +26,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
quantity = *resource.NewQuantity(1, resource.DecimalSI)
|
||||
extendedResourceName1 = "example.com/er1"
|
||||
extendedResourceName2 = "example.com/er2"
|
||||
quantity = *resource.NewQuantity(1, resource.DecimalSI)
|
||||
)
|
||||
|
||||
func TestRemoveMissingExtendedResources(t *testing.T) {
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
pluginNameNotAvailable = "N/A"
|
||||
// Metric keys for Plugin Manager.
|
||||
pluginManagerTotalPlugins = "plugin_manager_total_plugins"
|
||||
)
|
||||
|
@ -31,27 +31,15 @@ import (
|
||||
pluginwatcherapi "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/pluginmanager/cache"
|
||||
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/pluginwatcher"
|
||||
)
|
||||
|
||||
const (
|
||||
testHostname = "test-hostname"
|
||||
)
|
||||
|
||||
var (
|
||||
socketDir string
|
||||
deprecatedSocketDir string
|
||||
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 {
|
||||
validatePluginCalled bool
|
||||
registerPluginCalled bool
|
||||
@ -113,20 +101,6 @@ func cleanup(t *testing.T) {
|
||||
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) {
|
||||
err := retryWithExponentialBackOff(
|
||||
time.Duration(500*time.Millisecond),
|
||||
|
@ -39,8 +39,7 @@ type exampleHandler struct {
|
||||
|
||||
eventChans map[string]chan examplePluginEvent // map[pluginName]eventChan
|
||||
|
||||
m sync.Mutex
|
||||
count int
|
||||
m sync.Mutex
|
||||
|
||||
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 {
|
||||
depSocketDir := ""
|
||||
if testDeprecatedDir {
|
||||
|
@ -115,9 +115,7 @@ func retryWithExponentialBackOff(initialDuration time.Duration, fn wait.Conditio
|
||||
return wait.ExponentialBackoff(backoff, fn)
|
||||
}
|
||||
|
||||
type DummyImpl struct {
|
||||
dummy string
|
||||
}
|
||||
type DummyImpl struct{}
|
||||
|
||||
func NewDummyImpl() *DummyImpl {
|
||||
return &DummyImpl{}
|
||||
|
@ -661,9 +661,7 @@ func getPortForwardRequestParams(req *restful.Request) portForwardRequestParams
|
||||
}
|
||||
}
|
||||
|
||||
type responder struct {
|
||||
errorMessage string
|
||||
}
|
||||
type responder struct{}
|
||||
|
||||
func (r *responder) Error(w http.ResponseWriter, req *http.Request, err error) {
|
||||
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 {
|
||||
serverUnderTest *Server
|
||||
fakeKubelet *fakeKubelet
|
||||
fakeAuth *fakeAuth
|
||||
testHTTPServer *httptest.Server
|
||||
fakeRuntime *fakeRuntime
|
||||
testStreamingHTTPServer *httptest.Server
|
||||
criHandler *utiltesting.FakeHandler
|
||||
serverUnderTest *Server
|
||||
fakeKubelet *fakeKubelet
|
||||
fakeAuth *fakeAuth
|
||||
testHTTPServer *httptest.Server
|
||||
criHandler *utiltesting.FakeHandler
|
||||
}
|
||||
|
||||
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.
|
||||
func TestAuthzCoverage(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
|
@ -28,6 +28,3 @@ func dirExists(path string) bool {
|
||||
}
|
||||
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
|
||||
controllerAttachDetachEnabled bool
|
||||
loopSleepDuration time.Duration
|
||||
syncDuration time.Duration
|
||||
waitForAttachTimeout time.Duration
|
||||
nodeName types.NodeName
|
||||
desiredStateOfWorld cache.DesiredStateOfWorld
|
||||
@ -355,7 +354,6 @@ type reconstructedVolume struct {
|
||||
attachablePlugin volumepkg.AttachableVolumePlugin
|
||||
volumeGidValue string
|
||||
devicePath string
|
||||
reportedInUse bool
|
||||
mounter volumepkg.Mounter
|
||||
blockVolumeMapper volumepkg.BlockVolumeMapper
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user