Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
autoscaler
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
kubernetes
autoscaler
Commits
054c52a9
Unverified
Commit
054c52a9
authored
3 years ago
by
Kubernetes Prow Robot
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4742 from x13n/eq
Skip pod hostname when comparing PodSpecs
parents
2b84cf60
109765b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cluster-autoscaler/utils/utils.go
+13
-6
13 additions, 6 deletions
cluster-autoscaler/utils/utils.go
cluster-autoscaler/utils/utils_test.go
+12
-2
12 additions, 2 deletions
cluster-autoscaler/utils/utils_test.go
with
25 additions
and
8 deletions
cluster-autoscaler/utils/utils.go
+
13
−
6
View file @
054c52a9
...
@@ -62,14 +62,18 @@ func FilterOutNodes(nodes []*apiv1.Node, nodesToFilterOut []*apiv1.Node) []*apiv
...
@@ -62,14 +62,18 @@ func FilterOutNodes(nodes []*apiv1.Node, nodesToFilterOut []*apiv1.Node) []*apiv
// an equivalence group per pod which is undesirable.
// an equivalence group per pod which is undesirable.
// Projected volumes do not impact scheduling so we should ignore them
// Projected volumes do not impact scheduling so we should ignore them
func
PodSpecSemanticallyEqual
(
p1
apiv1
.
PodSpec
,
p2
apiv1
.
PodSpec
)
bool
{
func
PodSpecSemanticallyEqual
(
p1
apiv1
.
PodSpec
,
p2
apiv1
.
PodSpec
)
bool
{
p1Spec
:=
sanitizeP
rojectedVolumesAndMounts
(
p1
)
p1Spec
:=
sanitizeP
odSpec
(
p1
)
p2Spec
:=
sanitizeP
rojectedVolumesAndMounts
(
p2
)
p2Spec
:=
sanitizeP
odSpec
(
p2
)
return
apiequality
.
Semantic
.
DeepEqual
(
p1Spec
,
p2Spec
)
return
apiequality
.
Semantic
.
DeepEqual
(
p1Spec
,
p2Spec
)
}
}
// sanitizeProjectedVolumesAndMounts returns a pod spec with projected volumes
func
sanitizePodSpec
(
podSpec
apiv1
.
PodSpec
)
apiv1
.
PodSpec
{
// and their mounts removed
dropProjectedVolumesAndMounts
(
&
podSpec
)
func
sanitizeProjectedVolumesAndMounts
(
podSpec
apiv1
.
PodSpec
)
apiv1
.
PodSpec
{
dropHostname
(
&
podSpec
)
return
podSpec
}
func
dropProjectedVolumesAndMounts
(
podSpec
*
apiv1
.
PodSpec
)
{
projectedVolumeNames
:=
map
[
string
]
bool
{}
projectedVolumeNames
:=
map
[
string
]
bool
{}
var
volumes
[]
apiv1
.
Volume
var
volumes
[]
apiv1
.
Volume
for
_
,
v
:=
range
podSpec
.
Volumes
{
for
_
,
v
:=
range
podSpec
.
Volumes
{
...
@@ -90,5 +94,8 @@ func sanitizeProjectedVolumesAndMounts(podSpec apiv1.PodSpec) apiv1.PodSpec {
...
@@ -90,5 +94,8 @@ func sanitizeProjectedVolumesAndMounts(podSpec apiv1.PodSpec) apiv1.PodSpec {
}
}
podSpec
.
Containers
[
i
]
.
VolumeMounts
=
volumeMounts
podSpec
.
Containers
[
i
]
.
VolumeMounts
=
volumeMounts
}
}
return
podSpec
}
func
dropHostname
(
podSpec
*
apiv1
.
PodSpec
)
{
podSpec
.
Hostname
=
""
}
}
This diff is collapsed.
Click to expand it.
cluster-autoscaler/utils/utils_test.go
+
12
−
2
View file @
054c52a9
...
@@ -73,6 +73,16 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
...
@@ -73,6 +73,16 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
},
},
},
},
},
},
{
name
:
"two pods with different hostnames"
,
p1Spec
:
apiv1
.
PodSpec
{
Hostname
:
"foo"
,
},
p2Spec
:
apiv1
.
PodSpec
{
Hostname
:
"bar"
,
},
result
:
true
,
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
...
@@ -83,7 +93,7 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
...
@@ -83,7 +93,7 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
}
}
}
}
func
TestSanitizeP
rojectedVolumesAndMounts
(
t
*
testing
.
T
)
{
func
TestSanitizeP
odSpec
(
t
*
testing
.
T
)
{
projectedSAVol
:=
test
.
BuildServiceTokenProjectedVolumeSource
(
"path"
)
projectedSAVol
:=
test
.
BuildServiceTokenProjectedVolumeSource
(
"path"
)
tests
:=
[]
struct
{
tests
:=
[]
struct
{
...
@@ -170,7 +180,7 @@ func TestSanitizeProjectedVolumesAndMounts(t *testing.T) {
...
@@ -170,7 +180,7 @@ func TestSanitizeProjectedVolumesAndMounts(t *testing.T) {
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
sanitizeP
rojectedVolumesAndMounts
(
tt
.
inputPodSpec
)
got
:=
sanitizeP
odSpec
(
tt
.
inputPodSpec
)
assert
.
True
(
t
,
assert
.
ObjectsAreEqualValues
(
tt
.
outputPodSpec
,
got
),
"
\n
got: %#v
\n
want: %#v"
,
got
,
tt
.
outputPodSpec
)
assert
.
True
(
t
,
assert
.
ObjectsAreEqualValues
(
tt
.
outputPodSpec
,
got
),
"
\n
got: %#v
\n
want: %#v"
,
got
,
tt
.
outputPodSpec
)
})
})
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment