Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
4b216f7c
Commit
4b216f7c
authored
Nov 24, 2017
by
Rohit Agarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant code in container manager.
- Reuse stub implementations from unsupported implementations. - Delete test file that didn't contain any tests.
parent
e4f01051
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
207 deletions
+5
-207
BUILD
pkg/kubelet/cm/BUILD
+3
-6
container_manager_unsupported.go
pkg/kubelet/cm/container_manager_unsupported.go
+1
-56
container_manager_unsupported_test.go
pkg/kubelet/cm/container_manager_unsupported_test.go
+0
-116
pod_container_manager_unsupported.go
pkg/kubelet/cm/pod_container_manager_unsupported.go
+1
-29
No files found.
pkg/kubelet/cm/BUILD
View file @
4b216f7c
...
...
@@ -77,9 +77,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = [
"container_manager_unsupported_test.go",
] + select({
srcs = select({
"@io_bazel_rules_go//go/platform:linux_amd64": [
"cgroup_manager_linux_test.go",
"cgroup_manager_test.go",
...
...
@@ -91,11 +89,10 @@ go_test(
}),
importpath = "k8s.io/kubernetes/pkg/kubelet/cm",
library = ":go_default_library",
deps = [
"//pkg/util/mount:go_default_library",
] + select({
deps = select({
"@io_bazel_rules_go//go/platform:linux_amd64": [
"//pkg/kubelet/eviction/api:go_default_library",
"//pkg/util/mount:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
...
pkg/kubelet/cm/container_manager_unsupported.go
View file @
4b216f7c
...
...
@@ -25,16 +25,13 @@ import (
"k8s.io/client-go/tools/record"
internalapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri"
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager"
"k8s.io/kubernetes/pkg/kubelet/config"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
"k8s.io/kubernetes/pkg/kubelet/status"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
)
type
unsupportedContainerManager
struct
{
containerManagerStub
}
var
_
ContainerManager
=
&
unsupportedContainerManager
{}
...
...
@@ -43,58 +40,6 @@ func (unsupportedContainerManager) Start(_ *v1.Node, _ ActivePodsFunc, _ config.
return
fmt
.
Errorf
(
"Container Manager is unsupported in this build"
)
}
func
(
unsupportedContainerManager
)
SystemCgroupsLimit
()
v1
.
ResourceList
{
return
v1
.
ResourceList
{}
}
func
(
unsupportedContainerManager
)
GetNodeConfig
()
NodeConfig
{
return
NodeConfig
{}
}
func
(
unsupportedContainerManager
)
GetMountedSubsystems
()
*
CgroupSubsystems
{
return
&
CgroupSubsystems
{}
}
func
(
unsupportedContainerManager
)
GetQOSContainersInfo
()
QOSContainersInfo
{
return
QOSContainersInfo
{}
}
func
(
unsupportedContainerManager
)
UpdateQOSCgroups
()
error
{
return
nil
}
func
(
cm
*
unsupportedContainerManager
)
Status
()
Status
{
return
Status
{}
}
func
(
cm
*
unsupportedContainerManager
)
GetNodeAllocatableReservation
()
v1
.
ResourceList
{
return
nil
}
func
(
cm
*
unsupportedContainerManager
)
GetCapacity
()
v1
.
ResourceList
{
return
nil
}
func
(
cm
*
unsupportedContainerManager
)
GetDevicePluginResourceCapacity
()
(
v1
.
ResourceList
,
[]
string
)
{
return
nil
,
[]
string
{}
}
func
(
cm
*
unsupportedContainerManager
)
NewPodContainerManager
()
PodContainerManager
{
return
&
unsupportedPodContainerManager
{}
}
func
(
cm
*
unsupportedContainerManager
)
GetResources
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
)
(
*
kubecontainer
.
RunContainerOptions
,
error
)
{
return
&
kubecontainer
.
RunContainerOptions
{},
nil
}
func
(
cm
*
unsupportedContainerManager
)
UpdatePluginResources
(
*
schedulercache
.
NodeInfo
,
*
lifecycle
.
PodAdmitAttributes
)
error
{
return
nil
}
func
(
cm
*
unsupportedContainerManager
)
InternalContainerLifecycle
()
InternalContainerLifecycle
{
return
&
internalContainerLifecycleImpl
{
cpumanager
.
NewFakeManager
()}
}
func
NewContainerManager
(
_
mount
.
Interface
,
_
cadvisor
.
Interface
,
_
NodeConfig
,
failSwapOn
bool
,
devicePluginEnabled
bool
,
recorder
record
.
EventRecorder
)
(
ContainerManager
,
error
)
{
return
&
unsupportedContainerManager
{},
nil
}
pkg/kubelet/cm/container_manager_unsupported_test.go
deleted
100644 → 0
View file @
e4f01051
// +build !linux,!windows
/*
Copyright 2015 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
cm
import
(
"fmt"
"k8s.io/kubernetes/pkg/util/mount"
)
type
fakeMountInterface
struct
{
mountPoints
[]
mount
.
MountPoint
}
func
(
mi
*
fakeMountInterface
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
return
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
Unmount
(
target
string
)
error
{
return
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
List
()
([]
mount
.
MountPoint
,
error
)
{
return
mi
.
mountPoints
,
nil
}
func
(
mi
*
fakeMountInterface
)
IsMountPointMatch
(
mp
mount
.
MountPoint
,
dir
string
)
bool
{
return
(
mp
.
Path
==
dir
)
}
func
(
mi
*
fakeMountInterface
)
IsNotMountPoint
(
dir
string
)
(
bool
,
error
)
{
return
false
,
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
GetDeviceNameFromMount
(
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
mi
*
fakeMountInterface
)
DeviceOpened
(
pathname
string
)
(
bool
,
error
)
{
for
_
,
mp
:=
range
mi
.
mountPoints
{
if
mp
.
Device
==
pathname
{
return
true
,
nil
}
}
return
false
,
nil
}
func
(
mi
*
fakeMountInterface
)
PathIsDevice
(
pathname
string
)
(
bool
,
error
)
{
return
true
,
nil
}
func
(
mi
*
fakeMountInterface
)
MakeRShared
(
path
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
GetFileType
(
pathname
string
)
(
mount
.
FileType
,
error
)
{
return
mount
.
FileType
(
"fake"
),
nil
}
func
(
mi
*
fakeMountInterface
)
MakeDir
(
pathname
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
MakeFile
(
pathname
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
ExistsPath
(
pathname
string
)
bool
{
return
true
}
func
fakeContainerMgrMountInt
()
mount
.
Interface
{
return
&
fakeMountInterface
{
[]
mount
.
MountPoint
{
{
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Opts
:
[]
string
{
"rw"
,
"relatime"
,
"cpuset"
},
},
{
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Opts
:
[]
string
{
"rw"
,
"relatime"
,
"cpu"
},
},
{
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Opts
:
[]
string
{
"rw"
,
"relatime"
,
"cpuacct"
},
},
{
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Opts
:
[]
string
{
"rw"
,
"relatime"
,
"memory"
},
},
},
}
}
pkg/kubelet/cm/pod_container_manager_unsupported.go
View file @
4b216f7c
...
...
@@ -18,36 +18,8 @@ limitations under the License.
package
cm
import
(
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
)
type
unsupportedPodContainerManager
struct
{
podContainerManagerStub
}
var
_
PodContainerManager
=
&
unsupportedPodContainerManager
{}
func
(
m
*
unsupportedPodContainerManager
)
Exists
(
_
*
v1
.
Pod
)
bool
{
return
true
}
func
(
m
*
unsupportedPodContainerManager
)
EnsureExists
(
_
*
v1
.
Pod
)
error
{
return
nil
}
func
(
m
*
unsupportedPodContainerManager
)
GetPodContainerName
(
_
*
v1
.
Pod
)
(
CgroupName
,
string
)
{
return
""
,
""
}
func
(
m
*
unsupportedPodContainerManager
)
ReduceCPULimits
(
_
CgroupName
)
error
{
return
nil
}
func
(
m
*
unsupportedPodContainerManager
)
GetAllPodsFromCgroups
()
(
map
[
types
.
UID
]
CgroupName
,
error
)
{
return
nil
,
nil
}
func
(
m
*
unsupportedPodContainerManager
)
Destroy
(
name
CgroupName
)
error
{
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment