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
19379b5a
Commit
19379b5a
authored
Dec 07, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal rename api.Minion -> api.Node
parent
650aead4
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
212 additions
and
213 deletions
+212
-213
kubecfg.go
cmd/kubecfg/kubecfg.go
+1
-1
register.go
pkg/api/register.go
+6
-6
types.go
pkg/api/types.go
+6
-7
conversion.go
pkg/api/v1beta1/conversion.go
+4
-4
conversion_test.go
pkg/api/v1beta1/conversion_test.go
+14
-14
conversion.go
pkg/api/v1beta2/conversion.go
+2
-2
conversion_test.go
pkg/api/v1beta2/conversion_test.go
+2
-2
conversion_test.go
pkg/api/v1beta3/conversion_test.go
+2
-2
validation.go
pkg/api/validation/validation.go
+2
-2
validation_test.go
pkg/api/validation/validation_test.go
+13
-13
client_test.go
pkg/client/client_test.go
+3
-3
fake.go
pkg/client/fake.go
+1
-1
fake_minions.go
pkg/client/fake_minions.go
+5
-5
minions.go
pkg/client/minions.go
+9
-9
minioncontroller.go
pkg/cloudprovider/controller/minioncontroller.go
+6
-6
minioncontroller_test.go
pkg/cloudprovider/controller/minioncontroller_test.go
+16
-16
resource_printer.go
pkg/kubecfg/resource_printer.go
+2
-2
resource_printer.go
pkg/kubectl/resource_printer.go
+2
-2
etcd.go
pkg/registry/etcd/etcd.go
+6
-6
etcd_test.go
pkg/registry/etcd/etcd_test.go
+5
-5
healthy_registry.go
pkg/registry/minion/healthy_registry.go
+5
-5
healthy_registry_test.go
pkg/registry/minion/healthy_registry_test.go
+1
-1
registry.go
pkg/registry/minion/registry.go
+4
-4
rest.go
pkg/registry/minion/rest.go
+5
-5
rest_test.go
pkg/registry/minion/rest_test.go
+14
-14
rest_test.go
pkg/registry/pod/rest_test.go
+2
-2
minion.go
pkg/registry/registrytest/minion.go
+10
-10
rest.go
pkg/registry/service/rest.go
+1
-1
generic_scheduler.go
pkg/scheduler/generic_scheduler.go
+5
-5
generic_scheduler_test.go
pkg/scheduler/generic_scheduler_test.go
+3
-3
listers.go
pkg/scheduler/listers.go
+4
-4
predicates.go
pkg/scheduler/predicates.go
+4
-4
predicates_test.go
pkg/scheduler/predicates_test.go
+5
-5
priorities.go
pkg/scheduler/priorities.go
+1
-1
priorities_test.go
pkg/scheduler/priorities_test.go
+12
-12
factory.go
plugin/pkg/scheduler/factory/factory.go
+20
-20
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+8
-8
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+1
-1
No files found.
cmd/kubecfg/kubecfg.go
View file @
19379b5a
...
@@ -79,7 +79,7 @@ var parser = kubecfg.NewParser(map[string]runtime.Object{
...
@@ -79,7 +79,7 @@ var parser = kubecfg.NewParser(map[string]runtime.Object{
"pods"
:
&
api
.
Pod
{},
"pods"
:
&
api
.
Pod
{},
"services"
:
&
api
.
Service
{},
"services"
:
&
api
.
Service
{},
"replicationControllers"
:
&
api
.
ReplicationController
{},
"replicationControllers"
:
&
api
.
ReplicationController
{},
"minions"
:
&
api
.
Minion
{},
"minions"
:
&
api
.
Node
{},
"events"
:
&
api
.
Event
{},
"events"
:
&
api
.
Event
{},
})
})
...
...
pkg/api/register.go
View file @
19379b5a
...
@@ -31,8 +31,8 @@ func init() {
...
@@ -31,8 +31,8 @@ func init() {
&
ReplicationController
{},
&
ReplicationController
{},
&
ServiceList
{},
&
ServiceList
{},
&
Service
{},
&
Service
{},
&
Minion
List
{},
&
Node
List
{},
&
Minion
{},
&
Node
{},
&
Status
{},
&
Status
{},
&
ServerOpList
{},
&
ServerOpList
{},
&
ServerOp
{},
&
ServerOp
{},
...
@@ -47,8 +47,8 @@ func init() {
...
@@ -47,8 +47,8 @@ func init() {
&
BoundPods
{},
&
BoundPods
{},
)
)
// Legacy names are supported
// Legacy names are supported
Scheme
.
AddKnownTypeWithName
(
""
,
"
Node"
,
&
Minion
{})
Scheme
.
AddKnownTypeWithName
(
""
,
"
Minion"
,
&
Node
{})
Scheme
.
AddKnownTypeWithName
(
""
,
"
NodeList"
,
&
Minion
List
{})
Scheme
.
AddKnownTypeWithName
(
""
,
"
MinionList"
,
&
Node
List
{})
}
}
func
(
*
Pod
)
IsAnAPIObject
()
{}
func
(
*
Pod
)
IsAnAPIObject
()
{}
...
@@ -59,8 +59,8 @@ func (*Service) IsAnAPIObject() {}
...
@@ -59,8 +59,8 @@ func (*Service) IsAnAPIObject() {}
func
(
*
ServiceList
)
IsAnAPIObject
()
{}
func
(
*
ServiceList
)
IsAnAPIObject
()
{}
func
(
*
Endpoints
)
IsAnAPIObject
()
{}
func
(
*
Endpoints
)
IsAnAPIObject
()
{}
func
(
*
EndpointsList
)
IsAnAPIObject
()
{}
func
(
*
EndpointsList
)
IsAnAPIObject
()
{}
func
(
*
Minion
)
IsAnAPIObject
()
{}
func
(
*
Node
)
IsAnAPIObject
()
{}
func
(
*
MinionList
)
IsAnAPIObject
()
{}
func
(
*
NodeList
)
IsAnAPIObject
()
{}
func
(
*
Binding
)
IsAnAPIObject
()
{}
func
(
*
Binding
)
IsAnAPIObject
()
{}
func
(
*
Status
)
IsAnAPIObject
()
{}
func
(
*
Status
)
IsAnAPIObject
()
{}
func
(
*
ServerOp
)
IsAnAPIObject
()
{}
func
(
*
ServerOp
)
IsAnAPIObject
()
{}
...
...
pkg/api/types.go
View file @
19379b5a
...
@@ -672,10 +672,9 @@ type ResourceName string
...
@@ -672,10 +672,9 @@ type ResourceName string
type
ResourceList
map
[
ResourceName
]
util
.
IntOrString
type
ResourceList
map
[
ResourceName
]
util
.
IntOrString
// Minion is a worker node in Kubernetenes
// Node is a worker node in Kubernetenes
// The name of the minion according to etcd is in ObjectMeta.Name.
// The name of the node according to etcd is in ObjectMeta.Name.
// TODO: Rename to Node
type
Node
struct
{
type
Minion
struct
{
TypeMeta
`json:",inline"`
TypeMeta
`json:",inline"`
ObjectMeta
`json:"metadata,omitempty"`
ObjectMeta
`json:"metadata,omitempty"`
...
@@ -686,12 +685,12 @@ type Minion struct {
...
@@ -686,12 +685,12 @@ type Minion struct {
Status
NodeStatus
`json:"status,omitempty"`
Status
NodeStatus
`json:"status,omitempty"`
}
}
//
Minion
List is a list of minions.
//
Node
List is a list of minions.
type
Minion
List
struct
{
type
Node
List
struct
{
TypeMeta
`json:",inline"`
TypeMeta
`json:",inline"`
ListMeta
`json:"metadata,omitempty"`
ListMeta
`json:"metadata,omitempty"`
Items
[]
Minion
`json:"items"`
Items
[]
Node
`json:"items"`
}
}
// Binding is written by a scheduler to cause a pod to be bound to a host.
// Binding is written by a scheduler to cause a pod to be bound to a host.
...
...
pkg/api/v1beta1/conversion.go
View file @
19379b5a
...
@@ -137,7 +137,7 @@ func init() {
...
@@ -137,7 +137,7 @@ func init() {
},
},
// MinionList.Items had a wrong name in v1beta1
// MinionList.Items had a wrong name in v1beta1
func
(
in
*
newer
.
Minion
List
,
out
*
MinionList
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Node
List
,
out
*
MinionList
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -150,7 +150,7 @@ func init() {
...
@@ -150,7 +150,7 @@ func init() {
out
.
Minions
=
out
.
Items
out
.
Minions
=
out
.
Items
return
nil
return
nil
},
},
func
(
in
*
MinionList
,
out
*
newer
.
Minion
List
,
s
conversion
.
Scope
)
error
{
func
(
in
*
MinionList
,
out
*
newer
.
Node
List
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -444,7 +444,7 @@ func init() {
...
@@ -444,7 +444,7 @@ func init() {
return
nil
return
nil
},
},
func
(
in
*
newer
.
Minion
,
out
*
Minion
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Node
,
out
*
Minion
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -458,7 +458,7 @@ func init() {
...
@@ -458,7 +458,7 @@ func init() {
out
.
HostIP
=
in
.
Status
.
HostIP
out
.
HostIP
=
in
.
Status
.
HostIP
return
s
.
Convert
(
&
in
.
Spec
.
Capacity
,
&
out
.
NodeResources
.
Capacity
,
0
)
return
s
.
Convert
(
&
in
.
Spec
.
Capacity
,
&
out
.
NodeResources
.
Capacity
,
0
)
},
},
func
(
in
*
Minion
,
out
*
newer
.
Minion
,
s
conversion
.
Scope
)
error
{
func
(
in
*
Minion
,
out
*
newer
.
Node
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/api/v1beta1/conversion_test.go
View file @
19379b5a
...
@@ -31,7 +31,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -31,7 +31,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
@@ -39,7 +39,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -39,7 +39,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
List
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
List
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
@@ -141,39 +141,39 @@ func TestMinionListConversionToNew(t *testing.T) {
...
@@ -141,39 +141,39 @@ func TestMinionListConversionToNew(t *testing.T) {
oldMinion
:=
func
(
id
string
)
current
.
Minion
{
oldMinion
:=
func
(
id
string
)
current
.
Minion
{
return
current
.
Minion
{
TypeMeta
:
current
.
TypeMeta
{
ID
:
id
}}
return
current
.
Minion
{
TypeMeta
:
current
.
TypeMeta
{
ID
:
id
}}
}
}
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
newMinion
:=
func
(
id
string
)
newer
.
Node
{
return
newer
.
Minion
{
ObjectMeta
:
newer
.
ObjectMeta
{
Name
:
id
}}
return
newer
.
Node
{
ObjectMeta
:
newer
.
ObjectMeta
{
Name
:
id
}}
}
}
oldMinions
:=
[]
current
.
Minion
{
oldMinions
:=
[]
current
.
Minion
{
oldMinion
(
"foo"
),
oldMinion
(
"foo"
),
oldMinion
(
"bar"
),
oldMinion
(
"bar"
),
}
}
newMinions
:=
[]
newer
.
Minion
{
newMinions
:=
[]
newer
.
Node
{
newMinion
(
"foo"
),
newMinion
(
"foo"
),
newMinion
(
"bar"
),
newMinion
(
"bar"
),
}
}
table
:=
[]
struct
{
table
:=
[]
struct
{
oldML
*
current
.
MinionList
oldML
*
current
.
MinionList
newML
*
newer
.
Minion
List
newML
*
newer
.
Node
List
}{
}{
{
{
oldML
:
&
current
.
MinionList
{
Items
:
oldMinions
},
oldML
:
&
current
.
MinionList
{
Items
:
oldMinions
},
newML
:
&
newer
.
Minion
List
{
Items
:
newMinions
},
newML
:
&
newer
.
Node
List
{
Items
:
newMinions
},
},
{
},
{
oldML
:
&
current
.
MinionList
{
Minions
:
oldMinions
},
oldML
:
&
current
.
MinionList
{
Minions
:
oldMinions
},
newML
:
&
newer
.
Minion
List
{
Items
:
newMinions
},
newML
:
&
newer
.
Node
List
{
Items
:
newMinions
},
},
{
},
{
oldML
:
&
current
.
MinionList
{
oldML
:
&
current
.
MinionList
{
Items
:
oldMinions
,
Items
:
oldMinions
,
Minions
:
[]
current
.
Minion
{
oldMinion
(
"baz"
)},
Minions
:
[]
current
.
Minion
{
oldMinion
(
"baz"
)},
},
},
newML
:
&
newer
.
Minion
List
{
Items
:
newMinions
},
newML
:
&
newer
.
Node
List
{
Items
:
newMinions
},
},
},
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
got
:=
&
newer
.
Minion
List
{}
got
:=
&
newer
.
Node
List
{}
err
:=
Convert
(
item
.
oldML
,
got
)
err
:=
Convert
(
item
.
oldML
,
got
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
...
@@ -188,19 +188,19 @@ func TestMinionListConversionToOld(t *testing.T) {
...
@@ -188,19 +188,19 @@ func TestMinionListConversionToOld(t *testing.T) {
oldMinion
:=
func
(
id
string
)
current
.
Minion
{
oldMinion
:=
func
(
id
string
)
current
.
Minion
{
return
current
.
Minion
{
TypeMeta
:
current
.
TypeMeta
{
ID
:
id
}}
return
current
.
Minion
{
TypeMeta
:
current
.
TypeMeta
{
ID
:
id
}}
}
}
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
newMinion
:=
func
(
id
string
)
newer
.
Node
{
return
newer
.
Minion
{
ObjectMeta
:
newer
.
ObjectMeta
{
Name
:
id
}}
return
newer
.
Node
{
ObjectMeta
:
newer
.
ObjectMeta
{
Name
:
id
}}
}
}
oldMinions
:=
[]
current
.
Minion
{
oldMinions
:=
[]
current
.
Minion
{
oldMinion
(
"foo"
),
oldMinion
(
"foo"
),
oldMinion
(
"bar"
),
oldMinion
(
"bar"
),
}
}
newMinions
:=
[]
newer
.
Minion
{
newMinions
:=
[]
newer
.
Node
{
newMinion
(
"foo"
),
newMinion
(
"foo"
),
newMinion
(
"bar"
),
newMinion
(
"bar"
),
}
}
newML
:=
&
newer
.
Minion
List
{
Items
:
newMinions
}
newML
:=
&
newer
.
Node
List
{
Items
:
newMinions
}
oldML
:=
&
current
.
MinionList
{
oldML
:=
&
current
.
MinionList
{
Items
:
oldMinions
,
Items
:
oldMinions
,
Minions
:
oldMinions
,
Minions
:
oldMinions
,
...
...
pkg/api/v1beta2/conversion.go
View file @
19379b5a
...
@@ -374,7 +374,7 @@ func init() {
...
@@ -374,7 +374,7 @@ func init() {
return
nil
return
nil
},
},
func
(
in
*
newer
.
Minion
,
out
*
Minion
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Node
,
out
*
Minion
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -388,7 +388,7 @@ func init() {
...
@@ -388,7 +388,7 @@ func init() {
out
.
HostIP
=
in
.
Status
.
HostIP
out
.
HostIP
=
in
.
Status
.
HostIP
return
s
.
Convert
(
&
in
.
Spec
.
Capacity
,
&
out
.
NodeResources
.
Capacity
,
0
)
return
s
.
Convert
(
&
in
.
Spec
.
Capacity
,
&
out
.
NodeResources
.
Capacity
,
0
)
},
},
func
(
in
*
Minion
,
out
*
newer
.
Minion
,
s
conversion
.
Scope
)
error
{
func
(
in
*
Minion
,
out
*
newer
.
Node
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/api/v1beta2/conversion_test.go
View file @
19379b5a
...
@@ -60,7 +60,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
@@ -68,7 +68,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
List
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
List
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
...
pkg/api/v1beta3/conversion_test.go
View file @
19379b5a
...
@@ -28,7 +28,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -28,7 +28,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
@@ -36,7 +36,7 @@ func TestNodeConversion(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestNodeConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
_
,
ok
:=
obj
.
(
*
newer
.
Minion
List
);
!
ok
{
if
_
,
ok
:=
obj
.
(
*
newer
.
Node
List
);
!
ok
{
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
t
.
Errorf
(
"unexpected type: %#v"
,
obj
)
}
}
...
...
pkg/api/validation/validation.go
View file @
19379b5a
...
@@ -550,7 +550,7 @@ func ValidateBoundPod(pod *api.BoundPod) (errors []error) {
...
@@ -550,7 +550,7 @@ func ValidateBoundPod(pod *api.BoundPod) (errors []error) {
}
}
// ValidateMinion tests if required fields in the minion are set.
// ValidateMinion tests if required fields in the minion are set.
func
ValidateMinion
(
minion
*
api
.
Minion
)
errs
.
ValidationErrorList
{
func
ValidateMinion
(
minion
*
api
.
Node
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
len
(
minion
.
Namespace
)
!=
0
{
if
len
(
minion
.
Namespace
)
!=
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
minion
.
Namespace
,
""
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
minion
.
Namespace
,
""
))
...
@@ -563,7 +563,7 @@ func ValidateMinion(minion *api.Minion) errs.ValidationErrorList {
...
@@ -563,7 +563,7 @@ func ValidateMinion(minion *api.Minion) errs.ValidationErrorList {
}
}
// ValidateMinionUpdate tests to make sure a minion update can be applied. Modifies oldMinion.
// ValidateMinionUpdate tests to make sure a minion update can be applied. Modifies oldMinion.
func
ValidateMinionUpdate
(
oldMinion
*
api
.
Minion
,
minion
*
api
.
Minion
)
errs
.
ValidationErrorList
{
func
ValidateMinionUpdate
(
oldMinion
*
api
.
Node
,
minion
*
api
.
Node
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
oldMinion
.
Labels
=
minion
.
Labels
oldMinion
.
Labels
=
minion
.
Labels
if
!
reflect
.
DeepEqual
(
oldMinion
,
minion
)
{
if
!
reflect
.
DeepEqual
(
oldMinion
,
minion
)
{
...
...
pkg/api/validation/validation_test.go
View file @
19379b5a
...
@@ -1077,7 +1077,7 @@ func TestValidateBoundPodNoName(t *testing.T) {
...
@@ -1077,7 +1077,7 @@ func TestValidateBoundPodNoName(t *testing.T) {
func
TestValidateMinion
(
t
*
testing
.
T
)
{
func
TestValidateMinion
(
t
*
testing
.
T
)
{
validSelector
:=
map
[
string
]
string
{
"a"
:
"b"
}
validSelector
:=
map
[
string
]
string
{
"a"
:
"b"
}
invalidSelector
:=
map
[
string
]
string
{
"NoUppercaseOrSpecialCharsLike=Equals"
:
"b"
}
invalidSelector
:=
map
[
string
]
string
{
"NoUppercaseOrSpecialCharsLike=Equals"
:
"b"
}
successCases
:=
[]
api
.
Minion
{
successCases
:=
[]
api
.
Node
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Name
:
"abc"
,
...
@@ -1100,7 +1100,7 @@ func TestValidateMinion(t *testing.T) {
...
@@ -1100,7 +1100,7 @@ func TestValidateMinion(t *testing.T) {
}
}
}
}
errorCases
:=
map
[
string
]
api
.
Minion
{
errorCases
:=
map
[
string
]
api
.
Node
{
"zero-length Name"
:
{
"zero-length Name"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Name
:
""
,
...
@@ -1134,45 +1134,45 @@ func TestValidateMinion(t *testing.T) {
...
@@ -1134,45 +1134,45 @@ func TestValidateMinion(t *testing.T) {
func
TestValidateMinionUpdate
(
t
*
testing
.
T
)
{
func
TestValidateMinionUpdate
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
oldMinion
api
.
Minion
oldMinion
api
.
Node
minion
api
.
Minion
minion
api
.
Node
valid
bool
valid
bool
}{
}{
{
api
.
Minion
{},
api
.
Minion
{},
true
},
{
api
.
Node
{},
api
.
Node
{},
true
},
{
api
.
Minion
{
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
Name
:
"foo"
}},
api
.
Minion
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
},
Name
:
"bar"
},
},
false
},
},
false
},
{
api
.
Minion
{
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
api
.
Minion
{
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
},
},
},
true
},
},
true
},
{
api
.
Minion
{
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
},
api
.
Minion
{
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
},
},
},
true
},
},
true
},
{
api
.
Minion
{
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"bar"
:
"foo"
},
Labels
:
map
[
string
]
string
{
"bar"
:
"foo"
},
},
},
},
api
.
Minion
{
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
...
...
pkg/client/client_test.go
View file @
19379b5a
...
@@ -604,7 +604,7 @@ func TestGetServerAPIVersions(t *testing.T) {
...
@@ -604,7 +604,7 @@ func TestGetServerAPIVersions(t *testing.T) {
func
TestListMinions
(
t
*
testing
.
T
)
{
func
TestListMinions
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions"
},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Minion
List
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Node
List
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
Minions
()
.
List
()
response
,
err
:=
c
.
Setup
()
.
Minions
()
.
List
()
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
...
@@ -613,14 +613,14 @@ func TestListMinions(t *testing.T) {
...
@@ -613,14 +613,14 @@ func TestListMinions(t *testing.T) {
func
TestGetMinion
(
t
*
testing
.
T
)
{
func
TestGetMinion
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions/1"
},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions/1"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"minion-1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"minion-1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
Minions
()
.
Get
(
"1"
)
response
,
err
:=
c
.
Setup
()
.
Minions
()
.
Get
(
"1"
)
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
}
}
func
TestCreateMinion
(
t
*
testing
.
T
)
{
func
TestCreateMinion
(
t
*
testing
.
T
)
{
requestMinion
:=
&
api
.
Minion
{
requestMinion
:=
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"minion-1"
,
Name
:
"minion-1"
,
},
},
...
...
pkg/client/fake.go
View file @
19379b5a
...
@@ -39,7 +39,7 @@ type Fake struct {
...
@@ -39,7 +39,7 @@ type Fake struct {
Ctrl
api
.
ReplicationController
Ctrl
api
.
ReplicationController
ServiceList
api
.
ServiceList
ServiceList
api
.
ServiceList
EndpointsList
api
.
EndpointsList
EndpointsList
api
.
EndpointsList
MinionsList
api
.
Minion
List
MinionsList
api
.
Node
List
EventsList
api
.
EventList
EventsList
api
.
EventList
Err
error
Err
error
Watch
watch
.
Interface
Watch
watch
.
Interface
...
...
pkg/client/fake_minions.go
View file @
19379b5a
...
@@ -26,19 +26,19 @@ type FakeMinions struct {
...
@@ -26,19 +26,19 @@ type FakeMinions struct {
Fake
*
Fake
Fake
*
Fake
}
}
func
(
c
*
FakeMinions
)
Get
(
name
string
)
(
*
api
.
Minion
,
error
)
{
func
(
c
*
FakeMinions
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-minion"
,
Value
:
name
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-minion"
,
Value
:
name
})
return
&
api
.
Minion
{},
nil
return
&
api
.
Node
{},
nil
}
}
func
(
c
*
FakeMinions
)
List
()
(
*
api
.
Minion
List
,
error
)
{
func
(
c
*
FakeMinions
)
List
()
(
*
api
.
Node
List
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-minions"
,
Value
:
nil
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-minions"
,
Value
:
nil
})
return
&
c
.
Fake
.
MinionsList
,
nil
return
&
c
.
Fake
.
MinionsList
,
nil
}
}
func
(
c
*
FakeMinions
)
Create
(
minion
*
api
.
Minion
)
(
*
api
.
Minion
,
error
)
{
func
(
c
*
FakeMinions
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-minion"
,
Value
:
minion
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-minion"
,
Value
:
minion
})
return
&
api
.
Minion
{},
nil
return
&
api
.
Node
{},
nil
}
}
func
(
c
*
FakeMinions
)
Delete
(
id
string
)
error
{
func
(
c
*
FakeMinions
)
Delete
(
id
string
)
error
{
...
...
pkg/client/minions.go
View file @
19379b5a
...
@@ -23,9 +23,9 @@ type MinionsInterface interface {
...
@@ -23,9 +23,9 @@ type MinionsInterface interface {
}
}
type
MinionInterface
interface
{
type
MinionInterface
interface
{
Get
(
id
string
)
(
result
*
api
.
Minion
,
err
error
)
Get
(
id
string
)
(
result
*
api
.
Node
,
err
error
)
Create
(
minion
*
api
.
Minion
)
(
*
api
.
Minion
,
error
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
List
()
(
*
api
.
Minion
List
,
error
)
List
()
(
*
api
.
Node
List
,
error
)
Delete
(
id
string
)
error
Delete
(
id
string
)
error
}
}
...
@@ -40,22 +40,22 @@ func newMinions(c *Client) *minions {
...
@@ -40,22 +40,22 @@ func newMinions(c *Client) *minions {
}
}
// Create creates a new minion.
// Create creates a new minion.
func
(
c
*
minions
)
Create
(
minion
*
api
.
Minion
)
(
*
api
.
Minion
,
error
)
{
func
(
c
*
minions
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
result
:=
&
api
.
Minion
{}
result
:=
&
api
.
Node
{}
err
:=
c
.
r
.
Post
()
.
Path
(
"minions"
)
.
Body
(
minion
)
.
Do
()
.
Into
(
result
)
err
:=
c
.
r
.
Post
()
.
Path
(
"minions"
)
.
Body
(
minion
)
.
Do
()
.
Into
(
result
)
return
result
,
err
return
result
,
err
}
}
// List lists all the minions in the cluster.
// List lists all the minions in the cluster.
func
(
c
*
minions
)
List
()
(
*
api
.
Minion
List
,
error
)
{
func
(
c
*
minions
)
List
()
(
*
api
.
Node
List
,
error
)
{
result
:=
&
api
.
Minion
List
{}
result
:=
&
api
.
Node
List
{}
err
:=
c
.
r
.
Get
()
.
Path
(
"minions"
)
.
Do
()
.
Into
(
result
)
err
:=
c
.
r
.
Get
()
.
Path
(
"minions"
)
.
Do
()
.
Into
(
result
)
return
result
,
err
return
result
,
err
}
}
// Get gets an existing minion
// Get gets an existing minion
func
(
c
*
minions
)
Get
(
id
string
)
(
*
api
.
Minion
,
error
)
{
func
(
c
*
minions
)
Get
(
id
string
)
(
*
api
.
Node
,
error
)
{
result
:=
&
api
.
Minion
{}
result
:=
&
api
.
Node
{}
err
:=
c
.
r
.
Get
()
.
Path
(
"minions"
)
.
Path
(
id
)
.
Do
()
.
Into
(
result
)
err
:=
c
.
r
.
Get
()
.
Path
(
"minions"
)
.
Path
(
id
)
.
Do
()
.
Into
(
result
)
return
result
,
err
return
result
,
err
}
}
...
...
pkg/cloudprovider/controller/minioncontroller.go
View file @
19379b5a
...
@@ -73,7 +73,7 @@ func (s *MinionController) SyncStatic(period time.Duration) error {
...
@@ -73,7 +73,7 @@ func (s *MinionController) SyncStatic(period time.Duration) error {
if
registered
.
Has
(
minionID
)
{
if
registered
.
Has
(
minionID
)
{
continue
continue
}
}
_
,
err
:=
s
.
kubeClient
.
Minions
()
.
Create
(
&
api
.
Minion
{
_
,
err
:=
s
.
kubeClient
.
Minions
()
.
Create
(
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
minionID
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
minionID
},
Spec
:
api
.
NodeSpec
{
Spec
:
api
.
NodeSpec
{
Capacity
:
s
.
staticResources
.
Capacity
,
Capacity
:
s
.
staticResources
.
Capacity
,
...
@@ -101,7 +101,7 @@ func (s *MinionController) SyncCloud() error {
...
@@ -101,7 +101,7 @@ func (s *MinionController) SyncCloud() error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
minionMap
:=
make
(
map
[
string
]
*
api
.
Minion
)
minionMap
:=
make
(
map
[
string
]
*
api
.
Node
)
for
_
,
minion
:=
range
minions
.
Items
{
for
_
,
minion
:=
range
minions
.
Items
{
minionMap
[
minion
.
Name
]
=
&
minion
minionMap
[
minion
.
Name
]
=
&
minion
}
}
...
@@ -128,8 +128,8 @@ func (s *MinionController) SyncCloud() error {
...
@@ -128,8 +128,8 @@ func (s *MinionController) SyncCloud() error {
return
nil
return
nil
}
}
// cloudMinions constructs and returns api.
Minion
List from cloudprovider.
// cloudMinions constructs and returns api.
Node
List from cloudprovider.
func
(
s
*
MinionController
)
cloudMinions
()
(
*
api
.
Minion
List
,
error
)
{
func
(
s
*
MinionController
)
cloudMinions
()
(
*
api
.
Node
List
,
error
)
{
instances
,
ok
:=
s
.
cloud
.
Instances
()
instances
,
ok
:=
s
.
cloud
.
Instances
()
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"cloud doesn't support instances"
)
return
nil
,
fmt
.
Errorf
(
"cloud doesn't support instances"
)
...
@@ -138,8 +138,8 @@ func (s *MinionController) cloudMinions() (*api.MinionList, error) {
...
@@ -138,8 +138,8 @@ func (s *MinionController) cloudMinions() (*api.MinionList, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
result
:=
&
api
.
Minion
List
{
result
:=
&
api
.
Node
List
{
Items
:
make
([]
api
.
Minion
,
len
(
matches
)),
Items
:
make
([]
api
.
Node
,
len
(
matches
)),
}
}
for
i
:=
range
matches
{
for
i
:=
range
matches
{
result
.
Items
[
i
]
.
Name
=
matches
[
i
]
result
.
Items
[
i
]
.
Name
=
matches
[
i
]
...
...
pkg/cloudprovider/controller/minioncontroller_test.go
View file @
19379b5a
...
@@ -26,8 +26,8 @@ import (
...
@@ -26,8 +26,8 @@ import (
fake_cloud
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
fake_cloud
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
)
)
func
newMinion
(
name
string
)
*
api
.
Minion
{
func
newMinion
(
name
string
)
*
api
.
Node
{
return
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}}
return
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}}
}
}
type
FakeMinionHandler
struct
{
type
FakeMinionHandler
struct
{
...
@@ -35,12 +35,12 @@ type FakeMinionHandler struct {
...
@@ -35,12 +35,12 @@ type FakeMinionHandler struct {
client
.
FakeMinions
client
.
FakeMinions
// Input: Hooks determine if request is valid or not
// Input: Hooks determine if request is valid or not
CreateHook
func
(
*
FakeMinionHandler
,
*
api
.
Minion
)
bool
CreateHook
func
(
*
FakeMinionHandler
,
*
api
.
Node
)
bool
Existing
[]
*
api
.
Minion
Existing
[]
*
api
.
Node
// Output
// Output
CreatedMinions
[]
*
api
.
Minion
CreatedMinions
[]
*
api
.
Node
DeletedMinions
[]
*
api
.
Minion
DeletedMinions
[]
*
api
.
Node
RequestCount
int
RequestCount
int
}
}
...
@@ -48,7 +48,7 @@ func (c *FakeMinionHandler) Minions() client.MinionInterface {
...
@@ -48,7 +48,7 @@ func (c *FakeMinionHandler) Minions() client.MinionInterface {
return
c
return
c
}
}
func
(
m
*
FakeMinionHandler
)
Create
(
minion
*
api
.
Minion
)
(
*
api
.
Minion
,
error
)
{
func
(
m
*
FakeMinionHandler
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
defer
func
()
{
m
.
RequestCount
++
}()
defer
func
()
{
m
.
RequestCount
++
}()
if
m
.
CreateHook
==
nil
||
m
.
CreateHook
(
m
,
minion
)
{
if
m
.
CreateHook
==
nil
||
m
.
CreateHook
(
m
,
minion
)
{
m
.
CreatedMinions
=
append
(
m
.
CreatedMinions
,
minion
)
m
.
CreatedMinions
=
append
(
m
.
CreatedMinions
,
minion
)
...
@@ -58,9 +58,9 @@ func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) {
...
@@ -58,9 +58,9 @@ func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) {
}
}
}
}
func
(
m
*
FakeMinionHandler
)
List
()
(
*
api
.
Minion
List
,
error
)
{
func
(
m
*
FakeMinionHandler
)
List
()
(
*
api
.
Node
List
,
error
)
{
defer
func
()
{
m
.
RequestCount
++
}()
defer
func
()
{
m
.
RequestCount
++
}()
minions
:=
[]
api
.
Minion
{}
minions
:=
[]
api
.
Node
{}
for
i
:=
0
;
i
<
len
(
m
.
Existing
);
i
++
{
for
i
:=
0
;
i
<
len
(
m
.
Existing
);
i
++
{
if
!
contains
(
m
.
Existing
[
i
],
m
.
DeletedMinions
)
{
if
!
contains
(
m
.
Existing
[
i
],
m
.
DeletedMinions
)
{
minions
=
append
(
minions
,
*
m
.
Existing
[
i
])
minions
=
append
(
minions
,
*
m
.
Existing
[
i
])
...
@@ -71,7 +71,7 @@ func (m *FakeMinionHandler) List() (*api.MinionList, error) {
...
@@ -71,7 +71,7 @@ func (m *FakeMinionHandler) List() (*api.MinionList, error) {
minions
=
append
(
minions
,
*
m
.
CreatedMinions
[
i
])
minions
=
append
(
minions
,
*
m
.
CreatedMinions
[
i
])
}
}
}
}
return
&
api
.
Minion
List
{
Items
:
minions
},
nil
return
&
api
.
Node
List
{
Items
:
minions
},
nil
}
}
func
(
m
*
FakeMinionHandler
)
Delete
(
id
string
)
error
{
func
(
m
*
FakeMinionHandler
)
Delete
(
id
string
)
error
{
...
@@ -82,7 +82,7 @@ func (m *FakeMinionHandler) Delete(id string) error {
...
@@ -82,7 +82,7 @@ func (m *FakeMinionHandler) Delete(id string) error {
func
TestSyncStaticCreateMinion
(
t
*
testing
.
T
)
{
func
TestSyncStaticCreateMinion
(
t
*
testing
.
T
)
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
CreateHook
:
func
(
fake
*
FakeMinionHandler
,
minion
*
api
.
Minion
)
bool
{
CreateHook
:
func
(
fake
*
FakeMinionHandler
,
minion
*
api
.
Node
)
bool
{
return
true
return
true
},
},
}
}
...
@@ -104,7 +104,7 @@ func TestSyncStaticCreateMinion(t *testing.T) {
...
@@ -104,7 +104,7 @@ func TestSyncStaticCreateMinion(t *testing.T) {
func
TestSyncStaticCreateMinionWithError
(
t
*
testing
.
T
)
{
func
TestSyncStaticCreateMinionWithError
(
t
*
testing
.
T
)
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
CreateHook
:
func
(
fake
*
FakeMinionHandler
,
minion
*
api
.
Minion
)
bool
{
CreateHook
:
func
(
fake
*
FakeMinionHandler
,
minion
*
api
.
Node
)
bool
{
if
fake
.
RequestCount
==
0
{
if
fake
.
RequestCount
==
0
{
return
false
return
false
}
}
...
@@ -129,7 +129,7 @@ func TestSyncStaticCreateMinionWithError(t *testing.T) {
...
@@ -129,7 +129,7 @@ func TestSyncStaticCreateMinionWithError(t *testing.T) {
func
TestSyncCloudCreateMinion
(
t
*
testing
.
T
)
{
func
TestSyncCloudCreateMinion
(
t
*
testing
.
T
)
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
Existing
:
[]
*
api
.
Minion
{
newMinion
(
"minion0"
)},
Existing
:
[]
*
api
.
Node
{
newMinion
(
"minion0"
)},
}
}
instances
:=
[]
string
{
"minion0"
,
"minion1"
}
instances
:=
[]
string
{
"minion0"
,
"minion1"
}
fakeCloud
:=
fake_cloud
.
FakeCloud
{
fakeCloud
:=
fake_cloud
.
FakeCloud
{
...
@@ -153,7 +153,7 @@ func TestSyncCloudCreateMinion(t *testing.T) {
...
@@ -153,7 +153,7 @@ func TestSyncCloudCreateMinion(t *testing.T) {
func
TestSyncCloudDeleteMinion
(
t
*
testing
.
T
)
{
func
TestSyncCloudDeleteMinion
(
t
*
testing
.
T
)
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
Existing
:
[]
*
api
.
Minion
{
newMinion
(
"minion0"
),
newMinion
(
"minion1"
)},
Existing
:
[]
*
api
.
Node
{
newMinion
(
"minion0"
),
newMinion
(
"minion1"
)},
}
}
instances
:=
[]
string
{
"minion0"
}
instances
:=
[]
string
{
"minion0"
}
fakeCloud
:=
fake_cloud
.
FakeCloud
{
fakeCloud
:=
fake_cloud
.
FakeCloud
{
...
@@ -177,7 +177,7 @@ func TestSyncCloudDeleteMinion(t *testing.T) {
...
@@ -177,7 +177,7 @@ func TestSyncCloudDeleteMinion(t *testing.T) {
func
TestSyncCloudRegexp
(
t
*
testing
.
T
)
{
func
TestSyncCloudRegexp
(
t
*
testing
.
T
)
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
fakeMinionHandler
:=
&
FakeMinionHandler
{
Existing
:
[]
*
api
.
Minion
{
newMinion
(
"minion0"
)},
Existing
:
[]
*
api
.
Node
{
newMinion
(
"minion0"
)},
}
}
instances
:=
[]
string
{
"minion0"
,
"minion1"
,
"node0"
}
instances
:=
[]
string
{
"minion0"
,
"minion1"
,
"node0"
}
fakeCloud
:=
fake_cloud
.
FakeCloud
{
fakeCloud
:=
fake_cloud
.
FakeCloud
{
...
@@ -199,7 +199,7 @@ func TestSyncCloudRegexp(t *testing.T) {
...
@@ -199,7 +199,7 @@ func TestSyncCloudRegexp(t *testing.T) {
}
}
}
}
func
contains
(
minion
*
api
.
Minion
,
minions
[]
*
api
.
Minion
)
bool
{
func
contains
(
minion
*
api
.
Node
,
minions
[]
*
api
.
Node
)
bool
{
for
i
:=
0
;
i
<
len
(
minions
);
i
++
{
for
i
:=
0
;
i
<
len
(
minions
);
i
++
{
if
minion
.
Name
==
minions
[
i
]
.
Name
{
if
minion
.
Name
==
minions
[
i
]
.
Name
{
return
true
return
true
...
...
pkg/kubecfg/resource_printer.go
View file @
19379b5a
...
@@ -248,12 +248,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
...
@@ -248,12 +248,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
return
nil
return
nil
}
}
func
printMinion
(
minion
*
api
.
Minion
,
w
io
.
Writer
)
error
{
func
printMinion
(
minion
*
api
.
Node
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\n
"
,
minion
.
Name
,
labels
.
Set
(
minion
.
Labels
))
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\n
"
,
minion
.
Name
,
labels
.
Set
(
minion
.
Labels
))
return
err
return
err
}
}
func
printMinionList
(
list
*
api
.
Minion
List
,
w
io
.
Writer
)
error
{
func
printMinionList
(
list
*
api
.
Node
List
,
w
io
.
Writer
)
error
{
for
_
,
minion
:=
range
list
.
Items
{
for
_
,
minion
:=
range
list
.
Items
{
if
err
:=
printMinion
(
&
minion
,
w
);
err
!=
nil
{
if
err
:=
printMinion
(
&
minion
,
w
);
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/resource_printer.go
View file @
19379b5a
...
@@ -296,12 +296,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
...
@@ -296,12 +296,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
return
nil
return
nil
}
}
func
printMinion
(
minion
*
api
.
Minion
,
w
io
.
Writer
)
error
{
func
printMinion
(
minion
*
api
.
Node
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\n
"
,
minion
.
Name
,
formatLabels
(
minion
.
Labels
))
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\n
"
,
minion
.
Name
,
formatLabels
(
minion
.
Labels
))
return
err
return
err
}
}
func
printMinionList
(
list
*
api
.
Minion
List
,
w
io
.
Writer
)
error
{
func
printMinionList
(
list
*
api
.
Node
List
,
w
io
.
Writer
)
error
{
for
_
,
minion
:=
range
list
.
Items
{
for
_
,
minion
:=
range
list
.
Items
{
if
err
:=
printMinion
(
&
minion
,
w
);
err
!=
nil
{
if
err
:=
printMinion
(
&
minion
,
w
);
err
!=
nil
{
return
err
return
err
...
...
pkg/registry/etcd/etcd.go
View file @
19379b5a
...
@@ -559,26 +559,26 @@ func makeMinionKey(minionID string) string {
...
@@ -559,26 +559,26 @@ func makeMinionKey(minionID string) string {
return
"/registry/minions/"
+
minionID
return
"/registry/minions/"
+
minionID
}
}
func
(
r
*
Registry
)
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Minion
List
,
error
)
{
func
(
r
*
Registry
)
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Node
List
,
error
)
{
minions
:=
&
api
.
Minion
List
{}
minions
:=
&
api
.
Node
List
{}
err
:=
r
.
ExtractToList
(
"/registry/minions"
,
minions
)
err
:=
r
.
ExtractToList
(
"/registry/minions"
,
minions
)
return
minions
,
err
return
minions
,
err
}
}
func
(
r
*
Registry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
Registry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
// TODO: Add some validations.
// TODO: Add some validations.
err
:=
r
.
CreateObj
(
makeMinionKey
(
minion
.
Name
),
minion
,
0
)
err
:=
r
.
CreateObj
(
makeMinionKey
(
minion
.
Name
),
minion
,
0
)
return
etcderr
.
InterpretCreateError
(
err
,
"minion"
,
minion
.
Name
)
return
etcderr
.
InterpretCreateError
(
err
,
"minion"
,
minion
.
Name
)
}
}
func
(
r
*
Registry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
Registry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
// TODO: Add some validations.
// TODO: Add some validations.
err
:=
r
.
SetObj
(
makeMinionKey
(
minion
.
Name
),
minion
)
err
:=
r
.
SetObj
(
makeMinionKey
(
minion
.
Name
),
minion
)
return
etcderr
.
InterpretUpdateError
(
err
,
"minion"
,
minion
.
Name
)
return
etcderr
.
InterpretUpdateError
(
err
,
"minion"
,
minion
.
Name
)
}
}
func
(
r
*
Registry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Minion
,
error
)
{
func
(
r
*
Registry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Node
,
error
)
{
var
minion
api
.
Minion
var
minion
api
.
Node
key
:=
makeMinionKey
(
minionID
)
key
:=
makeMinionKey
(
minionID
)
err
:=
r
.
ExtractObj
(
key
,
&
minion
,
false
)
err
:=
r
.
ExtractObj
(
key
,
&
minion
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/registry/etcd/etcd_test.go
View file @
19379b5a
...
@@ -1364,12 +1364,12 @@ func TestEtcdListMinions(t *testing.T) {
...
@@ -1364,12 +1364,12 @@ func TestEtcdListMinions(t *testing.T) {
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
{
{
Value
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
Value
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
}),
}),
},
},
{
{
Value
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
Value
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
},
}),
}),
},
},
...
@@ -1393,7 +1393,7 @@ func TestEtcdCreateMinion(t *testing.T) {
...
@@ -1393,7 +1393,7 @@ func TestEtcdCreateMinion(t *testing.T) {
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
err
:=
registry
.
CreateMinion
(
ctx
,
&
api
.
Minion
{
err
:=
registry
.
CreateMinion
(
ctx
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -1405,7 +1405,7 @@ func TestEtcdCreateMinion(t *testing.T) {
...
@@ -1405,7 +1405,7 @@ func TestEtcdCreateMinion(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
var
minion
api
.
Minion
var
minion
api
.
Node
err
=
latest
.
Codec
.
DecodeInto
([]
byte
(
resp
.
Node
.
Value
),
&
minion
)
err
=
latest
.
Codec
.
DecodeInto
([]
byte
(
resp
.
Node
.
Value
),
&
minion
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
@@ -1419,7 +1419,7 @@ func TestEtcdCreateMinion(t *testing.T) {
...
@@ -1419,7 +1419,7 @@ func TestEtcdCreateMinion(t *testing.T) {
func
TestEtcdGetMinion
(
t
*
testing
.
T
)
{
func
TestEtcdGetMinion
(
t
*
testing
.
T
)
{
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
.
Set
(
"/registry/minions/foo"
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
fakeClient
.
Set
(
"/registry/minions/foo"
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
minion
,
err
:=
registry
.
GetMinion
(
ctx
,
"foo"
)
minion
,
err
:=
registry
.
GetMinion
(
ctx
,
"foo"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/registry/minion/healthy_registry.go
View file @
19379b5a
...
@@ -36,7 +36,7 @@ func NewHealthyRegistry(delegate Registry, client client.KubeletHealthChecker) R
...
@@ -36,7 +36,7 @@ func NewHealthyRegistry(delegate Registry, client client.KubeletHealthChecker) R
}
}
}
}
func
(
r
*
HealthyRegistry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Minion
,
error
)
{
func
(
r
*
HealthyRegistry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Node
,
error
)
{
minion
,
err
:=
r
.
delegate
.
GetMinion
(
ctx
,
minionID
)
minion
,
err
:=
r
.
delegate
.
GetMinion
(
ctx
,
minionID
)
if
minion
==
nil
{
if
minion
==
nil
{
return
nil
,
ErrDoesNotExist
return
nil
,
ErrDoesNotExist
...
@@ -58,16 +58,16 @@ func (r *HealthyRegistry) DeleteMinion(ctx api.Context, minionID string) error {
...
@@ -58,16 +58,16 @@ func (r *HealthyRegistry) DeleteMinion(ctx api.Context, minionID string) error {
return
r
.
delegate
.
DeleteMinion
(
ctx
,
minionID
)
return
r
.
delegate
.
DeleteMinion
(
ctx
,
minionID
)
}
}
func
(
r
*
HealthyRegistry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
HealthyRegistry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
return
r
.
delegate
.
CreateMinion
(
ctx
,
minion
)
return
r
.
delegate
.
CreateMinion
(
ctx
,
minion
)
}
}
func
(
r
*
HealthyRegistry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
HealthyRegistry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
return
r
.
delegate
.
UpdateMinion
(
ctx
,
minion
)
return
r
.
delegate
.
UpdateMinion
(
ctx
,
minion
)
}
}
func
(
r
*
HealthyRegistry
)
ListMinions
(
ctx
api
.
Context
)
(
currentMinions
*
api
.
Minion
List
,
err
error
)
{
func
(
r
*
HealthyRegistry
)
ListMinions
(
ctx
api
.
Context
)
(
currentMinions
*
api
.
Node
List
,
err
error
)
{
result
:=
&
api
.
Minion
List
{}
result
:=
&
api
.
Node
List
{}
list
,
err
:=
r
.
delegate
.
ListMinions
(
ctx
)
list
,
err
:=
r
.
delegate
.
ListMinions
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
result
,
err
return
result
,
err
...
...
pkg/registry/minion/healthy_registry_test.go
View file @
19379b5a
...
@@ -45,7 +45,7 @@ func TestBasicDelegation(t *testing.T) {
...
@@ -45,7 +45,7 @@ func TestBasicDelegation(t *testing.T) {
if
!
reflect
.
DeepEqual
(
list
,
&
mockMinionRegistry
.
Minions
)
{
if
!
reflect
.
DeepEqual
(
list
,
&
mockMinionRegistry
.
Minions
)
{
t
.
Errorf
(
"Expected %v, Got %v"
,
mockMinionRegistry
.
Minions
,
list
)
t
.
Errorf
(
"Expected %v, Got %v"
,
mockMinionRegistry
.
Minions
,
list
)
}
}
err
=
healthy
.
CreateMinion
(
ctx
,
&
api
.
Minion
{
err
=
healthy
.
CreateMinion
(
ctx
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/registry/minion/registry.go
View file @
19379b5a
...
@@ -20,9 +20,9 @@ import "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -20,9 +20,9 @@ import "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
// MinionRegistry is an interface for things that know how to store minions.
// MinionRegistry is an interface for things that know how to store minions.
type
Registry
interface
{
type
Registry
interface
{
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Minion
List
,
error
)
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Node
List
,
error
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Minion
,
error
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Node
,
error
)
DeleteMinion
(
ctx
api
.
Context
,
minionID
string
)
error
DeleteMinion
(
ctx
api
.
Context
,
minionID
string
)
error
}
}
pkg/registry/minion/rest.go
View file @
19379b5a
...
@@ -47,7 +47,7 @@ var ErrDoesNotExist = errors.New("The requested resource does not exist.")
...
@@ -47,7 +47,7 @@ var ErrDoesNotExist = errors.New("The requested resource does not exist.")
var
ErrNotHealty
=
errors
.
New
(
"The requested minion is not healthy."
)
var
ErrNotHealty
=
errors
.
New
(
"The requested minion is not healthy."
)
func
(
rs
*
REST
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
<-
chan
apiserver
.
RESTResult
,
error
)
{
func
(
rs
*
REST
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
<-
chan
apiserver
.
RESTResult
,
error
)
{
minion
,
ok
:=
obj
.
(
*
api
.
Minion
)
minion
,
ok
:=
obj
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"not a minion: %#v"
,
obj
)
return
nil
,
fmt
.
Errorf
(
"not a minion: %#v"
,
obj
)
}
}
...
@@ -93,11 +93,11 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
...
@@ -93,11 +93,11 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
}
}
func
(
rs
*
REST
)
New
()
runtime
.
Object
{
func
(
rs
*
REST
)
New
()
runtime
.
Object
{
return
&
api
.
Minion
{}
return
&
api
.
Node
{}
}
}
func
(
rs
*
REST
)
Update
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
<-
chan
apiserver
.
RESTResult
,
error
)
{
func
(
rs
*
REST
)
Update
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
<-
chan
apiserver
.
RESTResult
,
error
)
{
minion
,
ok
:=
obj
.
(
*
api
.
Minion
)
minion
,
ok
:=
obj
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"not a minion: %#v"
,
obj
)
return
nil
,
fmt
.
Errorf
(
"not a minion: %#v"
,
obj
)
}
}
...
@@ -121,8 +121,8 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
...
@@ -121,8 +121,8 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
}),
nil
}),
nil
}
}
func
(
rs
*
REST
)
toApiMinion
(
name
string
)
*
api
.
Minion
{
func
(
rs
*
REST
)
toApiMinion
(
name
string
)
*
api
.
Node
{
return
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}}
return
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}}
}
}
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
...
...
pkg/registry/minion/rest_test.go
View file @
19379b5a
...
@@ -28,28 +28,28 @@ import (
...
@@ -28,28 +28,28 @@ import (
func
TestMinionREST
(
t
*
testing
.
T
)
{
func
TestMinionREST
(
t
*
testing
.
T
)
{
ms
:=
NewREST
(
registrytest
.
NewMinionRegistry
([]
string
{
"foo"
,
"bar"
},
api
.
NodeResources
{}))
ms
:=
NewREST
(
registrytest
.
NewMinionRegistry
([]
string
{
"foo"
,
"bar"
},
api
.
NodeResources
{}))
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"foo"
);
err
!=
nil
||
obj
.
(
*
api
.
Minion
)
.
Name
!=
"foo"
{
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"foo"
);
err
!=
nil
||
obj
.
(
*
api
.
Node
)
.
Name
!=
"foo"
{
t
.
Errorf
(
"missing expected object"
)
t
.
Errorf
(
"missing expected object"
)
}
}
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"bar"
);
err
!=
nil
||
obj
.
(
*
api
.
Minion
)
.
Name
!=
"bar"
{
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"bar"
);
err
!=
nil
||
obj
.
(
*
api
.
Node
)
.
Name
!=
"bar"
{
t
.
Errorf
(
"missing expected object"
)
t
.
Errorf
(
"missing expected object"
)
}
}
if
_
,
err
:=
ms
.
Get
(
ctx
,
"baz"
);
err
!=
ErrDoesNotExist
{
if
_
,
err
:=
ms
.
Get
(
ctx
,
"baz"
);
err
!=
ErrDoesNotExist
{
t
.
Errorf
(
"has unexpected object"
)
t
.
Errorf
(
"has unexpected object"
)
}
}
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
}})
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"insert failed"
)
t
.
Errorf
(
"insert failed"
)
}
}
obj
:=
<-
c
obj
:=
<-
c
if
!
api
.
HasObjectMetaSystemFieldValues
(
&
obj
.
Object
.
(
*
api
.
Minion
)
.
ObjectMeta
)
{
if
!
api
.
HasObjectMetaSystemFieldValues
(
&
obj
.
Object
.
(
*
api
.
Node
)
.
ObjectMeta
)
{
t
.
Errorf
(
"storage did not populate object meta field values"
)
t
.
Errorf
(
"storage did not populate object meta field values"
)
}
}
if
m
,
ok
:=
obj
.
Object
.
(
*
api
.
Minion
);
!
ok
||
m
.
Name
!=
"baz"
{
if
m
,
ok
:=
obj
.
Object
.
(
*
api
.
Node
);
!
ok
||
m
.
Name
!=
"baz"
{
t
.
Errorf
(
"insert return value was weird: %#v"
,
obj
)
t
.
Errorf
(
"insert return value was weird: %#v"
,
obj
)
}
}
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"baz"
);
err
!=
nil
||
obj
.
(
*
api
.
Minion
)
.
Name
!=
"baz"
{
if
obj
,
err
:=
ms
.
Get
(
ctx
,
"baz"
);
err
!=
nil
||
obj
.
(
*
api
.
Node
)
.
Name
!=
"baz"
{
t
.
Errorf
(
"insert didn't actually insert"
)
t
.
Errorf
(
"insert didn't actually insert"
)
}
}
...
@@ -74,14 +74,14 @@ func TestMinionREST(t *testing.T) {
...
@@ -74,14 +74,14 @@ func TestMinionREST(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"got error calling List"
)
t
.
Errorf
(
"got error calling List"
)
}
}
expect
:=
[]
api
.
Minion
{
expect
:=
[]
api
.
Node
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
},
{
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
},
},
},
}
}
nodeList
:=
list
.
(
*
api
.
Minion
List
)
nodeList
:=
list
.
(
*
api
.
Node
List
)
if
len
(
expect
)
!=
len
(
nodeList
.
Items
)
||
!
contains
(
nodeList
,
"foo"
)
||
!
contains
(
nodeList
,
"baz"
)
{
if
len
(
expect
)
!=
len
(
nodeList
.
Items
)
||
!
contains
(
nodeList
,
"foo"
)
||
!
contains
(
nodeList
,
"baz"
)
{
t
.
Errorf
(
"Unexpected list value: %#v"
,
list
)
t
.
Errorf
(
"Unexpected list value: %#v"
,
list
)
}
}
...
@@ -97,12 +97,12 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
...
@@ -97,12 +97,12 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
ms
:=
NewREST
(
&
minionHealthRegistry
)
ms
:=
NewREST
(
&
minionHealthRegistry
)
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"m1"
}})
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"m1"
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"insert failed"
)
t
.
Errorf
(
"insert failed"
)
}
}
result
:=
<-
c
result
:=
<-
c
if
m
,
ok
:=
result
.
Object
.
(
*
api
.
Minion
);
!
ok
||
m
.
Name
!=
"m1"
{
if
m
,
ok
:=
result
.
Object
.
(
*
api
.
Node
);
!
ok
||
m
.
Name
!=
"m1"
{
t
.
Errorf
(
"insert return value was weird: %#v"
,
result
)
t
.
Errorf
(
"insert return value was weird: %#v"
,
result
)
}
}
if
_
,
err
:=
ms
.
Get
(
ctx
,
"m1"
);
err
==
nil
{
if
_
,
err
:=
ms
.
Get
(
ctx
,
"m1"
);
err
==
nil
{
...
@@ -110,7 +110,7 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
...
@@ -110,7 +110,7 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
}
}
}
}
func
contains
(
nodes
*
api
.
Minion
List
,
nodeID
string
)
bool
{
func
contains
(
nodes
*
api
.
Node
List
,
nodeID
string
)
bool
{
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
.
Items
{
if
node
.
Name
==
nodeID
{
if
node
.
Name
==
nodeID
{
return
true
return
true
...
@@ -126,7 +126,7 @@ func TestMinionStorageInvalidUpdate(t *testing.T) {
...
@@ -126,7 +126,7 @@ func TestMinionStorageInvalidUpdate(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
}
minion
,
ok
:=
obj
.
(
*
api
.
Minion
)
minion
,
ok
:=
obj
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Object is not a minion: %#v"
,
obj
)
t
.
Fatalf
(
"Object is not a minion: %#v"
,
obj
)
}
}
...
@@ -143,7 +143,7 @@ func TestMinionStorageValidUpdate(t *testing.T) {
...
@@ -143,7 +143,7 @@ func TestMinionStorageValidUpdate(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
}
minion
,
ok
:=
obj
.
(
*
api
.
Minion
)
minion
,
ok
:=
obj
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Object is not a minion: %#v"
,
obj
)
t
.
Fatalf
(
"Object is not a minion: %#v"
,
obj
)
}
}
...
@@ -161,7 +161,7 @@ func TestMinionStorageValidatesCreate(t *testing.T) {
...
@@ -161,7 +161,7 @@ func TestMinionStorageValidatesCreate(t *testing.T) {
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
validSelector
:=
map
[
string
]
string
{
"a"
:
"b"
}
validSelector
:=
map
[
string
]
string
{
"a"
:
"b"
}
invalidSelector
:=
map
[
string
]
string
{
"NoUppercaseOrSpecialCharsLike=Equals"
:
"b"
}
invalidSelector
:=
map
[
string
]
string
{
"NoUppercaseOrSpecialCharsLike=Equals"
:
"b"
}
failureCases
:=
map
[
string
]
api
.
Minion
{
failureCases
:=
map
[
string
]
api
.
Node
{
"zero-length Name"
:
{
"zero-length Name"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Name
:
""
,
...
...
pkg/registry/pod/rest_test.go
View file @
19379b5a
...
@@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) {
...
@@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) {
func
TestMakePodStatus
(
t
*
testing
.
T
)
{
func
TestMakePodStatus
(
t
*
testing
.
T
)
{
fakeClient
:=
client
.
Fake
{
fakeClient
:=
client
.
Fake
{
MinionsList
:
api
.
Minion
List
{
MinionsList
:
api
.
Node
List
{
Items
:
[]
api
.
Minion
{
Items
:
[]
api
.
Node
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine"
},
},
},
...
...
pkg/registry/registrytest/minion.go
View file @
19379b5a
...
@@ -25,13 +25,13 @@ import (
...
@@ -25,13 +25,13 @@ import (
type
MinionRegistry
struct
{
type
MinionRegistry
struct
{
Err
error
Err
error
Minion
string
Minion
string
Minions
api
.
Minion
List
Minions
api
.
Node
List
sync
.
Mutex
sync
.
Mutex
}
}
func
MakeMinionList
(
minions
[]
string
,
nodeResources
api
.
NodeResources
)
*
api
.
Minion
List
{
func
MakeMinionList
(
minions
[]
string
,
nodeResources
api
.
NodeResources
)
*
api
.
Node
List
{
list
:=
api
.
Minion
List
{
list
:=
api
.
Node
List
{
Items
:
make
([]
api
.
Minion
,
len
(
minions
)),
Items
:
make
([]
api
.
Node
,
len
(
minions
)),
}
}
for
i
:=
range
minions
{
for
i
:=
range
minions
{
list
.
Items
[
i
]
.
Name
=
minions
[
i
]
list
.
Items
[
i
]
.
Name
=
minions
[
i
]
...
@@ -46,13 +46,13 @@ func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *Minio
...
@@ -46,13 +46,13 @@ func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *Minio
}
}
}
}
func
(
r
*
MinionRegistry
)
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Minion
List
,
error
)
{
func
(
r
*
MinionRegistry
)
ListMinions
(
ctx
api
.
Context
)
(
*
api
.
Node
List
,
error
)
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
return
&
r
.
Minions
,
r
.
Err
return
&
r
.
Minions
,
r
.
Err
}
}
func
(
r
*
MinionRegistry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
MinionRegistry
)
CreateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
r
.
Minion
=
minion
.
Name
r
.
Minion
=
minion
.
Name
...
@@ -60,7 +60,7 @@ func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error
...
@@ -60,7 +60,7 @@ func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error
return
r
.
Err
return
r
.
Err
}
}
func
(
r
*
MinionRegistry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Minion
)
error
{
func
(
r
*
MinionRegistry
)
UpdateMinion
(
ctx
api
.
Context
,
minion
*
api
.
Node
)
error
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
for
i
,
node
:=
range
r
.
Minions
.
Items
{
for
i
,
node
:=
range
r
.
Minions
.
Items
{
...
@@ -72,7 +72,7 @@ func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error
...
@@ -72,7 +72,7 @@ func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error
return
r
.
Err
return
r
.
Err
}
}
func
(
r
*
MinionRegistry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Minion
,
error
)
{
func
(
r
*
MinionRegistry
)
GetMinion
(
ctx
api
.
Context
,
minionID
string
)
(
*
api
.
Node
,
error
)
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
for
_
,
node
:=
range
r
.
Minions
.
Items
{
for
_
,
node
:=
range
r
.
Minions
.
Items
{
...
@@ -86,10 +86,10 @@ func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minio
...
@@ -86,10 +86,10 @@ func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minio
func
(
r
*
MinionRegistry
)
DeleteMinion
(
ctx
api
.
Context
,
minionID
string
)
error
{
func
(
r
*
MinionRegistry
)
DeleteMinion
(
ctx
api
.
Context
,
minionID
string
)
error
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
var
newList
[]
api
.
Minion
var
newList
[]
api
.
Node
for
_
,
node
:=
range
r
.
Minions
.
Items
{
for
_
,
node
:=
range
r
.
Minions
.
Items
{
if
node
.
Name
!=
minionID
{
if
node
.
Name
!=
minionID
{
newList
=
append
(
newList
,
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
node
.
Name
}})
newList
=
append
(
newList
,
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
node
.
Name
}})
}
}
}
}
r
.
Minions
.
Items
=
newList
r
.
Minions
.
Items
=
newList
...
...
pkg/registry/service/rest.go
View file @
19379b5a
...
@@ -154,7 +154,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
...
@@ -154,7 +154,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
}),
nil
}),
nil
}
}
func
hostsFromMinionList
(
list
*
api
.
Minion
List
)
[]
string
{
func
hostsFromMinionList
(
list
*
api
.
Node
List
)
[]
string
{
result
:=
make
([]
string
,
len
(
list
.
Items
))
result
:=
make
([]
string
,
len
(
list
.
Items
))
for
ix
:=
range
list
.
Items
{
for
ix
:=
range
list
.
Items
{
result
[
ix
]
=
list
.
Items
[
ix
]
.
Name
result
[
ix
]
=
list
.
Items
[
ix
]
.
Name
...
...
pkg/scheduler/generic_scheduler.go
View file @
19379b5a
...
@@ -76,18 +76,18 @@ func (g *genericScheduler) selectHost(priorityList HostPriorityList) (string, er
...
@@ -76,18 +76,18 @@ func (g *genericScheduler) selectHost(priorityList HostPriorityList) (string, er
// Filters the minions to find the ones that fit based on the given predicate functions
// Filters the minions to find the ones that fit based on the given predicate functions
// Each minion is passed through the predicate functions to determine if it is a fit
// Each minion is passed through the predicate functions to determine if it is a fit
func
findNodesThatFit
(
pod
api
.
Pod
,
podLister
PodLister
,
predicates
[]
FitPredicate
,
nodes
api
.
MinionList
)
(
api
.
Minion
List
,
error
)
{
func
findNodesThatFit
(
pod
api
.
Pod
,
podLister
PodLister
,
predicates
[]
FitPredicate
,
nodes
api
.
NodeList
)
(
api
.
Node
List
,
error
)
{
filtered
:=
[]
api
.
Minion
{}
filtered
:=
[]
api
.
Node
{}
machineToPods
,
err
:=
MapPodsToMachines
(
podLister
)
machineToPods
,
err
:=
MapPodsToMachines
(
podLister
)
if
err
!=
nil
{
if
err
!=
nil
{
return
api
.
Minion
List
{},
err
return
api
.
Node
List
{},
err
}
}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
.
Items
{
fits
:=
true
fits
:=
true
for
_
,
predicate
:=
range
predicates
{
for
_
,
predicate
:=
range
predicates
{
fit
,
err
:=
predicate
(
pod
,
machineToPods
[
node
.
Name
],
node
.
Name
)
fit
,
err
:=
predicate
(
pod
,
machineToPods
[
node
.
Name
],
node
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
api
.
Minion
List
{},
err
return
api
.
Node
List
{},
err
}
}
if
!
fit
{
if
!
fit
{
fits
=
false
fits
=
false
...
@@ -98,7 +98,7 @@ func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicat
...
@@ -98,7 +98,7 @@ func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicat
filtered
=
append
(
filtered
,
node
)
filtered
=
append
(
filtered
,
node
)
}
}
}
}
return
api
.
Minion
List
{
Items
:
filtered
},
nil
return
api
.
Node
List
{
Items
:
filtered
},
nil
}
}
// Prioritizes the minions by running the individual priority functions sequentially.
// Prioritizes the minions by running the individual priority functions sequentially.
...
...
pkg/scheduler/generic_scheduler_test.go
View file @
19379b5a
...
@@ -83,9 +83,9 @@ func reverseNumericPriority(pod api.Pod, podLister PodLister, minionLister Minio
...
@@ -83,9 +83,9 @@ func reverseNumericPriority(pod api.Pod, podLister PodLister, minionLister Minio
return
reverseResult
,
nil
return
reverseResult
,
nil
}
}
func
makeMinionList
(
nodeNames
[]
string
)
api
.
Minion
List
{
func
makeMinionList
(
nodeNames
[]
string
)
api
.
Node
List
{
result
:=
api
.
Minion
List
{
result
:=
api
.
Node
List
{
Items
:
make
([]
api
.
Minion
,
len
(
nodeNames
)),
Items
:
make
([]
api
.
Node
,
len
(
nodeNames
)),
}
}
for
ix
:=
range
nodeNames
{
for
ix
:=
range
nodeNames
{
result
.
Items
[
ix
]
.
Name
=
nodeNames
[
ix
]
result
.
Items
[
ix
]
.
Name
=
nodeNames
[
ix
]
...
...
pkg/scheduler/listers.go
View file @
19379b5a
...
@@ -23,15 +23,15 @@ import (
...
@@ -23,15 +23,15 @@ import (
// MinionLister interface represents anything that can list minions for a scheduler.
// MinionLister interface represents anything that can list minions for a scheduler.
type
MinionLister
interface
{
type
MinionLister
interface
{
List
()
(
list
api
.
Minion
List
,
err
error
)
List
()
(
list
api
.
Node
List
,
err
error
)
}
}
// FakeMinionLister implements MinionLister on a []string for test purposes.
// FakeMinionLister implements MinionLister on a []string for test purposes.
type
FakeMinionLister
api
.
Minion
List
type
FakeMinionLister
api
.
Node
List
// List returns minions as a []string.
// List returns minions as a []string.
func
(
f
FakeMinionLister
)
List
()
(
api
.
Minion
List
,
error
)
{
func
(
f
FakeMinionLister
)
List
()
(
api
.
Node
List
,
error
)
{
return
api
.
Minion
List
(
f
),
nil
return
api
.
Node
List
(
f
),
nil
}
}
// PodLister interface represents anything that can list pods for a scheduler.
// PodLister interface represents anything that can list pods for a scheduler.
...
...
pkg/scheduler/predicates.go
View file @
19379b5a
...
@@ -27,14 +27,14 @@ import (
...
@@ -27,14 +27,14 @@ import (
)
)
type
NodeInfo
interface
{
type
NodeInfo
interface
{
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Minion
,
error
)
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Node
,
error
)
}
}
type
StaticNodeInfo
struct
{
type
StaticNodeInfo
struct
{
*
api
.
Minion
List
*
api
.
Node
List
}
}
func
(
nodes
StaticNodeInfo
)
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Minion
,
error
)
{
func
(
nodes
StaticNodeInfo
)
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Node
,
error
)
{
for
ix
:=
range
nodes
.
Items
{
for
ix
:=
range
nodes
.
Items
{
if
nodes
.
Items
[
ix
]
.
Name
==
nodeID
{
if
nodes
.
Items
[
ix
]
.
Name
==
nodeID
{
return
&
nodes
.
Items
[
ix
],
nil
return
&
nodes
.
Items
[
ix
],
nil
...
@@ -47,7 +47,7 @@ type ClientNodeInfo struct {
...
@@ -47,7 +47,7 @@ type ClientNodeInfo struct {
*
client
.
Client
*
client
.
Client
}
}
func
(
nodes
ClientNodeInfo
)
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Minion
,
error
)
{
func
(
nodes
ClientNodeInfo
)
GetNodeInfo
(
nodeID
string
)
(
*
api
.
Node
,
error
)
{
return
nodes
.
Minions
()
.
Get
(
nodeID
)
return
nodes
.
Minions
()
.
Get
(
nodeID
)
}
}
...
...
pkg/scheduler/predicates_test.go
View file @
19379b5a
...
@@ -25,10 +25,10 @@ import (
...
@@ -25,10 +25,10 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
type
FakeNodeInfo
api
.
Minion
type
FakeNodeInfo
api
.
Node
func
(
n
FakeNodeInfo
)
GetNodeInfo
(
nodeName
string
)
(
*
api
.
Minion
,
error
)
{
func
(
n
FakeNodeInfo
)
GetNodeInfo
(
nodeName
string
)
(
*
api
.
Node
,
error
)
{
node
:=
api
.
Minion
(
n
)
node
:=
api
.
Node
(
n
)
return
&
node
,
nil
return
&
node
,
nil
}
}
...
@@ -111,7 +111,7 @@ func TestPodFitsResources(t *testing.T) {
...
@@ -111,7 +111,7 @@ func TestPodFitsResources(t *testing.T) {
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
node
:=
api
.
Minion
{
Spec
:
api
.
NodeSpec
{
Capacity
:
makeResources
(
10
,
20
)
.
Capacity
}}
node
:=
api
.
Node
{
Spec
:
api
.
NodeSpec
{
Capacity
:
makeResources
(
10
,
20
)
.
Capacity
}}
fit
:=
ResourceFit
{
FakeNodeInfo
(
node
)}
fit
:=
ResourceFit
{
FakeNodeInfo
(
node
)}
fits
,
err
:=
fit
.
PodFitsResources
(
test
.
pod
,
test
.
existingPods
,
"machine"
)
fits
,
err
:=
fit
.
PodFitsResources
(
test
.
pod
,
test
.
existingPods
,
"machine"
)
...
@@ -335,7 +335,7 @@ func TestPodFitsSelector(t *testing.T) {
...
@@ -335,7 +335,7 @@ func TestPodFitsSelector(t *testing.T) {
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
node
:=
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
test
.
labels
}}
node
:=
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
test
.
labels
}}
fit
:=
NodeSelector
{
FakeNodeInfo
(
node
)}
fit
:=
NodeSelector
{
FakeNodeInfo
(
node
)}
fits
,
err
:=
fit
.
PodSelectorMatches
(
test
.
pod
,
[]
api
.
Pod
{},
"machine"
)
fits
,
err
:=
fit
.
PodSelectorMatches
(
test
.
pod
,
[]
api
.
Pod
{},
"machine"
)
...
...
pkg/scheduler/priorities.go
View file @
19379b5a
...
@@ -37,7 +37,7 @@ func calculateScore(requested, capacity int, node string) int {
...
@@ -37,7 +37,7 @@ func calculateScore(requested, capacity int, node string) int {
// Calculate the occupancy on a node. 'node' has information about the resources on the node.
// Calculate the occupancy on a node. 'node' has information about the resources on the node.
// 'pods' is a list of pods currently scheduled on the node.
// 'pods' is a list of pods currently scheduled on the node.
func
calculateOccupancy
(
pod
api
.
Pod
,
node
api
.
Minion
,
pods
[]
api
.
Pod
)
HostPriority
{
func
calculateOccupancy
(
pod
api
.
Pod
,
node
api
.
Node
,
pods
[]
api
.
Pod
)
HostPriority
{
totalCPU
:=
0
totalCPU
:=
0
totalMemory
:=
0
totalMemory
:=
0
for
_
,
existingPod
:=
range
pods
{
for
_
,
existingPod
:=
range
pods
{
...
...
pkg/scheduler/priorities_test.go
View file @
19379b5a
...
@@ -25,8 +25,8 @@ import (
...
@@ -25,8 +25,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
func
makeMinion
(
node
string
,
cpu
,
memory
int
)
api
.
Minion
{
func
makeMinion
(
node
string
,
cpu
,
memory
int
)
api
.
Node
{
return
api
.
Minion
{
return
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
node
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
node
},
Spec
:
api
.
NodeSpec
{
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
Capacity
:
api
.
ResourceList
{
...
@@ -70,7 +70,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -70,7 +70,7 @@ func TestLeastRequested(t *testing.T) {
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
api
.
Pod
pod
api
.
Pod
pods
[]
api
.
Pod
pods
[]
api
.
Pod
nodes
[]
api
.
Minion
nodes
[]
api
.
Node
expectedList
HostPriorityList
expectedList
HostPriorityList
test
string
test
string
}{
}{
...
@@ -87,7 +87,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -87,7 +87,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (10 + 10) / 2 = 10
Minion2 Score: (10 + 10) / 2 = 10
*/
*/
pod
:
api
.
Pod
{
Spec
:
noResources
},
pod
:
api
.
Pod
{
Spec
:
noResources
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
10
},
{
"machine2"
,
10
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
10
},
{
"machine2"
,
10
}},
test
:
"nothing scheduled, nothing requested"
,
test
:
"nothing scheduled, nothing requested"
,
},
},
...
@@ -104,7 +104,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -104,7 +104,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (5 + 5) / 2 = 5
Minion2 Score: (5 + 5) / 2 = 5
*/
*/
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
6000
,
10000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
6000
,
10000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
3
},
{
"machine2"
,
5
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
3
},
{
"machine2"
,
5
}},
test
:
"nothing scheduled, resources requested, differently sized machines"
,
test
:
"nothing scheduled, resources requested, differently sized machines"
,
},
},
...
@@ -121,7 +121,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (10 + 10) / 2 = 10
Minion2 Score: (10 + 10) / 2 = 10
*/
*/
pod
:
api
.
Pod
{
Spec
:
noResources
},
pod
:
api
.
Pod
{
Spec
:
noResources
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
10
},
{
"machine2"
,
10
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
10
},
{
"machine2"
,
10
}},
test
:
"no resources requested, pods scheduled"
,
test
:
"no resources requested, pods scheduled"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -144,7 +144,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -144,7 +144,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 7.5) / 2 = 5
Minion2 Score: (4 + 7.5) / 2 = 5
*/
*/
pod
:
api
.
Pod
{
Spec
:
noResources
},
pod
:
api
.
Pod
{
Spec
:
noResources
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
20000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
20000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
7
},
{
"machine2"
,
5
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
7
},
{
"machine2"
,
5
}},
test
:
"no resources requested, pods scheduled with resources"
,
test
:
"no resources requested, pods scheduled with resources"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -167,7 +167,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -167,7 +167,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 5) / 2 = 4
Minion2 Score: (4 + 5) / 2 = 4
*/
*/
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
20000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
20000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
4
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
4
}},
test
:
"resources requested, pods scheduled with resources"
,
test
:
"resources requested, pods scheduled with resources"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -188,7 +188,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -188,7 +188,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 8) / 2 = 6
Minion2 Score: (4 + 8) / 2 = 6
*/
*/
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
pod
:
api
.
Pod
{
Spec
:
cpuAndMemory
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
50000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
10000
,
20000
),
makeMinion
(
"machine2"
,
10000
,
50000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
6
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
6
}},
test
:
"resources requested, pods scheduled with resources, differently sized machines"
,
test
:
"resources requested, pods scheduled with resources, differently sized machines"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -209,7 +209,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -209,7 +209,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (0 + 5) / 2 = 2
Minion2 Score: (0 + 5) / 2 = 2
*/
*/
pod
:
api
.
Pod
{
Spec
:
cpuOnly
},
pod
:
api
.
Pod
{
Spec
:
cpuOnly
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
4000
,
10000
),
makeMinion
(
"machine2"
,
4000
,
10000
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
2
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
5
},
{
"machine2"
,
2
}},
test
:
"requested resources exceed minion capacity"
,
test
:
"requested resources exceed minion capacity"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -219,7 +219,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -219,7 +219,7 @@ func TestLeastRequested(t *testing.T) {
},
},
{
{
pod
:
api
.
Pod
{
Spec
:
noResources
},
pod
:
api
.
Pod
{
Spec
:
noResources
},
nodes
:
[]
api
.
Minion
{
makeMinion
(
"machine1"
,
0
,
0
),
makeMinion
(
"machine2"
,
0
,
0
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
0
,
0
),
makeMinion
(
"machine2"
,
0
,
0
)},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
test
:
"zero minion resources, pods scheduled with resources"
,
test
:
"zero minion resources, pods scheduled with resources"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
...
@@ -230,7 +230,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -230,7 +230,7 @@ func TestLeastRequested(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
list
,
err
:=
LeastRequestedPriority
(
test
.
pod
,
FakePodLister
(
test
.
pods
),
FakeMinionLister
(
api
.
Minion
List
{
Items
:
test
.
nodes
}))
list
,
err
:=
LeastRequestedPriority
(
test
.
pod
,
FakePodLister
(
test
.
pods
),
FakeMinionLister
(
api
.
Node
List
{
Items
:
test
.
nodes
}))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
19379b5a
...
@@ -45,7 +45,7 @@ type ConfigFactory struct {
...
@@ -45,7 +45,7 @@ type ConfigFactory struct {
// a means to list all scheduled pods
// a means to list all scheduled pods
PodLister
*
storeToPodLister
PodLister
*
storeToPodLister
// a means to list all minions
// a means to list all minions
MinionLister
*
storeTo
Minion
Lister
MinionLister
*
storeTo
Node
Lister
// map of strings to predicate functions to be used
// map of strings to predicate functions to be used
// to filter the minions for scheduling pods
// to filter the minions for scheduling pods
PredicateMap
map
[
string
]
algorithm
.
FitPredicate
PredicateMap
map
[
string
]
algorithm
.
FitPredicate
...
@@ -61,7 +61,7 @@ func NewConfigFactory(client *client.Client) *ConfigFactory {
...
@@ -61,7 +61,7 @@ func NewConfigFactory(client *client.Client) *ConfigFactory {
Client
:
client
,
Client
:
client
,
PodQueue
:
cache
.
NewFIFO
(),
PodQueue
:
cache
.
NewFIFO
(),
PodLister
:
&
storeToPodLister
{
cache
.
NewStore
()},
PodLister
:
&
storeToPodLister
{
cache
.
NewStore
()},
MinionLister
:
&
storeTo
Minion
Lister
{
cache
.
NewStore
()},
MinionLister
:
&
storeTo
Node
Lister
{
cache
.
NewStore
()},
PredicateMap
:
make
(
map
[
string
]
algorithm
.
FitPredicate
),
PredicateMap
:
make
(
map
[
string
]
algorithm
.
FitPredicate
),
PriorityMap
:
make
(
map
[
string
]
algorithm
.
PriorityConfig
),
PriorityMap
:
make
(
map
[
string
]
algorithm
.
PriorityConfig
),
}
}
...
@@ -103,7 +103,7 @@ func (factory *ConfigFactory) Create(predicateKeys, priorityKeys []string) (*sch
...
@@ -103,7 +103,7 @@ func (factory *ConfigFactory) Create(predicateKeys, priorityKeys []string) (*sch
// Minions may be listed frequently, so provide a local up-to-date cache.
// Minions may be listed frequently, so provide a local up-to-date cache.
if
false
{
if
false
{
// Disable this code until minions support watches.
// Disable this code until minions support watches.
cache
.
NewReflector
(
factory
.
createMinionLW
(),
&
api
.
Minion
{},
factory
.
MinionLister
.
Store
)
.
Run
()
cache
.
NewReflector
(
factory
.
createMinionLW
(),
&
api
.
Node
{},
factory
.
MinionLister
.
Store
)
.
Run
()
}
else
{
}
else
{
cache
.
NewPoller
(
factory
.
pollMinions
,
10
*
time
.
Second
,
factory
.
MinionLister
.
Store
)
.
Run
()
cache
.
NewPoller
(
factory
.
pollMinions
,
10
*
time
.
Second
,
factory
.
MinionLister
.
Store
)
.
Run
()
}
}
...
@@ -255,12 +255,12 @@ func (factory *ConfigFactory) createMinionLW() *listWatch {
...
@@ -255,12 +255,12 @@ func (factory *ConfigFactory) createMinionLW() *listWatch {
// pollMinions lists all minions and returns an enumerator for cache.Poller.
// pollMinions lists all minions and returns an enumerator for cache.Poller.
func
(
factory
*
ConfigFactory
)
pollMinions
()
(
cache
.
Enumerator
,
error
)
{
func
(
factory
*
ConfigFactory
)
pollMinions
()
(
cache
.
Enumerator
,
error
)
{
list
:=
&
api
.
Minion
List
{}
list
:=
&
api
.
Node
List
{}
err
:=
factory
.
Client
.
Get
()
.
Path
(
"minions"
)
.
Do
()
.
Into
(
list
)
err
:=
factory
.
Client
.
Get
()
.
Path
(
"minions"
)
.
Do
()
.
Into
(
list
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
&
minion
Enumerator
{
list
},
nil
return
&
node
Enumerator
{
list
},
nil
}
}
func
(
factory
*
ConfigFactory
)
makeDefaultErrorFunc
(
backoff
*
podBackoff
,
podQueue
*
cache
.
FIFO
)
func
(
pod
*
api
.
Pod
,
err
error
)
{
func
(
factory
*
ConfigFactory
)
makeDefaultErrorFunc
(
backoff
*
podBackoff
,
podQueue
*
cache
.
FIFO
)
func
(
pod
*
api
.
Pod
,
err
error
)
{
...
@@ -288,22 +288,22 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
...
@@ -288,22 +288,22 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
}
}
}
}
// storeTo
Minion
Lister turns a store into a minion lister. The store must contain (only) minions.
// storeTo
Node
Lister turns a store into a minion lister. The store must contain (only) minions.
type
storeTo
Minion
Lister
struct
{
type
storeTo
Node
Lister
struct
{
cache
.
Store
cache
.
Store
}
}
func
(
s
*
storeTo
MinionLister
)
List
()
(
machines
api
.
Minion
List
,
err
error
)
{
func
(
s
*
storeTo
NodeLister
)
List
()
(
machines
api
.
Node
List
,
err
error
)
{
for
_
,
m
:=
range
s
.
Store
.
List
()
{
for
_
,
m
:=
range
s
.
Store
.
List
()
{
machines
.
Items
=
append
(
machines
.
Items
,
*
(
m
.
(
*
api
.
Minion
)))
machines
.
Items
=
append
(
machines
.
Items
,
*
(
m
.
(
*
api
.
Node
)))
}
}
return
machines
,
nil
return
machines
,
nil
}
}
// GetNodeInfo returns cached data for the minion 'id'.
// GetNodeInfo returns cached data for the minion 'id'.
func
(
s
*
storeTo
MinionLister
)
GetNodeInfo
(
id
string
)
(
*
api
.
Minion
,
error
)
{
func
(
s
*
storeTo
NodeLister
)
GetNodeInfo
(
id
string
)
(
*
api
.
Node
,
error
)
{
if
minion
,
ok
:=
s
.
Get
(
id
);
ok
{
if
minion
,
ok
:=
s
.
Get
(
id
);
ok
{
return
minion
.
(
*
api
.
Minion
),
nil
return
minion
.
(
*
api
.
Node
),
nil
}
}
return
nil
,
fmt
.
Errorf
(
"minion '%v' is not in cache"
,
id
)
return
nil
,
fmt
.
Errorf
(
"minion '%v' is not in cache"
,
id
)
}
}
...
@@ -323,22 +323,22 @@ func (s *storeToPodLister) ListPods(selector labels.Selector) (pods []api.Pod, e
...
@@ -323,22 +323,22 @@ func (s *storeToPodLister) ListPods(selector labels.Selector) (pods []api.Pod, e
return
pods
,
nil
return
pods
,
nil
}
}
//
minionEnumerator allows a cache.Poller to enumerate items in an api.Pod
List
//
nodeEnumerator allows a cache.Poller to enumerate items in an api.Node
List
type
minion
Enumerator
struct
{
type
node
Enumerator
struct
{
*
api
.
Minion
List
*
api
.
Node
List
}
}
// Len returns the number of items in the
pod
list.
// Len returns the number of items in the
node
list.
func
(
me
*
minion
Enumerator
)
Len
()
int
{
func
(
ne
*
node
Enumerator
)
Len
()
int
{
if
me
.
Minion
List
==
nil
{
if
ne
.
Node
List
==
nil
{
return
0
return
0
}
}
return
len
(
m
e
.
Items
)
return
len
(
n
e
.
Items
)
}
}
// Get returns the item (and ID) with the particular index.
// Get returns the item (and ID) with the particular index.
func
(
me
*
minion
Enumerator
)
Get
(
index
int
)
(
string
,
interface
{})
{
func
(
ne
*
node
Enumerator
)
Get
(
index
int
)
(
string
,
interface
{})
{
return
me
.
Items
[
index
]
.
Name
,
&
m
e
.
Items
[
index
]
return
ne
.
Items
[
index
]
.
Name
,
&
n
e
.
Items
[
index
]
}
}
type
binder
struct
{
type
binder
struct
{
...
...
plugin/pkg/scheduler/factory/factory_test.go
View file @
19379b5a
...
@@ -145,10 +145,10 @@ func TestCreateWatches(t *testing.T) {
...
@@ -145,10 +145,10 @@ func TestCreateWatches(t *testing.T) {
func
TestPollMinions
(
t
*
testing
.
T
)
{
func
TestPollMinions
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
table
:=
[]
struct
{
minions
[]
api
.
Minion
minions
[]
api
.
Node
}{
}{
{
{
minions
:
[]
api
.
Minion
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
}},
},
},
...
@@ -156,7 +156,7 @@ func TestPollMinions(t *testing.T) {
...
@@ -156,7 +156,7 @@ func TestPollMinions(t *testing.T) {
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
ml
:=
&
api
.
Minion
List
{
Items
:
item
.
minions
}
ml
:=
&
api
.
Node
List
{
Items
:
item
.
minions
}
handler
:=
util
.
FakeHandler
{
handler
:=
util
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
ml
),
ResponseBody
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
ml
),
...
@@ -225,9 +225,9 @@ func TestStoreToMinionLister(t *testing.T) {
...
@@ -225,9 +225,9 @@ func TestStoreToMinionLister(t *testing.T) {
store
:=
cache
.
NewStore
()
store
:=
cache
.
NewStore
()
ids
:=
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
)
ids
:=
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
)
for
id
:=
range
ids
{
for
id
:=
range
ids
{
store
.
Add
(
id
,
&
api
.
Minion
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
id
}})
store
.
Add
(
id
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
id
}})
}
}
sml
:=
storeTo
Minion
Lister
{
store
}
sml
:=
storeTo
Node
Lister
{
store
}
gotNodes
,
err
:=
sml
.
List
()
gotNodes
,
err
:=
sml
.
List
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -273,14 +273,14 @@ func TestStoreToPodLister(t *testing.T) {
...
@@ -273,14 +273,14 @@ func TestStoreToPodLister(t *testing.T) {
}
}
func
TestMinionEnumerator
(
t
*
testing
.
T
)
{
func
TestMinionEnumerator
(
t
*
testing
.
T
)
{
testList
:=
&
api
.
Minion
List
{
testList
:=
&
api
.
Node
List
{
Items
:
[]
api
.
Minion
{
Items
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
}},
},
},
}
}
me
:=
minion
Enumerator
{
testList
}
me
:=
node
Enumerator
{
testList
}
if
e
,
a
:=
3
,
me
.
Len
();
e
!=
a
{
if
e
,
a
:=
3
,
me
.
Len
();
e
!=
a
{
t
.
Fatalf
(
"expected %v, got %v"
,
e
,
a
)
t
.
Fatalf
(
"expected %v, got %v"
,
e
,
a
)
...
...
plugin/pkg/scheduler/scheduler_test.go
View file @
19379b5a
...
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
...
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
var
gotBinding
*
api
.
Binding
var
gotBinding
*
api
.
Binding
c
:=
&
Config
{
c
:=
&
Config
{
MinionLister
:
scheduler
.
FakeMinionLister
(
MinionLister
:
scheduler
.
FakeMinionLister
(
api
.
MinionList
{
Items
:
[]
api
.
Minion
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}}}},
api
.
NodeList
{
Items
:
[]
api
.
Node
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}}}},
),
),
Algorithm
:
item
.
algo
,
Algorithm
:
item
.
algo
,
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
...
...
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