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
9a6857cf
Commit
9a6857cf
authored
Mar 10, 2015
by
Jerzy Szczepkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed writing Host in Pod.Spec during binding.
Fixed writing Host in Pod.Spec during binding. Related to #5207.
parent
6d465c4d
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 @
9a6857cf
...
@@ -173,9 +173,10 @@ func (r *BindingREST) setPodHostTo(ctx api.Context, podID, oldMachine, machine s
...
@@ -173,9 +173,10 @@ func (r *BindingREST) setPodHostTo(ctx api.Context, podID, oldMachine, machine s
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected object: %#v"
,
obj
)
return
nil
,
fmt
.
Errorf
(
"unexpected object: %#v"
,
obj
)
}
}
if
pod
.
Status
.
Host
!=
oldMachine
{
if
pod
.
S
pec
.
Host
!=
oldMachine
||
pod
.
S
tatus
.
Host
!=
oldMachine
{
return
nil
,
fmt
.
Errorf
(
"pod %v is already assigned to host %v
"
,
pod
.
Name
,
pod
.
Status
.
Host
)
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
pod
.
Status
.
Host
=
machine
finalPod
=
pod
finalPod
=
pod
return
pod
,
nil
return
pod
,
nil
...
...
pkg/registry/pod/etcd/etcd_test.go
View file @
9a6857cf
...
@@ -1090,28 +1090,28 @@ func TestEtcdCreateBinding(t *testing.T) {
...
@@ -1090,28 +1090,28 @@ func TestEtcdCreateBinding(t *testing.T) {
"badKind"
:
{
"badKind"
:
{
binding
:
api
.
Binding
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
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
)
},
errOK
:
func
(
err
error
)
bool
{
return
errors
.
IsInvalid
(
err
)
},
},
},
"emptyKind"
:
{
"emptyKind"
:
{
binding
:
api
.
Binding
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
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
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
},
"kindNode"
:
{
"kindNode"
:
{
binding
:
api
.
Binding
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
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
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
},
"kindMinion"
:
{
"kindMinion"
:
{
binding
:
api
.
Binding
{
binding
:
api
.
Binding
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"foo"
},
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
},
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
},
...
@@ -1124,13 +1124,22 @@ func TestEtcdCreateBinding(t *testing.T) {
...
@@ -1124,13 +1124,22 @@ func TestEtcdCreateBinding(t *testing.T) {
},
},
E
:
tools
.
EtcdErrorNotFound
,
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
{
if
_
,
err
:=
registry
.
Create
(
ctx
,
validNewPod
());
err
!=
nil
{
t
.
Fatalf
(
"%s: unexpected error: %v"
,
k
,
err
)
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
)
{
if
_
,
err
:=
bindingRegistry
.
Create
(
ctx
,
&
test
.
binding
);
!
test
.
errOK
(
err
)
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
k
,
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