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
1a75c884
Commit
1a75c884
authored
Mar 11, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5256 from jszczepkowski/podspec-host
Implemented writing Host in Pod.Spec during binding.
parents
d12f989e
9a6857cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
etcd.go
pkg/registry/pod/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/pod/etcd/etcd_test.go
+15
-6
No files found.
pkg/registry/pod/etcd/etcd.go
View file @
1a75c884
...
...
@@ -172,9 +172,10 @@ func (r *BindingREST) setPodHostTo(ctx api.Context, podID, oldMachine, machine s
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected object: %#v"
,
obj
)
}
if
pod
.
Status
.
Host
!=
oldMachine
{
return
nil
,
fmt
.
Errorf
(
"pod %v is already assigned to host %v
"
,
pod
.
Name
,
pod
.
Status
.
Host
)
if
pod
.
S
pec
.
Host
!=
oldMachine
||
pod
.
S
tatus
.
Host
!=
oldMachine
{
return
nil
,
fmt
.
Errorf
(
"pod %v is already assigned to host %v
or %v"
,
pod
.
Name
,
pod
.
Spec
.
Host
,
pod
.
Status
.
Host
)
}
pod
.
Spec
.
Host
=
machine
pod
.
Status
.
Host
=
machine
finalPod
=
pod
return
pod
,
nil
...
...
pkg/registry/pod/etcd/etcd_test.go
View file @
1a75c884
...
...
@@ -1090,28 +1090,28 @@ func TestEtcdCreateBinding(t *testing.T) {
"badKind"
:
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine"
,
Kind
:
"unknown"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine
1
"
,
Kind
:
"unknown"
},
},
errOK
:
func
(
err
error
)
bool
{
return
errors
.
IsInvalid
(
err
)
},
},
"emptyKind"
:
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine
2
"
},
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
"kindNode"
:
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine"
,
Kind
:
"Node"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine
3
"
,
Kind
:
"Node"
},
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
"kindMinion"
:
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine"
,
Kind
:
"Minion"
},
Target
:
api
.
ObjectReference
{
Name
:
"machine
4
"
,
Kind
:
"Minion"
},
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
...
...
@@ -1124,13 +1124,22 @@ func TestEtcdCreateBinding(t *testing.T) {
},
E
:
tools
.
EtcdErrorNotFound
,
}
fakeClient
.
Set
(
"/registry/nodes/machine/boundpods"
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
BoundPods
{}),
0
)
path
:=
fmt
.
Sprintf
(
"/registry/nodes/%v/boundpods"
,
test
.
binding
.
Target
.
Name
)
fakeClient
.
Set
(
path
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
BoundPods
{}),
0
)
if
_
,
err
:=
registry
.
Create
(
ctx
,
validNewPod
());
err
!=
nil
{
t
.
Fatalf
(
"%s: unexpected error: %v"
,
k
,
err
)
}
fakeClient
.
Set
(
"/registry/nodes/machine/boundpods"
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
BoundPods
{}),
0
)
fakeClient
.
Set
(
path
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
BoundPods
{}),
0
)
if
_
,
err
:=
bindingRegistry
.
Create
(
ctx
,
&
test
.
binding
);
!
test
.
errOK
(
err
)
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
k
,
err
)
}
else
if
err
==
nil
{
// If bind succeeded, verify Host field in pod's Spec.
pod
,
err
:=
registry
.
Get
(
ctx
,
validNewPod
()
.
ObjectMeta
.
Name
)
if
err
!=
nil
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
k
,
err
)
}
else
if
pod
.
(
*
api
.
Pod
)
.
Spec
.
Host
!=
test
.
binding
.
Target
.
Name
{
t
.
Errorf
(
"%s: expected: %v, got: %v"
,
k
,
pod
.
(
*
api
.
Pod
)
.
Spec
.
Host
,
test
.
binding
.
Target
.
Name
)
}
}
}
}
...
...
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