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
88fe5c6f
Commit
88fe5c6f
authored
Jan 05, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Never set pod.Name in kubelet config code
I think it is time to tighten up input requirements. The validation code will reject a pod that has an empty name field.
parent
22a241aa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
13 deletions
+2
-13
etcd.go
pkg/kubelet/config/etcd.go
+1
-5
file.go
pkg/kubelet/config/file.go
+0
-1
file_test.go
pkg/kubelet/config/file_test.go
+1
-4
http.go
pkg/kubelet/config/http.go
+0
-3
No files found.
pkg/kubelet/config/etcd.go
View file @
88fe5c6f
...
...
@@ -19,7 +19,6 @@ package config
import
(
"errors"
"fmt"
"path"
"strconv"
"time"
...
...
@@ -93,10 +92,7 @@ func eventToPods(ev watch.Event) ([]api.BoundPod, error) {
return
pods
,
errors
.
New
(
"unable to parse response as BoundPods"
)
}
for
i
,
pod
:=
range
boundPods
.
Items
{
if
len
(
pod
.
Name
)
==
0
{
pod
.
Name
=
fmt
.
Sprintf
(
"%d"
,
i
+
1
)
}
for
_
,
pod
:=
range
boundPods
.
Items
{
// TODO: generate random UID if not present
if
pod
.
UID
==
""
&&
!
pod
.
CreationTimestamp
.
IsZero
()
{
pod
.
UID
=
strconv
.
FormatInt
(
pod
.
CreationTimestamp
.
Unix
(),
10
)
...
...
pkg/kubelet/config/file.go
View file @
88fe5c6f
...
...
@@ -153,7 +153,6 @@ func extractFromFile(filename string) (api.BoundPod, error) {
return
pod
,
fmt
.
Errorf
(
"can't convert pod from file %q: %v"
,
filename
,
err
)
}
pod
.
Name
=
simpleSubdomainSafeHash
(
filename
)
if
len
(
pod
.
UID
)
==
0
{
pod
.
UID
=
simpleSubdomainSafeHash
(
filename
)
}
...
...
pkg/kubelet/config/file_test.go
View file @
88fe5c6f
...
...
@@ -121,7 +121,7 @@ func TestReadFromFile(t *testing.T) {
update
:=
got
.
(
kubelet
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
FileSource
,
api
.
BoundPod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
simpleSubdomainSafeHash
(
file
.
Name
())
,
Name
:
"test"
,
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
Namespace
:
"default"
,
},
...
...
@@ -161,8 +161,6 @@ func TestExtractFromValidDataFile(t *testing.T) {
file
:=
writeTestFile
(
t
,
os
.
TempDir
(),
"test_pod_config"
,
string
(
text
))
defer
os
.
Remove
(
file
.
Name
())
expectedPod
.
Name
=
simpleSubdomainSafeHash
(
file
.
Name
())
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceFile
{
file
.
Name
(),
ch
}
err
=
c
.
extractFromPath
()
...
...
@@ -228,7 +226,6 @@ func TestExtractFromDir(t *testing.T) {
}
ioutil
.
WriteFile
(
name
,
data
,
0755
)
files
[
i
]
=
file
pods
[
i
]
.
Name
=
simpleSubdomainSafeHash
(
name
)
}
ch
:=
make
(
chan
interface
{},
1
)
...
...
pkg/kubelet/config/http.go
View file @
88fe5c6f
...
...
@@ -91,9 +91,6 @@ func (s *sourceURL) extractFromURL() error {
if
err
:=
api
.
Scheme
.
Convert
(
&
manifest
,
&
pod
);
err
!=
nil
{
return
err
}
if
len
(
pod
.
Name
)
==
0
{
pod
.
Name
=
"1"
}
if
len
(
pod
.
Namespace
)
==
0
{
pod
.
Namespace
=
api
.
NamespaceDefault
}
...
...
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