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
1e7c0a4b
Commit
1e7c0a4b
authored
Aug 14, 2017
by
Ricky Pai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove validation disallowing hostAlias with hostNetwork
parent
4edd92f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
18 deletions
+10
-18
validation.go
pkg/api/validation/validation.go
+0
-11
validation_test.go
pkg/api/validation/validation_test.go
+10
-7
No files found.
pkg/api/validation/validation.go
View file @
1e7c0a4b
...
@@ -2067,16 +2067,6 @@ func validateHostNetwork(hostNetwork bool, containers []api.Container, fldPath *
...
@@ -2067,16 +2067,6 @@ func validateHostNetwork(hostNetwork bool, containers []api.Container, fldPath *
return
allErrors
return
allErrors
}
}
func
validateHostNetworkNoHostAliases
(
hostNetwork
bool
,
hostAliases
[]
api
.
HostAlias
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrors
:=
field
.
ErrorList
{}
if
hostNetwork
{
if
len
(
hostAliases
)
>
0
{
allErrors
=
append
(
allErrors
,
field
.
Forbidden
(
fldPath
,
"may not be set when `hostNetwork` is true"
))
}
}
return
allErrors
}
// validateImagePullSecrets checks to make sure the pull secrets are well
// validateImagePullSecrets checks to make sure the pull secrets are well
// formed. Right now, we only expect name to be set (it's the only field). If
// formed. Right now, we only expect name to be set (it's the only field). If
// this ever changes and someone decides to set those fields, we'd like to
// this ever changes and someone decides to set those fields, we'd like to
...
@@ -2620,7 +2610,6 @@ func ValidatePodSecurityContext(securityContext *api.PodSecurityContext, spec *a
...
@@ -2620,7 +2610,6 @@ func ValidatePodSecurityContext(securityContext *api.PodSecurityContext, spec *a
if
securityContext
!=
nil
{
if
securityContext
!=
nil
{
allErrs
=
append
(
allErrs
,
validateHostNetwork
(
securityContext
.
HostNetwork
,
spec
.
Containers
,
specPath
.
Child
(
"containers"
))
...
)
allErrs
=
append
(
allErrs
,
validateHostNetwork
(
securityContext
.
HostNetwork
,
spec
.
Containers
,
specPath
.
Child
(
"containers"
))
...
)
allErrs
=
append
(
allErrs
,
validateHostNetworkNoHostAliases
(
securityContext
.
HostNetwork
,
spec
.
HostAliases
,
specPath
)
...
)
if
securityContext
.
FSGroup
!=
nil
{
if
securityContext
.
FSGroup
!=
nil
{
for
_
,
msg
:=
range
validation
.
IsValidGroupID
(
*
securityContext
.
FSGroup
)
{
for
_
,
msg
:=
range
validation
.
IsValidGroupID
(
*
securityContext
.
FSGroup
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"fsGroup"
),
*
(
securityContext
.
FSGroup
),
msg
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"fsGroup"
),
*
(
securityContext
.
FSGroup
),
msg
))
...
...
pkg/api/validation/validation_test.go
View file @
1e7c0a4b
...
@@ -3844,13 +3844,22 @@ func TestValidatePodSpec(t *testing.T) {
...
@@ -3844,13 +3844,22 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy
:
api
.
RestartPolicyAlways
,
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
},
{
// Populate HostAliases with `foo.bar` hostnames
.
{
// Populate HostAliases with `foo.bar` hostnames.
HostAliases
:
[]
api
.
HostAlias
{{
IP
:
"12.34.56.78"
,
Hostnames
:
[]
string
{
"host1.foo"
,
"host2.bar"
}}},
HostAliases
:
[]
api
.
HostAlias
{{
IP
:
"12.34.56.78"
,
Hostnames
:
[]
string
{
"host1.foo"
,
"host2.bar"
}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
,
TerminationMessagePolicy
:
"File"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
,
TerminationMessagePolicy
:
"File"
}},
RestartPolicy
:
api
.
RestartPolicyAlways
,
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
},
{
// Populate HostAliases with HostNetwork.
HostAliases
:
[]
api
.
HostAlias
{{
IP
:
"12.34.56.78"
,
Hostnames
:
[]
string
{
"host1.foo"
,
"host2.bar"
}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
,
TerminationMessagePolicy
:
"File"
}},
SecurityContext
:
&
api
.
PodSecurityContext
{
HostNetwork
:
true
,
},
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
{
// Populate PriorityClassName.
{
// Populate PriorityClassName.
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
,
TerminationMessagePolicy
:
"File"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
,
TerminationMessagePolicy
:
"File"
}},
...
@@ -3923,12 +3932,6 @@ func TestValidatePodSpec(t *testing.T) {
...
@@ -3923,12 +3932,6 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy
:
api
.
RestartPolicyAlways
,
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
},
"with hostNetwork and hostAliases"
:
{
SecurityContext
:
&
api
.
PodSecurityContext
{
HostNetwork
:
true
,
},
HostAliases
:
[]
api
.
HostAlias
{{
IP
:
"12.34.56.78"
,
Hostnames
:
[]
string
{
"host1"
,
"host2"
}}},
},
"with hostAliases with invalid IP"
:
{
"with hostAliases with invalid IP"
:
{
SecurityContext
:
&
api
.
PodSecurityContext
{
SecurityContext
:
&
api
.
PodSecurityContext
{
HostNetwork
:
false
,
HostNetwork
:
false
,
...
...
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