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
c436671c
Commit
c436671c
authored
Jan 27, 2017
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kuberuntime: remove the kubernetesManagedLabel label
The CRI shim should be responsible for returning only those containers/sandboxes created through CRI. Remove this label in kubelet.
parent
8fa38196
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
30 deletions
+3
-30
kuberuntime_container.go
pkg/kubelet/kuberuntime/kuberuntime_container.go
+1
-3
kuberuntime_sandbox.go
pkg/kubelet/kuberuntime/kuberuntime_sandbox.go
+1
-12
labels.go
pkg/kubelet/kuberuntime/labels.go
+1
-15
No files found.
pkg/kubelet/kuberuntime/kuberuntime_container.go
View file @
c436671c
...
@@ -302,9 +302,7 @@ func (m *kubeGenericRuntimeManager) makeMounts(opts *kubecontainer.RunContainerO
...
@@ -302,9 +302,7 @@ func (m *kubeGenericRuntimeManager) makeMounts(opts *kubecontainer.RunContainerO
// The boolean parameter specifies whether returns all containers including
// The boolean parameter specifies whether returns all containers including
// those already exited and dead containers (used for garbage collection).
// those already exited and dead containers (used for garbage collection).
func
(
m
*
kubeGenericRuntimeManager
)
getKubeletContainers
(
allContainers
bool
)
([]
*
runtimeapi
.
Container
,
error
)
{
func
(
m
*
kubeGenericRuntimeManager
)
getKubeletContainers
(
allContainers
bool
)
([]
*
runtimeapi
.
Container
,
error
)
{
filter
:=
&
runtimeapi
.
ContainerFilter
{
filter
:=
&
runtimeapi
.
ContainerFilter
{}
LabelSelector
:
map
[
string
]
string
{
kubernetesManagedLabel
:
"true"
},
}
if
!
allContainers
{
if
!
allContainers
{
runningState
:=
runtimeapi
.
ContainerState_CONTAINER_RUNNING
runningState
:=
runtimeapi
.
ContainerState_CONTAINER_RUNNING
filter
.
State
=
&
runtimeapi
.
ContainerStateValue
{
filter
.
State
=
&
runtimeapi
.
ContainerStateValue
{
...
...
pkg/kubelet/kuberuntime/kuberuntime_sandbox.go
View file @
c436671c
...
@@ -188,18 +188,7 @@ func (m *kubeGenericRuntimeManager) getKubeletSandboxes(all bool) ([]*runtimeapi
...
@@ -188,18 +188,7 @@ func (m *kubeGenericRuntimeManager) getKubeletSandboxes(all bool) ([]*runtimeapi
return
nil
,
err
return
nil
,
err
}
}
result
:=
[]
*
runtimeapi
.
PodSandbox
{}
return
resp
,
nil
for
_
,
s
:=
range
resp
{
if
!
isManagedByKubelet
(
s
.
Labels
)
{
glog
.
V
(
5
)
.
Infof
(
"Sandbox %s is not managed by kubelet"
,
kubecontainer
.
BuildPodFullName
(
s
.
Metadata
.
Name
,
s
.
Metadata
.
Namespace
))
continue
}
result
=
append
(
result
,
s
)
}
return
result
,
nil
}
}
// determinePodSandboxIP determines the IP address of the given pod sandbox.
// determinePodSandboxIP determines the IP address of the given pod sandbox.
...
...
pkg/kubelet/kuberuntime/labels.go
View file @
c436671c
...
@@ -39,9 +39,6 @@ const (
...
@@ -39,9 +39,6 @@ const (
containerTerminationMessagePolicyLabel
=
"io.kubernetes.container.terminationMessagePolicy"
containerTerminationMessagePolicyLabel
=
"io.kubernetes.container.terminationMessagePolicy"
containerPreStopHandlerLabel
=
"io.kubernetes.container.preStopHandler"
containerPreStopHandlerLabel
=
"io.kubernetes.container.preStopHandler"
containerPortsLabel
=
"io.kubernetes.container.ports"
containerPortsLabel
=
"io.kubernetes.container.ports"
// kubernetesManagedLabel is used to distinguish whether a container/sandbox is managed by kubelet or not
kubernetesManagedLabel
=
"io.kubernetes.managed"
)
)
type
labeledPodSandboxInfo
struct
{
type
labeledPodSandboxInfo
struct
{
...
@@ -87,7 +84,6 @@ func newPodLabels(pod *v1.Pod) map[string]string {
...
@@ -87,7 +84,6 @@ func newPodLabels(pod *v1.Pod) map[string]string {
labels
[
types
.
KubernetesPodNameLabel
]
=
pod
.
Name
labels
[
types
.
KubernetesPodNameLabel
]
=
pod
.
Name
labels
[
types
.
KubernetesPodNamespaceLabel
]
=
pod
.
Namespace
labels
[
types
.
KubernetesPodNamespaceLabel
]
=
pod
.
Namespace
labels
[
types
.
KubernetesPodUIDLabel
]
=
string
(
pod
.
UID
)
labels
[
types
.
KubernetesPodUIDLabel
]
=
string
(
pod
.
UID
)
labels
[
kubernetesManagedLabel
]
=
"true"
return
labels
return
labels
}
}
...
@@ -104,7 +100,6 @@ func newContainerLabels(container *v1.Container, pod *v1.Pod) map[string]string
...
@@ -104,7 +100,6 @@ func newContainerLabels(container *v1.Container, pod *v1.Pod) map[string]string
labels
[
types
.
KubernetesPodNamespaceLabel
]
=
pod
.
Namespace
labels
[
types
.
KubernetesPodNamespaceLabel
]
=
pod
.
Namespace
labels
[
types
.
KubernetesPodUIDLabel
]
=
string
(
pod
.
UID
)
labels
[
types
.
KubernetesPodUIDLabel
]
=
string
(
pod
.
UID
)
labels
[
types
.
KubernetesContainerNameLabel
]
=
container
.
Name
labels
[
types
.
KubernetesContainerNameLabel
]
=
container
.
Name
labels
[
kubernetesManagedLabel
]
=
"true"
return
labels
return
labels
}
}
...
@@ -157,7 +152,7 @@ func getPodSandboxInfoFromLabels(labels map[string]string) *labeledPodSandboxInf
...
@@ -157,7 +152,7 @@ func getPodSandboxInfoFromLabels(labels map[string]string) *labeledPodSandboxInf
// Remain only labels from v1.Pod
// Remain only labels from v1.Pod
for
k
,
v
:=
range
labels
{
for
k
,
v
:=
range
labels
{
if
k
!=
types
.
KubernetesPodNameLabel
&&
k
!=
types
.
KubernetesPodNamespaceLabel
&&
k
!=
types
.
KubernetesPodUIDLabel
&&
k
!=
kubernetesManagedLabel
{
if
k
!=
types
.
KubernetesPodNameLabel
&&
k
!=
types
.
KubernetesPodNamespaceLabel
&&
k
!=
types
.
KubernetesPodUIDLabel
{
podSandboxInfo
.
Labels
[
k
]
=
v
podSandboxInfo
.
Labels
[
k
]
=
v
}
}
}
}
...
@@ -182,15 +177,6 @@ func getContainerInfoFromLabels(labels map[string]string) *labeledContainerInfo
...
@@ -182,15 +177,6 @@ func getContainerInfoFromLabels(labels map[string]string) *labeledContainerInfo
}
}
}
}
// isManagedByKubelet returns true is the sandbox/container is managed by kubelet.
func
isManagedByKubelet
(
labels
map
[
string
]
string
)
bool
{
if
_
,
ok
:=
labels
[
kubernetesManagedLabel
];
ok
{
return
true
}
return
false
}
// getContainerInfoFromAnnotations gets annotatedContainerInfo from annotations.
// getContainerInfoFromAnnotations gets annotatedContainerInfo from annotations.
func
getContainerInfoFromAnnotations
(
annotations
map
[
string
]
string
)
*
annotatedContainerInfo
{
func
getContainerInfoFromAnnotations
(
annotations
map
[
string
]
string
)
*
annotatedContainerInfo
{
var
err
error
var
err
error
...
...
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