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
f8063879
Commit
f8063879
authored
Apr 05, 2017
by
Manjunath A Kumatagi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Docker API Version instead of docker version
parent
2b42d71a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
18 deletions
+15
-18
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+1
-4
container_manager_linux.go
pkg/kubelet/cm/container_manager_linux.go
+12
-12
container_manager_linux.go
pkg/kubelet/dockershim/cm/container_manager_linux.go
+2
-2
No files found.
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
f8063879
...
@@ -95,10 +95,7 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
...
@@ -95,10 +95,7 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
// New creates a cAdvisor and exports its API on the specified port if port > 0.
// New creates a cAdvisor and exports its API on the specified port if port > 0.
func
New
(
port
uint
,
runtime
string
,
rootPath
string
)
(
Interface
,
error
)
{
func
New
(
port
uint
,
runtime
string
,
rootPath
string
)
(
Interface
,
error
)
{
sysFs
,
err
:=
sysfs
.
NewRealSysFs
()
sysFs
:=
sysfs
.
NewRealSysFs
()
if
err
!=
nil
{
return
nil
,
err
}
// Create and start the cAdvisor container manager.
// Create and start the cAdvisor container manager.
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{}},
http
.
DefaultClient
)
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{}},
http
.
DefaultClient
)
...
...
pkg/kubelet/cm/container_manager_linux.go
View file @
f8063879
...
@@ -66,7 +66,7 @@ const (
...
@@ -66,7 +66,7 @@ const (
var
(
var
(
// The docker version in which containerd was introduced.
// The docker version in which containerd was introduced.
containerd
Version
=
utilversion
.
MustParseSemantic
(
"1.11.0
"
)
containerd
APIVersion
=
utilversion
.
MustParseGeneric
(
"1.23
"
)
)
)
// A non-user container tracked by the Kubelet.
// A non-user container tracked by the Kubelet.
...
@@ -377,7 +377,7 @@ func (cm *containerManagerImpl) setupNode(activePods ActivePodsFunc) error {
...
@@ -377,7 +377,7 @@ func (cm *containerManagerImpl) setupNode(activePods ActivePodsFunc) error {
systemContainers
:=
[]
*
systemContainer
{}
systemContainers
:=
[]
*
systemContainer
{}
if
cm
.
ContainerRuntime
==
"docker"
{
if
cm
.
ContainerRuntime
==
"docker"
{
docker
Version
:=
getDocker
Version
(
cm
.
cadvisorInterface
)
docker
APIVersion
:=
getDockerAPI
Version
(
cm
.
cadvisorInterface
)
if
cm
.
EnableCRI
{
if
cm
.
EnableCRI
{
// If kubelet uses CRI, dockershim will manage the cgroups and oom
// If kubelet uses CRI, dockershim will manage the cgroups and oom
// score for the docker processes.
// score for the docker processes.
...
@@ -420,13 +420,13 @@ func (cm *containerManagerImpl) setupNode(activePods ActivePodsFunc) error {
...
@@ -420,13 +420,13 @@ func (cm *containerManagerImpl) setupNode(activePods ActivePodsFunc) error {
},
},
}
}
cont
.
ensureStateFunc
=
func
(
manager
*
fs
.
Manager
)
error
{
cont
.
ensureStateFunc
=
func
(
manager
*
fs
.
Manager
)
error
{
return
EnsureDockerInContainer
(
dockerVersion
,
qos
.
DockerOOMScoreAdj
,
dockerContainer
)
return
EnsureDockerInContainer
(
docker
API
Version
,
qos
.
DockerOOMScoreAdj
,
dockerContainer
)
}
}
systemContainers
=
append
(
systemContainers
,
cont
)
systemContainers
=
append
(
systemContainers
,
cont
)
}
else
{
}
else
{
cm
.
periodicTasks
=
append
(
cm
.
periodicTasks
,
func
()
{
cm
.
periodicTasks
=
append
(
cm
.
periodicTasks
,
func
()
{
glog
.
V
(
10
)
.
Infof
(
"Adding docker daemon periodic tasks"
)
glog
.
V
(
10
)
.
Infof
(
"Adding docker daemon periodic tasks"
)
if
err
:=
EnsureDockerInContainer
(
dockerVersion
,
qos
.
DockerOOMScoreAdj
,
nil
);
err
!=
nil
{
if
err
:=
EnsureDockerInContainer
(
docker
API
Version
,
qos
.
DockerOOMScoreAdj
,
nil
);
err
!=
nil
{
glog
.
Error
(
err
)
glog
.
Error
(
err
)
return
return
}
}
...
@@ -654,10 +654,10 @@ func getPidsForProcess(name, pidFile string) ([]int, error) {
...
@@ -654,10 +654,10 @@ func getPidsForProcess(name, pidFile string) ([]int, error) {
// Temporarily export the function to be used by dockershim.
// Temporarily export the function to be used by dockershim.
// TODO(yujuhong): Move this function to dockershim once kubelet migrates to
// TODO(yujuhong): Move this function to dockershim once kubelet migrates to
// dockershim as the default.
// dockershim as the default.
func
EnsureDockerInContainer
(
dockerVersion
*
utilversion
.
Version
,
oomScoreAdj
int
,
manager
*
fs
.
Manager
)
error
{
func
EnsureDockerInContainer
(
docker
API
Version
*
utilversion
.
Version
,
oomScoreAdj
int
,
manager
*
fs
.
Manager
)
error
{
type
process
struct
{
name
,
file
string
}
type
process
struct
{
name
,
file
string
}
dockerProcs
:=
[]
process
{{
dockerProcessName
,
dockerPidFile
}}
dockerProcs
:=
[]
process
{{
dockerProcessName
,
dockerPidFile
}}
if
docker
Version
.
AtLeast
(
containerd
Version
)
{
if
docker
APIVersion
.
AtLeast
(
containerdAPI
Version
)
{
dockerProcs
=
append
(
dockerProcs
,
process
{
containerdProcessName
,
containerdPidFile
})
dockerProcs
=
append
(
dockerProcs
,
process
{
containerdProcessName
,
containerdPidFile
})
}
}
var
errs
[]
error
var
errs
[]
error
...
@@ -818,19 +818,19 @@ func isKernelPid(pid int) bool {
...
@@ -818,19 +818,19 @@ func isKernelPid(pid int) bool {
return
err
!=
nil
return
err
!=
nil
}
}
// Helper for getting the docker version.
// Helper for getting the docker
API
version.
func
getDockerVersion
(
cadvisor
cadvisor
.
Interface
)
*
utilversion
.
Version
{
func
getDocker
API
Version
(
cadvisor
cadvisor
.
Interface
)
*
utilversion
.
Version
{
versions
,
err
:=
cadvisor
.
VersionInfo
()
versions
,
err
:=
cadvisor
.
VersionInfo
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error requesting cAdvisor VersionInfo: %v"
,
err
)
glog
.
Errorf
(
"Error requesting cAdvisor VersionInfo: %v"
,
err
)
return
utilversion
.
MustParseSemantic
(
"0.0
.0
"
)
return
utilversion
.
MustParseSemantic
(
"0.0"
)
}
}
docker
Version
,
err
:=
utilversion
.
ParseSemantic
(
versions
.
Docker
Version
)
docker
APIVersion
,
err
:=
utilversion
.
ParseGeneric
(
versions
.
DockerAPI
Version
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error parsing docker version %q: %v"
,
versions
.
DockerVersion
,
err
)
glog
.
Errorf
(
"Error parsing docker version %q: %v"
,
versions
.
DockerVersion
,
err
)
return
utilversion
.
MustParseSemantic
(
"0.0
.0
"
)
return
utilversion
.
MustParseSemantic
(
"0.0"
)
}
}
return
dockerVersion
return
docker
API
Version
}
}
func
(
m
*
containerManagerImpl
)
GetCapacity
()
v1
.
ResourceList
{
func
(
m
*
containerManagerImpl
)
GetCapacity
()
v1
.
ResourceList
{
...
...
pkg/kubelet/dockershim/cm/container_manager_linux.go
View file @
f8063879
...
@@ -85,9 +85,9 @@ func (m *containerManager) doWork() {
...
@@ -85,9 +85,9 @@ func (m *containerManager) doWork() {
glog
.
Errorf
(
"Unable to get docker version: %v"
,
err
)
glog
.
Errorf
(
"Unable to get docker version: %v"
,
err
)
return
return
}
}
version
,
err
:=
utilversion
.
ParseGeneric
(
v
.
Version
)
version
,
err
:=
utilversion
.
ParseGeneric
(
v
.
API
Version
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Unable to parse docker version %q: %v"
,
v
.
Version
,
err
)
glog
.
Errorf
(
"Unable to parse docker version %q: %v"
,
v
.
API
Version
,
err
)
return
return
}
}
// EnsureDockerInConatiner does two things.
// EnsureDockerInConatiner does two things.
...
...
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