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
bf8f2584
Commit
bf8f2584
authored
Apr 20, 2015
by
Ravi Gadde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added field selector for listing pods.
parent
a45b5c3e
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
43 additions
and
37 deletions
+43
-37
integration.go
cmd/integration/integration.go
+3
-2
pods.go
pkg/client/pods.go
+4
-4
pods_test.go
pkg/client/pods_test.go
+4
-3
fake_pods.go
pkg/client/testclient/fake_pods.go
+1
-1
nodecontroller.go
pkg/cloudprovider/nodecontroller/nodecontroller.go
+1
-1
replication_controller.go
pkg/controller/replication_controller.go
+1
-1
describe.go
pkg/kubectl/describe.go
+3
-2
namespace_controller.go
pkg/namespace/namespace_controller.go
+1
-1
resource_quota_controller.go
pkg/resourcequota/resource_quota_controller.go
+2
-1
endpoints_controller.go
pkg/service/endpoints_controller.go
+1
-1
density.go
test/e2e/density.go
+6
-6
es_cluster_logging.go
test/e2e/es_cluster_logging.go
+1
-1
events.go
test/e2e/events.go
+1
-1
monitoring.go
test/e2e/monitoring.go
+1
-1
pods.go
test/e2e/pods.go
+5
-5
rc.go
test/e2e/rc.go
+4
-3
client_test.go
test/integration/client_test.go
+2
-2
metrics_test.go
test/integration/metrics_test.go
+2
-1
No files found.
cmd/integration/integration.go
View file @
bf8f2584
...
@@ -43,6 +43,7 @@ import (
...
@@ -43,6 +43,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller"
replicationControllerPkg
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
replicationControllerPkg
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
...
@@ -260,7 +261,7 @@ func podsOnMinions(c *client.Client, podNamespace string, labelSelector labels.S
...
@@ -260,7 +261,7 @@ func podsOnMinions(c *client.Client, podNamespace string, labelSelector labels.S
podInfo
:=
fakeKubeletClient
{}
podInfo
:=
fakeKubeletClient
{}
// wait for minions to indicate they have info about the desired pods
// wait for minions to indicate they have info about the desired pods
return
func
()
(
bool
,
error
)
{
return
func
()
(
bool
,
error
)
{
pods
,
err
:=
c
.
Pods
(
podNamespace
)
.
List
(
labelSelector
)
pods
,
err
:=
c
.
Pods
(
podNamespace
)
.
List
(
labelSelector
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Infof
(
"Unable to get pods to list: %v"
,
err
)
glog
.
Infof
(
"Unable to get pods to list: %v"
,
err
)
return
false
,
nil
return
false
,
nil
...
@@ -384,7 +385,7 @@ containers:
...
@@ -384,7 +385,7 @@ containers:
namespace
:=
kubelet
.
NamespaceDefault
namespace
:=
kubelet
.
NamespaceDefault
if
err
:=
wait
.
Poll
(
time
.
Second
,
time
.
Minute
*
2
,
if
err
:=
wait
.
Poll
(
time
.
Second
,
time
.
Minute
*
2
,
podRunning
(
c
,
namespace
,
podName
));
err
!=
nil
{
podRunning
(
c
,
namespace
,
podName
));
err
!=
nil
{
if
pods
,
err
:=
c
.
Pods
(
namespace
)
.
List
(
labels
.
Everything
());
err
==
nil
{
if
pods
,
err
:=
c
.
Pods
(
namespace
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
);
err
==
nil
{
for
_
,
pod
:=
range
pods
.
Items
{
for
_
,
pod
:=
range
pods
.
Items
{
glog
.
Infof
(
"pod found: %s/%s"
,
namespace
,
pod
.
Name
)
glog
.
Infof
(
"pod found: %s/%s"
,
namespace
,
pod
.
Name
)
}
}
...
...
pkg/client/pods.go
View file @
bf8f2584
...
@@ -30,7 +30,7 @@ type PodsNamespacer interface {
...
@@ -30,7 +30,7 @@ type PodsNamespacer interface {
// PodInterface has methods to work with Pod resources.
// PodInterface has methods to work with Pod resources.
type
PodInterface
interface
{
type
PodInterface
interface
{
List
(
selector
label
s
.
Selector
)
(
*
api
.
PodList
,
error
)
List
(
label
labels
.
Selector
,
field
field
s
.
Selector
)
(
*
api
.
PodList
,
error
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
Delete
(
name
string
)
error
Delete
(
name
string
)
error
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
...
@@ -54,10 +54,10 @@ func newPods(c *Client, namespace string) *pods {
...
@@ -54,10 +54,10 @@ func newPods(c *Client, namespace string) *pods {
}
}
}
}
// List takes
a selector, and returns the list of pods that match that selector
.
// List takes
label and field selectors, and returns the list of pods that match those selectors
.
func
(
c
*
pods
)
List
(
selector
label
s
.
Selector
)
(
result
*
api
.
PodList
,
err
error
)
{
func
(
c
*
pods
)
List
(
label
labels
.
Selector
,
field
field
s
.
Selector
)
(
result
*
api
.
PodList
,
err
error
)
{
result
=
&
api
.
PodList
{}
result
=
&
api
.
PodList
{}
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"pods"
)
.
LabelsSelectorParam
(
selector
)
.
Do
()
.
Into
(
result
)
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"pods"
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Do
()
.
Into
(
result
)
return
return
}
}
...
...
pkg/client/pods_test.go
View file @
bf8f2584
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
)
...
@@ -31,7 +32,7 @@ func TestListEmptyPods(t *testing.T) {
...
@@ -31,7 +32,7 @@ func TestListEmptyPods(t *testing.T) {
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
testapi
.
ResourcePath
(
"pods"
,
ns
,
""
),
Query
:
buildQueryValues
(
ns
,
nil
)},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
testapi
.
ResourcePath
(
"pods"
,
ns
,
""
),
Query
:
buildQueryValues
(
ns
,
nil
)},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
PodList
{}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
PodList
{}},
}
}
podList
,
err
:=
c
.
Setup
()
.
Pods
(
ns
)
.
List
(
labels
.
Everything
())
podList
,
err
:=
c
.
Setup
()
.
Pods
(
ns
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
c
.
Validate
(
t
,
podList
,
err
)
c
.
Validate
(
t
,
podList
,
err
)
}
}
...
@@ -57,7 +58,7 @@ func TestListPods(t *testing.T) {
...
@@ -57,7 +58,7 @@ func TestListPods(t *testing.T) {
},
},
},
},
}
}
receivedPodList
,
err
:=
c
.
Setup
()
.
Pods
(
ns
)
.
List
(
labels
.
Everything
())
receivedPodList
,
err
:=
c
.
Setup
()
.
Pods
(
ns
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
c
.
Validate
(
t
,
receivedPodList
,
err
)
c
.
Validate
(
t
,
receivedPodList
,
err
)
}
}
...
@@ -91,7 +92,7 @@ func TestListPodsLabels(t *testing.T) {
...
@@ -91,7 +92,7 @@ func TestListPodsLabels(t *testing.T) {
c
.
Setup
()
c
.
Setup
()
c
.
QueryValidator
[
labelSelectorQueryParamName
]
=
validateLabels
c
.
QueryValidator
[
labelSelectorQueryParamName
]
=
validateLabels
selector
:=
labels
.
Set
{
"foo"
:
"bar"
,
"name"
:
"baz"
}
.
AsSelector
()
selector
:=
labels
.
Set
{
"foo"
:
"bar"
,
"name"
:
"baz"
}
.
AsSelector
()
receivedPodList
,
err
:=
c
.
Pods
(
ns
)
.
List
(
selector
)
receivedPodList
,
err
:=
c
.
Pods
(
ns
)
.
List
(
selector
,
fields
.
Everything
()
)
c
.
Validate
(
t
,
receivedPodList
,
err
)
c
.
Validate
(
t
,
receivedPodList
,
err
)
}
}
...
...
pkg/client/testclient/fake_pods.go
View file @
bf8f2584
...
@@ -30,7 +30,7 @@ type FakePods struct {
...
@@ -30,7 +30,7 @@ type FakePods struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakePods
)
List
(
selector
label
s
.
Selector
)
(
*
api
.
PodList
,
error
)
{
func
(
c
*
FakePods
)
List
(
label
labels
.
Selector
,
field
field
s
.
Selector
)
(
*
api
.
PodList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-pods"
},
&
api
.
PodList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-pods"
},
&
api
.
PodList
{})
return
obj
.
(
*
api
.
PodList
),
err
return
obj
.
(
*
api
.
PodList
),
err
}
}
...
...
pkg/cloudprovider/nodecontroller/nodecontroller.go
View file @
bf8f2584
...
@@ -652,7 +652,7 @@ func (nc *NodeController) getCloudNodesWithSpec() (*api.NodeList, error) {
...
@@ -652,7 +652,7 @@ func (nc *NodeController) getCloudNodesWithSpec() (*api.NodeList, error) {
func
(
nc
*
NodeController
)
deletePods
(
nodeID
string
)
error
{
func
(
nc
*
NodeController
)
deletePods
(
nodeID
string
)
error
{
glog
.
V
(
2
)
.
Infof
(
"Delete all pods from %v"
,
nodeID
)
glog
.
V
(
2
)
.
Infof
(
"Delete all pods from %v"
,
nodeID
)
// TODO: We don't yet have field selectors from client, see issue #1362.
// TODO: We don't yet have field selectors from client, see issue #1362.
pods
,
err
:=
nc
.
kubeClient
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
())
pods
,
err
:=
nc
.
kubeClient
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/controller/replication_controller.go
View file @
bf8f2584
...
@@ -201,7 +201,7 @@ func FilterActivePods(pods []api.Pod) []*api.Pod {
...
@@ -201,7 +201,7 @@ func FilterActivePods(pods []api.Pod) []*api.Pod {
func
(
rm
*
ReplicationManager
)
syncReplicationController
(
controller
api
.
ReplicationController
)
error
{
func
(
rm
*
ReplicationManager
)
syncReplicationController
(
controller
api
.
ReplicationController
)
error
{
s
:=
labels
.
Set
(
controller
.
Spec
.
Selector
)
.
AsSelector
()
s
:=
labels
.
Set
(
controller
.
Spec
.
Selector
)
.
AsSelector
()
podList
,
err
:=
rm
.
kubeClient
.
Pods
(
controller
.
Namespace
)
.
List
(
s
)
podList
,
err
:=
rm
.
kubeClient
.
Pods
(
controller
.
Namespace
)
.
List
(
s
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/describe.go
View file @
bf8f2584
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -479,7 +480,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
...
@@ -479,7 +480,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
}
}
var
pods
[]
*
api
.
Pod
var
pods
[]
*
api
.
Pod
allPods
,
err
:=
d
.
Pods
(
namespace
)
.
List
(
labels
.
Everything
())
allPods
,
err
:=
d
.
Pods
(
namespace
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -613,7 +614,7 @@ func printReplicationControllersByLabels(matchingRCs []api.ReplicationController
...
@@ -613,7 +614,7 @@ func printReplicationControllersByLabels(matchingRCs []api.ReplicationController
}
}
func
getPodStatusForReplicationController
(
c
client
.
PodInterface
,
controller
*
api
.
ReplicationController
)
(
running
,
waiting
,
succeeded
,
failed
int
,
err
error
)
{
func
getPodStatusForReplicationController
(
c
client
.
PodInterface
,
controller
*
api
.
ReplicationController
)
(
running
,
waiting
,
succeeded
,
failed
int
,
err
error
)
{
rcPods
,
err
:=
c
.
List
(
labels
.
SelectorFromSet
(
controller
.
Spec
.
Selector
))
rcPods
,
err
:=
c
.
List
(
labels
.
SelectorFromSet
(
controller
.
Spec
.
Selector
)
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
...
pkg/namespace/namespace_controller.go
View file @
bf8f2584
...
@@ -236,7 +236,7 @@ func deleteReplicationControllers(kubeClient client.Interface, ns string) error
...
@@ -236,7 +236,7 @@ func deleteReplicationControllers(kubeClient client.Interface, ns string) error
}
}
func
deletePods
(
kubeClient
client
.
Interface
,
ns
string
)
error
{
func
deletePods
(
kubeClient
client
.
Interface
,
ns
string
)
error
{
items
,
err
:=
kubeClient
.
Pods
(
ns
)
.
List
(
labels
.
Everything
())
items
,
err
:=
kubeClient
.
Pods
(
ns
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/resourcequota/resource_quota_controller.go
View file @
bf8f2584
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -147,7 +148,7 @@ func (rm *ResourceQuotaManager) syncResourceQuota(quota api.ResourceQuota) (err
...
@@ -147,7 +148,7 @@ func (rm *ResourceQuotaManager) syncResourceQuota(quota api.ResourceQuota) (err
pods
:=
&
api
.
PodList
{}
pods
:=
&
api
.
PodList
{}
if
set
[
api
.
ResourcePods
]
||
set
[
api
.
ResourceMemory
]
||
set
[
api
.
ResourceCPU
]
{
if
set
[
api
.
ResourcePods
]
||
set
[
api
.
ResourceMemory
]
||
set
[
api
.
ResourceCPU
]
{
pods
,
err
=
rm
.
kubeClient
.
Pods
(
usage
.
Namespace
)
.
List
(
labels
.
Everything
())
pods
,
err
=
rm
.
kubeClient
.
Pods
(
usage
.
Namespace
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/service/endpoints_controller.go
View file @
bf8f2584
...
@@ -85,7 +85,7 @@ func NewEndpointController(client *client.Client) *EndpointController {
...
@@ -85,7 +85,7 @@ func NewEndpointController(client *client.Client) *EndpointController {
e
.
podStore
.
Store
,
e
.
podController
=
framework
.
NewInformer
(
e
.
podStore
.
Store
,
e
.
podController
=
framework
.
NewInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
return
e
.
client
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
())
return
e
.
client
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
},
},
WatchFunc
:
func
(
rv
string
)
(
watch
.
Interface
,
error
)
{
WatchFunc
:
func
(
rv
string
)
(
watch
.
Interface
,
error
)
{
return
e
.
client
.
Pods
(
api
.
NamespaceAll
)
.
Watch
(
labels
.
Everything
(),
fields
.
Everything
(),
rv
)
return
e
.
client
.
Pods
(
api
.
NamespaceAll
)
.
Watch
(
labels
.
Everything
(),
fields
.
Everything
(),
rv
)
...
...
test/e2e/density.go
View file @
bf8f2584
...
@@ -35,14 +35,14 @@ import (
...
@@ -35,14 +35,14 @@ import (
)
)
// Convenient wrapper around listing pods supporting retries.
// Convenient wrapper around listing pods supporting retries.
func
listPods
(
c
*
client
.
Client
,
namespace
string
,
label
labels
.
Selector
)
(
*
api
.
PodList
,
error
)
{
func
listPods
(
c
*
client
.
Client
,
namespace
string
,
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PodList
,
error
)
{
maxRetries
:=
4
maxRetries
:=
4
pods
,
err
:=
c
.
Pods
(
namespace
)
.
List
(
label
)
pods
,
err
:=
c
.
Pods
(
namespace
)
.
List
(
label
,
field
)
for
i
:=
0
;
i
<
maxRetries
;
i
++
{
for
i
:=
0
;
i
<
maxRetries
;
i
++
{
if
err
==
nil
{
if
err
==
nil
{
return
pods
,
nil
return
pods
,
nil
}
}
pods
,
err
=
c
.
Pods
(
namespace
)
.
List
(
label
)
pods
,
err
=
c
.
Pods
(
namespace
)
.
List
(
label
,
field
)
}
}
return
pods
,
err
return
pods
,
err
}
}
...
@@ -127,7 +127,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
...
@@ -127,7 +127,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
By
(
fmt
.
Sprintf
(
"Making sure all %d replicas exist"
,
replicas
))
By
(
fmt
.
Sprintf
(
"Making sure all %d replicas exist"
,
replicas
))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
pods
,
err
:=
listPods
(
c
,
ns
,
label
)
pods
,
err
:=
listPods
(
c
,
ns
,
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
current
=
len
(
pods
.
Items
)
current
=
len
(
pods
.
Items
)
failCount
:=
5
failCount
:=
5
...
@@ -147,7 +147,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
...
@@ -147,7 +147,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
last
=
current
last
=
current
time
.
Sleep
(
5
*
time
.
Second
)
time
.
Sleep
(
5
*
time
.
Second
)
pods
,
err
=
listPods
(
c
,
ns
,
label
)
pods
,
err
=
listPods
(
c
,
ns
,
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
current
=
len
(
pods
.
Items
)
current
=
len
(
pods
.
Items
)
}
}
...
@@ -166,7 +166,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
...
@@ -166,7 +166,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
unknown
:=
0
unknown
:=
0
time
.
Sleep
(
10
*
time
.
Second
)
time
.
Sleep
(
10
*
time
.
Second
)
currentPods
,
listErr
:=
listPods
(
c
,
ns
,
label
)
currentPods
,
listErr
:=
listPods
(
c
,
ns
,
label
,
fields
.
Everything
()
)
Expect
(
listErr
)
.
NotTo
(
HaveOccurred
())
Expect
(
listErr
)
.
NotTo
(
HaveOccurred
())
if
len
(
currentPods
.
Items
)
!=
len
(
pods
.
Items
)
{
if
len
(
currentPods
.
Items
)
!=
len
(
pods
.
Items
)
{
Failf
(
"Number of reported pods changed: %d vs %d"
,
len
(
currentPods
.
Items
),
len
(
pods
.
Items
))
Failf
(
"Number of reported pods changed: %d vs %d"
,
len
(
currentPods
.
Items
),
len
(
pods
.
Items
))
...
...
test/e2e/es_cluster_logging.go
View file @
bf8f2584
...
@@ -83,7 +83,7 @@ func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
...
@@ -83,7 +83,7 @@ func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
// Wait for the Elasticsearch pods to enter the running state.
// Wait for the Elasticsearch pods to enter the running state.
By
(
"Checking to make sure the Elasticsearch pods are running"
)
By
(
"Checking to make sure the Elasticsearch pods are running"
)
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
"elasticsearch-logging"
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
"elasticsearch-logging"
}))
pods
,
err
:=
c
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
label
)
pods
,
err
:=
c
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
for
_
,
pod
:=
range
pods
.
Items
{
for
_
,
pod
:=
range
pods
.
Items
{
err
=
waitForPodRunning
(
c
,
pod
.
Name
)
err
=
waitForPodRunning
(
c
,
pod
.
Name
)
...
...
test/e2e/events.go
View file @
bf8f2584
...
@@ -78,7 +78,7 @@ var _ = Describe("Events", func() {
...
@@ -78,7 +78,7 @@ var _ = Describe("Events", func() {
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
By
(
"verifying the pod is in kubernetes"
)
By
(
"verifying the pod is in kubernetes"
)
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
By
(
"retrieving the pod"
)
By
(
"retrieving the pod"
)
...
...
test/e2e/monitoring.go
View file @
bf8f2584
...
@@ -86,7 +86,7 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
...
@@ -86,7 +86,7 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
return
nil
,
fmt
.
Errorf
(
"expected to find only one replica for rc %q, found %d"
,
rc
.
Name
,
rc
.
Status
.
Replicas
)
return
nil
,
fmt
.
Errorf
(
"expected to find only one replica for rc %q, found %d"
,
rc
.
Name
,
rc
.
Status
.
Replicas
)
}
}
expectedRcs
[
rc
.
Name
]
=
true
expectedRcs
[
rc
.
Name
]
=
true
podList
,
err
:=
c
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
labels
.
Set
(
rc
.
Spec
.
Selector
)
.
AsSelector
())
podList
,
err
:=
c
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
labels
.
Set
(
rc
.
Spec
.
Selector
)
.
AsSelector
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
test/e2e/pods.go
View file @
bf8f2584
...
@@ -174,7 +174,7 @@ var _ = Describe("Pods", func() {
...
@@ -174,7 +174,7 @@ var _ = Describe("Pods", func() {
}
}
By
(
"setting up watch"
)
By
(
"setting up watch"
)
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to query for pods: %v"
,
err
))
Fail
(
fmt
.
Sprintf
(
"Failed to query for pods: %v"
,
err
))
}
}
...
@@ -196,7 +196,7 @@ var _ = Describe("Pods", func() {
...
@@ -196,7 +196,7 @@ var _ = Describe("Pods", func() {
}
}
By
(
"verifying the pod is in kubernetes"
)
By
(
"verifying the pod is in kubernetes"
)
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to query for pods: %v"
,
err
))
Fail
(
fmt
.
Sprintf
(
"Failed to query for pods: %v"
,
err
))
}
}
...
@@ -214,7 +214,7 @@ var _ = Describe("Pods", func() {
...
@@ -214,7 +214,7 @@ var _ = Describe("Pods", func() {
By
(
"deleting the pod"
)
By
(
"deleting the pod"
)
podClient
.
Delete
(
pod
.
Name
)
podClient
.
Delete
(
pod
.
Name
)
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to delete pod: %v"
,
err
))
Fail
(
fmt
.
Sprintf
(
"Failed to delete pod: %v"
,
err
))
}
}
...
@@ -286,7 +286,7 @@ var _ = Describe("Pods", func() {
...
@@ -286,7 +286,7 @@ var _ = Describe("Pods", func() {
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
By
(
"verifying the pod is in kubernetes"
)
By
(
"verifying the pod is in kubernetes"
)
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
:=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
By
(
"retrieving the pod"
)
By
(
"retrieving the pod"
)
...
@@ -309,7 +309,7 @@ var _ = Describe("Pods", func() {
...
@@ -309,7 +309,7 @@ var _ = Describe("Pods", func() {
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
expectNoError
(
waitForPodRunning
(
c
,
pod
.
Name
))
By
(
"verifying the updated pod is in kubernetes"
)
By
(
"verifying the updated pod is in kubernetes"
)
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
})))
pods
,
err
=
podClient
.
List
(
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"time"
:
value
}))
,
fields
.
Everything
()
)
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
fmt
.
Println
(
"pod update OK"
)
fmt
.
Println
(
"pod update OK"
)
})
})
...
...
test/e2e/rc.go
View file @
bf8f2584
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
...
@@ -110,7 +111,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
...
@@ -110,7 +111,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
// List the pods, making sure we observe all the replicas.
// List the pods, making sure we observe all the replicas.
listTimeout
:=
time
.
Minute
listTimeout
:=
time
.
Minute
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
)
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
t
:=
time
.
Now
()
t
:=
time
.
Now
()
for
{
for
{
...
@@ -123,7 +124,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
...
@@ -123,7 +124,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
name
,
replicas
,
len
(
pods
.
Items
),
time
.
Since
(
t
)
.
Seconds
())
name
,
replicas
,
len
(
pods
.
Items
),
time
.
Since
(
t
)
.
Seconds
())
}
}
time
.
Sleep
(
5
*
time
.
Second
)
time
.
Sleep
(
5
*
time
.
Second
)
pods
,
err
=
c
.
Pods
(
ns
)
.
List
(
label
)
pods
,
err
=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
...
@@ -165,7 +166,7 @@ type responseChecker struct {
...
@@ -165,7 +166,7 @@ type responseChecker struct {
func
(
r
responseChecker
)
checkAllResponses
()
(
done
bool
,
err
error
)
{
func
(
r
responseChecker
)
checkAllResponses
()
(
done
bool
,
err
error
)
{
successes
:=
0
successes
:=
0
currentPods
,
err
:=
r
.
c
.
Pods
(
r
.
ns
)
.
List
(
r
.
label
)
currentPods
,
err
:=
r
.
c
.
Pods
(
r
.
ns
)
.
List
(
r
.
label
,
fields
.
Everything
()
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
for
i
,
pod
:=
range
r
.
pods
.
Items
{
for
i
,
pod
:=
range
r
.
pods
.
Items
{
// Check that the replica list remains unchanged, otherwise we have problems.
// Check that the replica list remains unchanged, otherwise we have problems.
...
...
test/integration/client_test.go
View file @
bf8f2584
...
@@ -56,7 +56,7 @@ func TestClient(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestClient(t *testing.T) {
t
.
Errorf
(
"expected %#v, got %#v"
,
e
,
a
)
t
.
Errorf
(
"expected %#v, got %#v"
,
e
,
a
)
}
}
pods
,
err
:=
client
.
Pods
(
ns
)
.
List
(
labels
.
Everything
())
pods
,
err
:=
client
.
Pods
(
ns
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -94,7 +94,7 @@ func TestClient(t *testing.T) {
...
@@ -94,7 +94,7 @@ func TestClient(t *testing.T) {
}
}
// pod is shown, but not scheduled
// pod is shown, but not scheduled
pods
,
err
=
client
.
Pods
(
ns
)
.
List
(
labels
.
Everything
())
pods
,
err
=
client
.
Pods
(
ns
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
test/integration/metrics_test.go
View file @
bf8f2584
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
...
@@ -111,7 +112,7 @@ func TestApiserverMetrics(t *testing.T) {
...
@@ -111,7 +112,7 @@ func TestApiserverMetrics(t *testing.T) {
// Make a request to the apiserver to ensure there's at least one data point
// Make a request to the apiserver to ensure there's at least one data point
// for the metrics we're expecting -- otherwise, they won't be exported.
// for the metrics we're expecting -- otherwise, they won't be exported.
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
s
.
URL
,
Version
:
testapi
.
Version
()})
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
s
.
URL
,
Version
:
testapi
.
Version
()})
if
_
,
err
:=
client
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
labels
.
Everything
());
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
api
.
NamespaceDefault
)
.
List
(
labels
.
Everything
()
,
fields
.
Everything
()
);
err
!=
nil
{
t
.
Fatalf
(
"unexpected error getting pods: %v"
,
err
)
t
.
Fatalf
(
"unexpected error getting pods: %v"
,
err
)
}
}
...
...
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