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
0c9bb5a9
Commit
0c9bb5a9
authored
Dec 18, 2017
by
Cao Shufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless function hasHostPortConflicts
`hasHostPortConflicts` is not used anywhere. Delete it.
parent
d3a73478
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
39 deletions
+0
-39
BUILD
pkg/kubelet/BUILD
+0
-2
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+0
-18
kubelet_pods_test.go
pkg/kubelet/kubelet_pods_test.go
+0
-19
No files found.
pkg/kubelet/BUILD
View file @
0c9bb5a9
...
@@ -36,7 +36,6 @@ go_library(
...
@@ -36,7 +36,6 @@ go_library(
"//pkg/apis/core/v1:go_default_library",
"//pkg/apis/core/v1:go_default_library",
"//pkg/apis/core/v1/helper:go_default_library",
"//pkg/apis/core/v1/helper:go_default_library",
"//pkg/apis/core/v1/helper/qos:go_default_library",
"//pkg/apis/core/v1/helper/qos:go_default_library",
"//pkg/apis/core/v1/validation:go_default_library",
"//pkg/capabilities:go_default_library",
"//pkg/capabilities:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
...
@@ -125,7 +124,6 @@ go_library(
...
@@ -125,7 +124,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
...
...
pkg/kubelet/kubelet_pods.go
View file @
0c9bb5a9
...
@@ -40,7 +40,6 @@ import (
...
@@ -40,7 +40,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
utilvalidation
"k8s.io/apimachinery/pkg/util/validation"
utilvalidation
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/client-go/tools/remotecommand"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
...
@@ -48,7 +47,6 @@ import (
...
@@ -48,7 +47,6 @@ import (
podshelper
"k8s.io/kubernetes/pkg/apis/core/pods"
podshelper
"k8s.io/kubernetes/pkg/apis/core/pods"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
v1qos
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
v1qos
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
"k8s.io/kubernetes/pkg/apis/core/v1/validation"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/fieldpath"
"k8s.io/kubernetes/pkg/fieldpath"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
@@ -1109,22 +1107,6 @@ func (kl *Kubelet) podKiller() {
...
@@ -1109,22 +1107,6 @@ func (kl *Kubelet) podKiller() {
}
}
}
}
// hasHostPortConflicts detects pods with conflicted host ports.
func
hasHostPortConflicts
(
pods
[]
*
v1
.
Pod
)
bool
{
ports
:=
sets
.
String
{}
for
_
,
pod
:=
range
pods
{
if
errs
:=
validation
.
AccumulateUniqueHostPorts
(
pod
.
Spec
.
Containers
,
&
ports
,
field
.
NewPath
(
"spec"
,
"containers"
));
len
(
errs
)
>
0
{
glog
.
Errorf
(
"Pod %q: HostPort is already allocated, ignoring: %v"
,
format
.
Pod
(
pod
),
errs
)
return
true
}
if
errs
:=
validation
.
AccumulateUniqueHostPorts
(
pod
.
Spec
.
InitContainers
,
&
ports
,
field
.
NewPath
(
"spec"
,
"initContainers"
));
len
(
errs
)
>
0
{
glog
.
Errorf
(
"Pod %q: HostPort is already allocated, ignoring: %v"
,
format
.
Pod
(
pod
),
errs
)
return
true
}
}
return
false
}
// validateContainerLogStatus returns the container ID for the desired container to retrieve logs for, based on the state
// validateContainerLogStatus returns the container ID for the desired container to retrieve logs for, based on the state
// of the container. The previous flag will only return the logs for the last terminated container, otherwise, the current
// of the container. The previous flag will only return the logs for the last terminated container, otherwise, the current
// running container is preferred over a previous termination. If info about the container is not available then a specific
// running container is preferred over a previous termination. If info about the container is not available then a specific
...
...
pkg/kubelet/kubelet_pods_test.go
View file @
0c9bb5a9
...
@@ -2270,25 +2270,6 @@ func TestPortForward(t *testing.T) {
...
@@ -2270,25 +2270,6 @@ func TestPortForward(t *testing.T) {
}
}
}
}
// Tests that identify the host port conflicts are detected correctly.
func
TestGetHostPortConflicts
(
t
*
testing
.
T
)
{
pods
:=
[]
*
v1
.
Pod
{
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
80
}}}}}},
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
81
}}}}}},
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
82
}}}}}},
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
83
}}}}}},
}
// Pods should not cause any conflict.
assert
.
False
(
t
,
hasHostPortConflicts
(
pods
),
"Should not have port conflicts"
)
expected
:=
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
81
}}}}},
}
// The new pod should cause conflict and be reported.
pods
=
append
(
pods
,
expected
)
assert
.
True
(
t
,
hasHostPortConflicts
(
pods
),
"Should have port conflicts"
)
}
func
TestHasHostMountPVC
(
t
*
testing
.
T
)
{
func
TestHasHostMountPVC
(
t
*
testing
.
T
)
{
tests
:=
map
[
string
]
struct
{
tests
:=
map
[
string
]
struct
{
pvError
error
pvError
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