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
a48f2182
Commit
a48f2182
authored
Sep 10, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13754 from tummychow/labels-deps
Move util.StringSet into its own package
parents
1fec1993
78ce5da9
Hide whitespace changes
Inline
Side-by-side
Showing
98 changed files
with
473 additions
and
429 deletions
+473
-429
conversion.go
cmd/genconversion/conversion.go
+2
-2
deep_copy.go
cmd/gendeepcopy/deep_copy.go
+2
-2
integration.go
cmd/integration/integration.go
+4
-3
offers.go
contrib/mesos/pkg/offers/offers.go
+9
-9
delay.go
contrib/mesos/pkg/queue/delay.go
+4
-4
historical.go
contrib/mesos/pkg/queue/historical.go
+4
-4
scheduler.go
contrib/mesos/pkg/scheduler/scheduler.go
+2
-2
endpoints_controller.go
contrib/mesos/pkg/service/endpoints_controller.go
+3
-2
known-flags.txt
hack/verify-flags/known-flags.txt
+1
-0
handler.go
pkg/admission/handler.go
+3
-3
helpers.go
pkg/api/helpers.go
+3
-2
latest.go
pkg/api/latest/latest.go
+3
-3
mapper.go
pkg/api/mapper.go
+2
-2
serialization_test.go
pkg/api/serialization_test.go
+4
-3
validation.go
pkg/api/validation/validation.go
+20
-19
validation_test.go
pkg/api/validation/validation_test.go
+3
-2
apiserver.go
pkg/apiserver/apiserver.go
+2
-1
handlers.go
pkg/apiserver/handlers.go
+3
-2
handlers_test.go
pkg/apiserver/handlers_test.go
+2
-2
delta_fifo.go
pkg/client/unversioned/cache/delta_fifo.go
+2
-2
expiration_cache_fakes.go
pkg/client/unversioned/cache/expiration_cache_fakes.go
+2
-1
expiration_cache_test.go
pkg/client/unversioned/cache/expiration_cache_test.go
+4
-3
index.go
pkg/client/unversioned/cache/index.go
+2
-2
listers_test.go
pkg/client/unversioned/cache/listers_test.go
+13
-13
store_test.go
pkg/client/unversioned/cache/store_test.go
+8
-8
thread_safe_store.go
pkg/client/unversioned/cache/thread_safe_store.go
+3
-3
debugging.go
pkg/client/unversioned/debugging.go
+3
-3
flags_test.go
pkg/client/unversioned/flags_test.go
+2
-2
helper.go
pkg/client/unversioned/helper.go
+3
-2
request.go
pkg/client/unversioned/request.go
+2
-1
aws_loadbalancer.go
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
+5
-5
aws_utils.go
pkg/cloudprovider/providers/aws/aws_utils.go
+4
-4
gce.go
pkg/cloudprovider/providers/gce/gce.go
+2
-2
controller_utils_test.go
pkg/controller/controller_utils_test.go
+3
-2
endpoints_controller.go
pkg/controller/endpoint/endpoints_controller.go
+3
-2
controller_test.go
pkg/controller/framework/controller_test.go
+4
-4
namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+2
-1
namespace_controller_test.go
pkg/controller/namespace/namespace_controller_test.go
+3
-2
nodecontroller.go
pkg/controller/node/nodecontroller.go
+6
-5
rate_limited_queue.go
pkg/controller/node/rate_limited_queue.go
+3
-2
rate_limited_queue_test.go
pkg/controller/node/rate_limited_queue_test.go
+8
-7
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+2
-1
resource_quota_controller_test.go
...ontroller/resourcequota/resource_quota_controller_test.go
+3
-3
serviceaccounts_controller.go
pkg/controller/serviceaccount/serviceaccounts_controller.go
+4
-4
serviceaccounts_controller_test.go
...troller/serviceaccount/serviceaccounts_controller_test.go
+4
-3
tokens_controller.go
pkg/controller/serviceaccount/tokens_controller.go
+3
-3
keyring.go
pkg/credentialprovider/keyring.go
+2
-2
latest.go
pkg/expapi/latest/latest.go
+3
-3
validation.go
pkg/expapi/validation/validation.go
+2
-1
navigation_step_parser.go
pkg/kubectl/cmd/config/navigation_step_parser.go
+4
-4
log.go
pkg/kubectl/cmd/log.go
+2
-2
describe.go
pkg/kubectl/describe.go
+2
-2
builder.go
pkg/kubectl/resource/builder.go
+2
-2
result.go
pkg/kubectl/resource/result.go
+2
-2
resource_printer.go
pkg/kubectl/resource_printer.go
+2
-1
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+4
-3
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+2
-1
config.go
pkg/kubelet/config/config.go
+6
-6
fake_docker_client.go
pkg/kubelet/dockertools/fake_docker_client.go
+2
-2
manager.go
pkg/kubelet/dockertools/manager.go
+2
-1
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+4
-3
image_manager.go
pkg/kubelet/image_manager.go
+4
-3
image_manager_test.go
pkg/kubelet/image_manager_test.go
+2
-2
kubelet.go
pkg/kubelet/kubelet.go
+7
-6
mirror_client_test.go
pkg/kubelet/mirror_client_test.go
+3
-3
selector.go
pkg/labels/selector.go
+12
-11
selector_test.go
pkg/labels/selector_test.go
+47
-47
master.go
pkg/master/master.go
+4
-3
etcd_test.go
pkg/registry/generic/etcd/etcd_test.go
+6
-5
allocator_test.go
pkg/registry/service/ipallocator/allocator_test.go
+3
-3
allocator_test.go
pkg/registry/service/portallocator/allocator_test.go
+2
-1
conversion_generator.go
pkg/runtime/conversion_generator.go
+3
-3
deep_copy_generator.go
pkg/runtime/deep_copy_generator.go
+3
-3
cacher_test.go
pkg/storage/cacher_test.go
+2
-1
watch_cache_test.go
pkg/storage/watch_cache_test.go
+3
-2
linux.go
pkg/util/bandwidth/linux.go
+2
-2
iptables.go
pkg/util/iptables/iptables.go
+3
-3
iptables_test.go
pkg/util/iptables/iptables_test.go
+15
-15
transport.go
pkg/util/proxy/transport.go
+27
-27
set.go
pkg/util/sets/set.go
+21
-21
set_test.go
pkg/util/sets/set_test.go
+17
-17
gce_util.go
pkg/volume/gce_pd/gce_util.go
+4
-3
admission.go
plugin/pkg/admission/namespace/lifecycle/admission.go
+3
-3
admission.go
plugin/pkg/admission/serviceaccount/admission.go
+5
-5
defaults.go
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
+5
-5
factory.go
plugin/pkg/scheduler/factory/factory.go
+4
-3
plugins.go
plugin/pkg/scheduler/factory/plugins.go
+6
-6
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+3
-3
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+6
-6
daemon_restart.go
test/e2e/daemon_restart.go
+4
-3
density.go
test/e2e/density.go
+2
-1
kubelet.go
test/e2e/kubelet.go
+8
-7
kubelet_stats.go
test/e2e/kubelet_stats.go
+2
-1
load.go
test/e2e/load.go
+2
-2
service_latency.go
test/e2e/service_latency.go
+2
-1
util.go
test/e2e/util.go
+7
-6
webserver.go
test/images/network-tester/webserver.go
+2
-2
service_account_test.go
test/integration/service_account_test.go
+2
-2
No files found.
cmd/genconversion/conversion.go
View file @
a48f2182
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi/v1"
_
"k8s.io/kubernetes/pkg/expapi/v1"
pkg_runtime
"k8s.io/kubernetes/pkg/runtime"
pkg_runtime
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"github.com/golang/glog"
"github.com/golang/glog"
flag
"github.com/spf13/pflag"
flag
"github.com/spf13/pflag"
...
@@ -84,7 +84,7 @@ func main() {
...
@@ -84,7 +84,7 @@ func main() {
glog
.
Errorf
(
"error while generating conversion functions for %v: %v"
,
knownType
,
err
)
glog
.
Errorf
(
"error while generating conversion functions for %v: %v"
,
knownType
,
err
)
}
}
}
}
generator
.
RepackImports
(
util
.
NewStringSet
())
generator
.
RepackImports
(
sets
.
NewString
())
if
err
:=
generator
.
WriteImports
(
data
);
err
!=
nil
{
if
err
:=
generator
.
WriteImports
(
data
);
err
!=
nil
{
glog
.
Fatalf
(
"error while writing imports: %v"
,
err
)
glog
.
Fatalf
(
"error while writing imports: %v"
,
err
)
}
}
...
...
cmd/gendeepcopy/deep_copy.go
View file @
a48f2182
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi/v1"
_
"k8s.io/kubernetes/pkg/expapi/v1"
pkg_runtime
"k8s.io/kubernetes/pkg/runtime"
pkg_runtime
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"github.com/golang/glog"
"github.com/golang/glog"
flag
"github.com/spf13/pflag"
flag
"github.com/spf13/pflag"
...
@@ -80,7 +80,7 @@ func main() {
...
@@ -80,7 +80,7 @@ func main() {
}
}
versionPath
:=
path
.
Join
(
pkgBase
,
group
,
version
)
versionPath
:=
path
.
Join
(
pkgBase
,
group
,
version
)
generator
:=
pkg_runtime
.
NewDeepCopyGenerator
(
api
.
Scheme
.
Raw
(),
versionPath
,
util
.
NewStringSet
(
"k8s.io/kubernetes"
))
generator
:=
pkg_runtime
.
NewDeepCopyGenerator
(
api
.
Scheme
.
Raw
(),
versionPath
,
sets
.
NewString
(
"k8s.io/kubernetes"
))
generator
.
AddImport
(
path
.
Join
(
pkgBase
,
"api"
))
generator
.
AddImport
(
path
.
Join
(
pkgBase
,
"api"
))
if
len
(
*
overwrites
)
>
0
{
if
len
(
*
overwrites
)
>
0
{
...
...
cmd/integration/integration.go
View file @
a48f2182
...
@@ -55,6 +55,7 @@ import (
...
@@ -55,6 +55,7 @@ import (
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/volume/empty_dir"
"k8s.io/kubernetes/pkg/volume/empty_dir"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
...
@@ -738,7 +739,7 @@ func runMasterServiceTest(client *client.Client) {
...
@@ -738,7 +739,7 @@ func runMasterServiceTest(client *client.Client) {
glog
.
Fatalf
(
"unexpected error listing services: %v"
,
err
)
glog
.
Fatalf
(
"unexpected error listing services: %v"
,
err
)
}
}
var
foundRW
bool
var
foundRW
bool
found
:=
util
.
StringSet
{}
found
:=
sets
.
String
{}
for
i
:=
range
svcList
.
Items
{
for
i
:=
range
svcList
.
Items
{
found
.
Insert
(
svcList
.
Items
[
i
]
.
Name
)
found
.
Insert
(
svcList
.
Items
[
i
]
.
Name
)
if
svcList
.
Items
[
i
]
.
Name
==
"kubernetes"
{
if
svcList
.
Items
[
i
]
.
Name
==
"kubernetes"
{
...
@@ -864,7 +865,7 @@ func runServiceTest(client *client.Client) {
...
@@ -864,7 +865,7 @@ func runServiceTest(client *client.Client) {
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to list services across namespaces: %v"
,
err
)
glog
.
Fatalf
(
"Failed to list services across namespaces: %v"
,
err
)
}
}
names
:=
util
.
NewStringSet
()
names
:=
sets
.
NewString
()
for
_
,
svc
:=
range
svcList
.
Items
{
for
_
,
svc
:=
range
svcList
.
Items
{
names
.
Insert
(
fmt
.
Sprintf
(
"%s/%s"
,
svc
.
Namespace
,
svc
.
Name
))
names
.
Insert
(
fmt
.
Sprintf
(
"%s/%s"
,
svc
.
Namespace
,
svc
.
Name
))
}
}
...
@@ -1011,7 +1012,7 @@ func main() {
...
@@ -1011,7 +1012,7 @@ func main() {
// Check that kubelet tried to make the containers.
// Check that kubelet tried to make the containers.
// Using a set to list unique creation attempts. Our fake is
// Using a set to list unique creation attempts. Our fake is
// really stupid, so kubelet tries to create these multiple times.
// really stupid, so kubelet tries to create these multiple times.
createdConts
:=
util
.
StringSet
{}
createdConts
:=
sets
.
String
{}
for
_
,
p
:=
range
fakeDocker1
.
Created
{
for
_
,
p
:=
range
fakeDocker1
.
Created
{
// The last 8 characters are random, so slice them off.
// The last 8 characters are random, so slice them off.
if
n
:=
len
(
p
);
n
>
8
{
if
n
:=
len
(
p
);
n
>
8
{
...
...
contrib/mesos/pkg/offers/offers.go
View file @
a48f2182
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
"k8s.io/kubernetes/contrib/mesos/pkg/queue"
"k8s.io/kubernetes/contrib/mesos/pkg/queue"
"k8s.io/kubernetes/contrib/mesos/pkg/runtime"
"k8s.io/kubernetes/contrib/mesos/pkg/runtime"
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
const
(
const
(
...
@@ -453,7 +453,7 @@ func (s *offerStorage) nextListener() *offerListener {
...
@@ -453,7 +453,7 @@ func (s *offerStorage) nextListener() *offerListener {
// notify listeners if we find an acceptable offer for them. listeners
// notify listeners if we find an acceptable offer for them. listeners
// are garbage collected after a certain age (see offerListenerMaxAge).
// are garbage collected after a certain age (see offerListenerMaxAge).
// ids lists offer IDs that are retrievable from offer storage.
// ids lists offer IDs that are retrievable from offer storage.
func
(
s
*
offerStorage
)
notifyListeners
(
ids
func
()
(
util
.
StringSet
,
uint64
))
{
func
(
s
*
offerStorage
)
notifyListeners
(
ids
func
()
(
sets
.
String
,
uint64
))
{
listener
:=
s
.
nextListener
()
// blocking
listener
:=
s
.
nextListener
()
// blocking
offerIds
,
version
:=
ids
()
offerIds
,
version
:=
ids
()
...
@@ -493,8 +493,8 @@ func (s *offerStorage) Init(done <-chan struct{}) {
...
@@ -493,8 +493,8 @@ func (s *offerStorage) Init(done <-chan struct{}) {
// cached offer ids for the purposes of listener notification
// cached offer ids for the purposes of listener notification
idCache
:=
&
stringsCache
{
idCache
:=
&
stringsCache
{
refill
:
func
()
util
.
StringSet
{
refill
:
func
()
sets
.
String
{
result
:=
util
.
NewStringSet
()
result
:=
sets
.
NewString
()
for
_
,
v
:=
range
s
.
offers
.
List
()
{
for
_
,
v
:=
range
s
.
offers
.
List
()
{
if
offer
,
ok
:=
v
.
(
Perishable
);
ok
{
if
offer
,
ok
:=
v
.
(
Perishable
);
ok
{
result
.
Insert
(
offer
.
Id
())
result
.
Insert
(
offer
.
Id
())
...
@@ -510,14 +510,14 @@ func (s *offerStorage) Init(done <-chan struct{}) {
...
@@ -510,14 +510,14 @@ func (s *offerStorage) Init(done <-chan struct{}) {
type
stringsCache
struct
{
type
stringsCache
struct
{
expiresAt
time
.
Time
expiresAt
time
.
Time
cached
util
.
StringSet
cached
sets
.
String
ttl
time
.
Duration
ttl
time
.
Duration
refill
func
()
util
.
StringSet
refill
func
()
sets
.
String
version
uint64
version
uint64
}
}
// not thread-safe
// not thread-safe
func
(
c
*
stringsCache
)
Strings
()
(
util
.
StringSet
,
uint64
)
{
func
(
c
*
stringsCache
)
Strings
()
(
sets
.
String
,
uint64
)
{
now
:=
time
.
Now
()
now
:=
time
.
Now
()
if
c
.
expiresAt
.
Before
(
now
)
{
if
c
.
expiresAt
.
Before
(
now
)
{
old
:=
c
.
cached
old
:=
c
.
cached
...
@@ -549,8 +549,8 @@ func (self *slaveStorage) add(slaveId, offerId string) {
...
@@ -549,8 +549,8 @@ func (self *slaveStorage) add(slaveId, offerId string) {
}
}
// delete the slave-offer mappings for slaveId, returns the IDs of the offers that were unmapped
// delete the slave-offer mappings for slaveId, returns the IDs of the offers that were unmapped
func
(
self
*
slaveStorage
)
deleteSlave
(
slaveId
string
)
util
.
StringSet
{
func
(
self
*
slaveStorage
)
deleteSlave
(
slaveId
string
)
sets
.
String
{
offerIds
:=
util
.
NewStringSet
()
offerIds
:=
sets
.
NewString
()
self
.
Lock
()
self
.
Lock
()
defer
self
.
Unlock
()
defer
self
.
Unlock
()
for
oid
,
sid
:=
range
self
.
index
{
for
oid
,
sid
:=
range
self
.
index
{
...
...
contrib/mesos/pkg/queue/delay.go
View file @
a48f2182
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"sync"
"sync"
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
qitem
struct
{
type
qitem
struct
{
...
@@ -277,13 +277,13 @@ func (f *DelayFIFO) List() []UniqueID {
...
@@ -277,13 +277,13 @@ func (f *DelayFIFO) List() []UniqueID {
return
list
return
list
}
}
// ContainedIDs returns a
util
.StringSet containing all IDs of the stored items.
// ContainedIDs returns a
stringset
.StringSet containing all IDs of the stored items.
// This is a snapshot of a moment in time, and one should keep in mind that
// This is a snapshot of a moment in time, and one should keep in mind that
// other go routines can add or remove items after you call this.
// other go routines can add or remove items after you call this.
func
(
c
*
DelayFIFO
)
ContainedIDs
()
util
.
StringSet
{
func
(
c
*
DelayFIFO
)
ContainedIDs
()
sets
.
String
{
c
.
rlock
()
c
.
rlock
()
defer
c
.
runlock
()
defer
c
.
runlock
()
set
:=
util
.
StringSet
{}
set
:=
sets
.
String
{}
for
id
:=
range
c
.
items
{
for
id
:=
range
c
.
items
{
set
.
Insert
(
id
)
set
.
Insert
(
id
)
}
}
...
...
contrib/mesos/pkg/queue/historical.go
View file @
a48f2182
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"sync"
"sync"
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
entry
struct
{
type
entry
struct
{
...
@@ -177,13 +177,13 @@ func (f *HistoricalFIFO) ListKeys() []string {
...
@@ -177,13 +177,13 @@ func (f *HistoricalFIFO) ListKeys() []string {
return
list
return
list
}
}
// ContainedIDs returns a
util
.StringSet containing all IDs of the stored items.
// ContainedIDs returns a
stringset
.StringSet containing all IDs of the stored items.
// This is a snapshot of a moment in time, and one should keep in mind that
// This is a snapshot of a moment in time, and one should keep in mind that
// other go routines can add or remove items after you call this.
// other go routines can add or remove items after you call this.
func
(
c
*
HistoricalFIFO
)
ContainedIDs
()
util
.
StringSet
{
func
(
c
*
HistoricalFIFO
)
ContainedIDs
()
sets
.
String
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
set
:=
util
.
StringSet
{}
set
:=
sets
.
String
{}
for
id
,
entry
:=
range
c
.
items
{
for
id
,
entry
:=
range
c
.
items
{
if
entry
.
Is
(
DELETE_EVENT
|
POP_EVENT
)
{
if
entry
.
Is
(
DELETE_EVENT
|
POP_EVENT
)
{
continue
continue
...
...
contrib/mesos/pkg/scheduler/scheduler.go
View file @
a48f2182
...
@@ -47,7 +47,7 @@ import (
...
@@ -47,7 +47,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
Slave
struct
{
type
Slave
struct
{
...
@@ -711,7 +711,7 @@ func (k *KubernetesScheduler) explicitlyReconcileTasks(driver bindings.Scheduler
...
@@ -711,7 +711,7 @@ func (k *KubernetesScheduler) explicitlyReconcileTasks(driver bindings.Scheduler
// tell mesos to send us the latest status updates for all the non-terminal tasks that we know about
// tell mesos to send us the latest status updates for all the non-terminal tasks that we know about
statusList
:=
[]
*
mesos
.
TaskStatus
{}
statusList
:=
[]
*
mesos
.
TaskStatus
{}
remaining
:=
util
.
KeySet
(
reflect
.
ValueOf
(
taskToSlave
))
remaining
:=
sets
.
KeySet
(
reflect
.
ValueOf
(
taskToSlave
))
for
taskId
,
slaveId
:=
range
taskToSlave
{
for
taskId
,
slaveId
:=
range
taskToSlave
{
if
slaveId
==
""
{
if
slaveId
==
""
{
delete
(
taskToSlave
,
taskId
)
delete
(
taskToSlave
,
taskId
)
...
...
contrib/mesos/pkg/service/endpoints_controller.go
View file @
a48f2182
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/workqueue"
"k8s.io/kubernetes/pkg/util/workqueue"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -132,8 +133,8 @@ func (e *endpointController) Run(workers int, stopCh <-chan struct{}) {
...
@@ -132,8 +133,8 @@ func (e *endpointController) Run(workers int, stopCh <-chan struct{}) {
e
.
queue
.
ShutDown
()
e
.
queue
.
ShutDown
()
}
}
func
(
e
*
endpointController
)
getPodServiceMemberships
(
pod
*
api
.
Pod
)
(
util
.
StringSet
,
error
)
{
func
(
e
*
endpointController
)
getPodServiceMemberships
(
pod
*
api
.
Pod
)
(
sets
.
String
,
error
)
{
set
:=
util
.
StringSet
{}
set
:=
sets
.
String
{}
services
,
err
:=
e
.
serviceStore
.
GetPodServices
(
pod
)
services
,
err
:=
e
.
serviceStore
.
GetPodServices
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
// don't log this error because this function makes pointless
// don't log this error because this function makes pointless
...
...
hack/verify-flags/known-flags.txt
View file @
a48f2182
...
@@ -194,6 +194,7 @@ path-override
...
@@ -194,6 +194,7 @@ path-override
pod-cidr
pod-cidr
pod-eviction-timeout
pod-eviction-timeout
pod-infra-container-image
pod-infra-container-image
pod-running
policy-config-file
policy-config-file
poll-interval
poll-interval
portal-net
portal-net
...
...
pkg/admission/handler.go
View file @
a48f2182
...
@@ -17,13 +17,13 @@ limitations under the License.
...
@@ -17,13 +17,13 @@ limitations under the License.
package
admission
package
admission
import
(
import
(
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// Handler is a base for admission control handlers that
// Handler is a base for admission control handlers that
// support a predefined set of operations
// support a predefined set of operations
type
Handler
struct
{
type
Handler
struct
{
operations
util
.
StringSet
operations
sets
.
String
}
}
// Handles returns true for methods that this handler supports
// Handles returns true for methods that this handler supports
...
@@ -34,7 +34,7 @@ func (h *Handler) Handles(operation Operation) bool {
...
@@ -34,7 +34,7 @@ func (h *Handler) Handles(operation Operation) bool {
// NewHandler creates a new base handler that handles the passed
// NewHandler creates a new base handler that handles the passed
// in operations
// in operations
func
NewHandler
(
ops
...
Operation
)
*
Handler
{
func
NewHandler
(
ops
...
Operation
)
*
Handler
{
operations
:=
util
.
NewStringSet
()
operations
:=
sets
.
NewString
()
for
_
,
op
:=
range
ops
{
for
_
,
op
:=
range
ops
{
operations
.
Insert
(
string
(
op
))
operations
.
Insert
(
string
(
op
))
}
}
...
...
pkg/api/helpers.go
View file @
a48f2182
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/davecgh/go-spew/spew"
"github.com/davecgh/go-spew/spew"
)
)
...
@@ -77,7 +78,7 @@ var Semantic = conversion.EqualitiesOrDie(
...
@@ -77,7 +78,7 @@ var Semantic = conversion.EqualitiesOrDie(
},
},
)
)
var
standardResources
=
util
.
NewStringSet
(
var
standardResources
=
sets
.
NewString
(
string
(
ResourceMemory
),
string
(
ResourceMemory
),
string
(
ResourceCPU
),
string
(
ResourceCPU
),
string
(
ResourcePods
),
string
(
ResourcePods
),
...
@@ -111,7 +112,7 @@ func IsServiceIPRequested(service *Service) bool {
...
@@ -111,7 +112,7 @@ func IsServiceIPRequested(service *Service) bool {
return
service
.
Spec
.
ClusterIP
==
""
return
service
.
Spec
.
ClusterIP
==
""
}
}
var
standardFinalizers
=
util
.
NewStringSet
(
var
standardFinalizers
=
sets
.
NewString
(
string
(
FinalizerKubernetes
))
string
(
FinalizerKubernetes
))
func
IsStandardFinalizerName
(
str
string
)
bool
{
func
IsStandardFinalizerName
(
str
string
)
bool
{
...
...
pkg/api/latest/latest.go
View file @
a48f2182
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api/registered"
"k8s.io/kubernetes/pkg/api/registered"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// Version is the string that represents the current external default version.
// Version is the string that represents the current external default version.
...
@@ -79,7 +79,7 @@ func init() {
...
@@ -79,7 +79,7 @@ func init() {
// the list of kinds that are scoped at the root of the api hierarchy
// the list of kinds that are scoped at the root of the api hierarchy
// if a kind is not enumerated here, it is assumed to have a namespace scope
// if a kind is not enumerated here, it is assumed to have a namespace scope
rootScoped
:=
util
.
NewStringSet
(
rootScoped
:=
sets
.
NewString
(
"Node"
,
"Node"
,
"Minion"
,
"Minion"
,
"Namespace"
,
"Namespace"
,
...
@@ -87,7 +87,7 @@ func init() {
...
@@ -87,7 +87,7 @@ func init() {
)
)
// these kinds should be excluded from the list of resources
// these kinds should be excluded from the list of resources
ignoredKinds
:=
util
.
NewStringSet
(
ignoredKinds
:=
sets
.
NewString
(
"ListOptions"
,
"ListOptions"
,
"DeleteOptions"
,
"DeleteOptions"
,
"Status"
,
"Status"
,
...
...
pkg/api/mapper.go
View file @
a48f2182
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"strings"
"strings"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
var
RESTMapper
meta
.
RESTMapper
var
RESTMapper
meta
.
RESTMapper
...
@@ -34,7 +34,7 @@ func RegisterRESTMapper(m meta.RESTMapper) {
...
@@ -34,7 +34,7 @@ func RegisterRESTMapper(m meta.RESTMapper) {
}
}
func
NewDefaultRESTMapper
(
group
string
,
versions
[]
string
,
interfacesFunc
meta
.
VersionInterfacesFunc
,
func
NewDefaultRESTMapper
(
group
string
,
versions
[]
string
,
interfacesFunc
meta
.
VersionInterfacesFunc
,
importPathPrefix
string
,
ignoredKinds
,
rootScoped
util
.
StringSet
)
*
meta
.
DefaultRESTMapper
{
importPathPrefix
string
,
ignoredKinds
,
rootScoped
sets
.
String
)
*
meta
.
DefaultRESTMapper
{
mapper
:=
meta
.
NewDefaultRESTMapper
(
group
,
versions
,
interfacesFunc
)
mapper
:=
meta
.
NewDefaultRESTMapper
(
group
,
versions
,
interfacesFunc
)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// enumerate all supported versions, get the kinds, and register with the mapper how to address
...
...
pkg/api/serialization_test.go
View file @
a48f2182
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
apitesting
"k8s.io/kubernetes/pkg/api/testing"
apitesting
"k8s.io/kubernetes/pkg/api/testing"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi/v1"
_
"k8s.io/kubernetes/pkg/expapi/v1"
...
@@ -87,7 +88,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
...
@@ -87,7 +88,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// roundTripSame verifies the same source object is tested in all API versions.
// roundTripSame verifies the same source object is tested in all API versions.
func
roundTripSame
(
t
*
testing
.
T
,
item
runtime
.
Object
,
except
...
string
)
{
func
roundTripSame
(
t
*
testing
.
T
,
item
runtime
.
Object
,
except
...
string
)
{
set
:=
util
.
NewStringSet
(
except
...
)
set
:=
sets
.
NewString
(
except
...
)
seed
:=
rand
.
Int63
()
seed
:=
rand
.
Int63
()
fuzzInternalObject
(
t
,
""
,
item
,
seed
)
fuzzInternalObject
(
t
,
""
,
item
,
seed
)
version
:=
testapi
.
Default
.
Version
()
version
:=
testapi
.
Default
.
Version
()
...
@@ -119,8 +120,8 @@ func TestList(t *testing.T) {
...
@@ -119,8 +120,8 @@ func TestList(t *testing.T) {
roundTripSame
(
t
,
item
)
roundTripSame
(
t
,
item
)
}
}
var
nonRoundTrippableTypes
=
util
.
NewStringSet
()
var
nonRoundTrippableTypes
=
sets
.
NewString
()
var
nonInternalRoundTrippableTypes
=
util
.
NewStringSet
(
"List"
,
"ListOptions"
,
"PodExecOptions"
,
"PodAttachOptions"
)
var
nonInternalRoundTrippableTypes
=
sets
.
NewString
(
"List"
,
"ListOptions"
,
"PodExecOptions"
,
"PodAttachOptions"
)
var
nonRoundTrippableTypesByVersion
=
map
[
string
][]
string
{}
var
nonRoundTrippableTypesByVersion
=
map
[
string
][]
string
{}
func
TestRoundTripTypes
(
t
*
testing
.
T
)
{
func
TestRoundTripTypes
(
t
*
testing
.
T
)
{
...
...
pkg/api/validation/validation.go
View file @
a48f2182
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -307,10 +308,10 @@ func ValidateObjectMetaUpdate(new, old *api.ObjectMeta) errs.ValidationErrorList
...
@@ -307,10 +308,10 @@ func ValidateObjectMetaUpdate(new, old *api.ObjectMeta) errs.ValidationErrorList
return
allErrs
return
allErrs
}
}
func
validateVolumes
(
volumes
[]
api
.
Volume
)
(
util
.
StringSet
,
errs
.
ValidationErrorList
)
{
func
validateVolumes
(
volumes
[]
api
.
Volume
)
(
sets
.
String
,
errs
.
ValidationErrorList
)
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
allNames
:=
util
.
StringSet
{}
allNames
:=
sets
.
String
{}
for
i
,
vol
:=
range
volumes
{
for
i
,
vol
:=
range
volumes
{
el
:=
validateSource
(
&
vol
.
VolumeSource
)
.
Prefix
(
"source"
)
el
:=
validateSource
(
&
vol
.
VolumeSource
)
.
Prefix
(
"source"
)
if
len
(
vol
.
Name
)
==
0
{
if
len
(
vol
.
Name
)
==
0
{
...
@@ -497,7 +498,7 @@ func validateGlusterfs(glusterfs *api.GlusterfsVolumeSource) errs.ValidationErro
...
@@ -497,7 +498,7 @@ func validateGlusterfs(glusterfs *api.GlusterfsVolumeSource) errs.ValidationErro
return
allErrs
return
allErrs
}
}
var
validDownwardAPIFieldPathExpressions
=
util
.
NewStringSet
(
"metadata.name"
,
"metadata.namespace"
,
"metadata.labels"
,
"metadata.annotations"
)
var
validDownwardAPIFieldPathExpressions
=
sets
.
NewString
(
"metadata.name"
,
"metadata.namespace"
,
"metadata.labels"
,
"metadata.annotations"
)
func
validateDownwardAPIVolumeSource
(
downwardAPIVolume
*
api
.
DownwardAPIVolumeSource
)
errs
.
ValidationErrorList
{
func
validateDownwardAPIVolumeSource
(
downwardAPIVolume
*
api
.
DownwardAPIVolumeSource
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
...
@@ -688,12 +689,12 @@ func ValidatePersistentVolumeClaimStatusUpdate(newPvc, oldPvc *api.PersistentVol
...
@@ -688,12 +689,12 @@ func ValidatePersistentVolumeClaimStatusUpdate(newPvc, oldPvc *api.PersistentVol
return
allErrs
return
allErrs
}
}
var
supportedPortProtocols
=
util
.
NewStringSet
(
string
(
api
.
ProtocolTCP
),
string
(
api
.
ProtocolUDP
))
var
supportedPortProtocols
=
sets
.
NewString
(
string
(
api
.
ProtocolTCP
),
string
(
api
.
ProtocolUDP
))
func
validatePorts
(
ports
[]
api
.
ContainerPort
)
errs
.
ValidationErrorList
{
func
validatePorts
(
ports
[]
api
.
ContainerPort
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
allNames
:=
util
.
StringSet
{}
allNames
:=
sets
.
String
{}
for
i
,
port
:=
range
ports
{
for
i
,
port
:=
range
ports
{
pErrs
:=
errs
.
ValidationErrorList
{}
pErrs
:=
errs
.
ValidationErrorList
{}
if
len
(
port
.
Name
)
>
0
{
if
len
(
port
.
Name
)
>
0
{
...
@@ -739,7 +740,7 @@ func validateEnv(vars []api.EnvVar) errs.ValidationErrorList {
...
@@ -739,7 +740,7 @@ func validateEnv(vars []api.EnvVar) errs.ValidationErrorList {
return
allErrs
return
allErrs
}
}
var
validFieldPathExpressionsEnv
=
util
.
NewStringSet
(
"metadata.name"
,
"metadata.namespace"
,
"status.podIP"
)
var
validFieldPathExpressionsEnv
=
sets
.
NewString
(
"metadata.name"
,
"metadata.namespace"
,
"status.podIP"
)
func
validateEnvVarValueFrom
(
ev
api
.
EnvVar
)
errs
.
ValidationErrorList
{
func
validateEnvVarValueFrom
(
ev
api
.
EnvVar
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
...
@@ -763,7 +764,7 @@ func validateEnvVarValueFrom(ev api.EnvVar) errs.ValidationErrorList {
...
@@ -763,7 +764,7 @@ func validateEnvVarValueFrom(ev api.EnvVar) errs.ValidationErrorList {
return
allErrs
return
allErrs
}
}
func
validateObjectFieldSelector
(
fs
*
api
.
ObjectFieldSelector
,
expressions
*
util
.
StringSet
)
errs
.
ValidationErrorList
{
func
validateObjectFieldSelector
(
fs
*
api
.
ObjectFieldSelector
,
expressions
*
sets
.
String
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
fs
.
APIVersion
==
""
{
if
fs
.
APIVersion
==
""
{
...
@@ -782,7 +783,7 @@ func validateObjectFieldSelector(fs *api.ObjectFieldSelector, expressions *util.
...
@@ -782,7 +783,7 @@ func validateObjectFieldSelector(fs *api.ObjectFieldSelector, expressions *util.
return
allErrs
return
allErrs
}
}
func
validateVolumeMounts
(
mounts
[]
api
.
VolumeMount
,
volumes
util
.
StringSet
)
errs
.
ValidationErrorList
{
func
validateVolumeMounts
(
mounts
[]
api
.
VolumeMount
,
volumes
sets
.
String
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
for
i
,
mnt
:=
range
mounts
{
for
i
,
mnt
:=
range
mounts
{
...
@@ -818,7 +819,7 @@ func validateProbe(probe *api.Probe) errs.ValidationErrorList {
...
@@ -818,7 +819,7 @@ func validateProbe(probe *api.Probe) errs.ValidationErrorList {
// AccumulateUniqueHostPorts extracts each HostPort of each Container,
// AccumulateUniqueHostPorts extracts each HostPort of each Container,
// accumulating the results and returning an error if any ports conflict.
// accumulating the results and returning an error if any ports conflict.
func
AccumulateUniqueHostPorts
(
containers
[]
api
.
Container
,
accumulator
*
util
.
StringSet
)
errs
.
ValidationErrorList
{
func
AccumulateUniqueHostPorts
(
containers
[]
api
.
Container
,
accumulator
*
sets
.
String
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
for
ci
,
ctr
:=
range
containers
{
for
ci
,
ctr
:=
range
containers
{
...
@@ -843,7 +844,7 @@ func AccumulateUniqueHostPorts(containers []api.Container, accumulator *util.Str
...
@@ -843,7 +844,7 @@ func AccumulateUniqueHostPorts(containers []api.Container, accumulator *util.Str
// checkHostPortConflicts checks for colliding Port.HostPort values across
// checkHostPortConflicts checks for colliding Port.HostPort values across
// a slice of containers.
// a slice of containers.
func
checkHostPortConflicts
(
containers
[]
api
.
Container
)
errs
.
ValidationErrorList
{
func
checkHostPortConflicts
(
containers
[]
api
.
Container
)
errs
.
ValidationErrorList
{
allPorts
:=
util
.
StringSet
{}
allPorts
:=
sets
.
String
{}
return
AccumulateUniqueHostPorts
(
containers
,
&
allPorts
)
return
AccumulateUniqueHostPorts
(
containers
,
&
allPorts
)
}
}
...
@@ -865,7 +866,7 @@ func validateHTTPGetAction(http *api.HTTPGetAction) errs.ValidationErrorList {
...
@@ -865,7 +866,7 @@ func validateHTTPGetAction(http *api.HTTPGetAction) errs.ValidationErrorList {
}
else
if
http
.
Port
.
Kind
==
util
.
IntstrString
&&
!
util
.
IsValidPortName
(
http
.
Port
.
StrVal
)
{
}
else
if
http
.
Port
.
Kind
==
util
.
IntstrString
&&
!
util
.
IsValidPortName
(
http
.
Port
.
StrVal
)
{
allErrors
=
append
(
allErrors
,
errs
.
NewFieldInvalid
(
"port"
,
http
.
Port
.
StrVal
,
portNameErrorMsg
))
allErrors
=
append
(
allErrors
,
errs
.
NewFieldInvalid
(
"port"
,
http
.
Port
.
StrVal
,
portNameErrorMsg
))
}
}
supportedSchemes
:=
util
.
NewStringSet
(
string
(
api
.
URISchemeHTTP
),
string
(
api
.
URISchemeHTTPS
))
supportedSchemes
:=
sets
.
NewString
(
string
(
api
.
URISchemeHTTP
),
string
(
api
.
URISchemeHTTPS
))
if
!
supportedSchemes
.
Has
(
string
(
http
.
Scheme
))
{
if
!
supportedSchemes
.
Has
(
string
(
http
.
Scheme
))
{
allErrors
=
append
(
allErrors
,
errs
.
NewFieldInvalid
(
"scheme"
,
http
.
Scheme
,
fmt
.
Sprintf
(
"must be one of %v"
,
supportedSchemes
.
List
())))
allErrors
=
append
(
allErrors
,
errs
.
NewFieldInvalid
(
"scheme"
,
http
.
Scheme
,
fmt
.
Sprintf
(
"must be one of %v"
,
supportedSchemes
.
List
())))
}
}
...
@@ -930,14 +931,14 @@ func validatePullPolicy(ctr *api.Container) errs.ValidationErrorList {
...
@@ -930,14 +931,14 @@ func validatePullPolicy(ctr *api.Container) errs.ValidationErrorList {
return
allErrors
return
allErrors
}
}
func
validateContainers
(
containers
[]
api
.
Container
,
volumes
util
.
StringSet
)
errs
.
ValidationErrorList
{
func
validateContainers
(
containers
[]
api
.
Container
,
volumes
sets
.
String
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
len
(
containers
)
==
0
{
if
len
(
containers
)
==
0
{
return
append
(
allErrs
,
errs
.
NewFieldRequired
(
""
))
return
append
(
allErrs
,
errs
.
NewFieldRequired
(
""
))
}
}
allNames
:=
util
.
StringSet
{}
allNames
:=
sets
.
String
{}
for
i
,
ctr
:=
range
containers
{
for
i
,
ctr
:=
range
containers
{
cErrs
:=
errs
.
ValidationErrorList
{}
cErrs
:=
errs
.
ValidationErrorList
{}
if
len
(
ctr
.
Name
)
==
0
{
if
len
(
ctr
.
Name
)
==
0
{
...
@@ -1130,8 +1131,8 @@ func ValidatePodTemplateUpdate(newPod, oldPod *api.PodTemplate) errs.ValidationE
...
@@ -1130,8 +1131,8 @@ func ValidatePodTemplateUpdate(newPod, oldPod *api.PodTemplate) errs.ValidationE
return
allErrs
return
allErrs
}
}
var
supportedSessionAffinityType
=
util
.
NewStringSet
(
string
(
api
.
ServiceAffinityClientIP
),
string
(
api
.
ServiceAffinityNone
))
var
supportedSessionAffinityType
=
sets
.
NewString
(
string
(
api
.
ServiceAffinityClientIP
),
string
(
api
.
ServiceAffinityNone
))
var
supportedServiceType
=
util
.
NewStringSet
(
string
(
api
.
ServiceTypeClusterIP
),
string
(
api
.
ServiceTypeNodePort
),
var
supportedServiceType
=
sets
.
NewString
(
string
(
api
.
ServiceTypeClusterIP
),
string
(
api
.
ServiceTypeNodePort
),
string
(
api
.
ServiceTypeLoadBalancer
))
string
(
api
.
ServiceTypeLoadBalancer
))
// ValidateService tests if required fields in the service are set.
// ValidateService tests if required fields in the service are set.
...
@@ -1150,7 +1151,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
...
@@ -1150,7 +1151,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
}
}
}
}
}
}
allPortNames
:=
util
.
StringSet
{}
allPortNames
:=
sets
.
String
{}
for
i
:=
range
service
.
Spec
.
Ports
{
for
i
:=
range
service
.
Spec
.
Ports
{
allErrs
=
append
(
allErrs
,
validateServicePort
(
&
service
.
Spec
.
Ports
[
i
],
len
(
service
.
Spec
.
Ports
)
>
1
,
&
allPortNames
)
.
PrefixIndex
(
i
)
.
Prefix
(
"spec.ports"
)
...
)
allErrs
=
append
(
allErrs
,
validateServicePort
(
&
service
.
Spec
.
Ports
[
i
],
len
(
service
.
Spec
.
Ports
)
>
1
,
&
allPortNames
)
.
PrefixIndex
(
i
)
.
Prefix
(
"spec.ports"
)
...
)
}
}
...
@@ -1220,7 +1221,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
...
@@ -1220,7 +1221,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
return
allErrs
return
allErrs
}
}
func
validateServicePort
(
sp
*
api
.
ServicePort
,
requireName
bool
,
allNames
*
util
.
StringSet
)
errs
.
ValidationErrorList
{
func
validateServicePort
(
sp
*
api
.
ServicePort
,
requireName
bool
,
allNames
*
sets
.
String
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
requireName
&&
sp
.
Name
==
""
{
if
requireName
&&
sp
.
Name
==
""
{
...
@@ -1441,7 +1442,7 @@ func ValidateLimitRange(limitRange *api.LimitRange) errs.ValidationErrorList {
...
@@ -1441,7 +1442,7 @@ func ValidateLimitRange(limitRange *api.LimitRange) errs.ValidationErrorList {
}
}
limitTypeSet
[
limit
.
Type
]
=
true
limitTypeSet
[
limit
.
Type
]
=
true
keys
:=
util
.
StringSet
{}
keys
:=
sets
.
String
{}
min
:=
map
[
string
]
resource
.
Quantity
{}
min
:=
map
[
string
]
resource
.
Quantity
{}
max
:=
map
[
string
]
resource
.
Quantity
{}
max
:=
map
[
string
]
resource
.
Quantity
{}
defaults
:=
map
[
string
]
resource
.
Quantity
{}
defaults
:=
map
[
string
]
resource
.
Quantity
{}
...
@@ -1884,7 +1885,7 @@ func ValidateThirdPartyResource(obj *api.ThirdPartyResource) errs.ValidationErro
...
@@ -1884,7 +1885,7 @@ func ValidateThirdPartyResource(obj *api.ThirdPartyResource) errs.ValidationErro
if
len
(
obj
.
Name
)
==
0
{
if
len
(
obj
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
obj
.
Name
,
"name must be non-empty"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
obj
.
Name
,
"name must be non-empty"
))
}
}
versions
:=
util
.
StringSet
{}
versions
:=
sets
.
String
{}
for
ix
:=
range
obj
.
Versions
{
for
ix
:=
range
obj
.
Versions
{
version
:=
&
obj
.
Versions
[
ix
]
version
:=
&
obj
.
Versions
[
ix
]
if
len
(
version
.
Name
)
==
0
{
if
len
(
version
.
Name
)
==
0
{
...
...
pkg/api/validation/validation_test.go
View file @
a48f2182
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/fielderrors"
errors
"k8s.io/kubernetes/pkg/util/fielderrors"
errors
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
expectPrefix
(
t
*
testing
.
T
,
prefix
string
,
errs
fielderrors
.
ValidationErrorList
)
{
func
expectPrefix
(
t
*
testing
.
T
,
prefix
string
,
errs
fielderrors
.
ValidationErrorList
)
{
...
@@ -769,7 +770,7 @@ func TestValidateEnv(t *testing.T) {
...
@@ -769,7 +770,7 @@ func TestValidateEnv(t *testing.T) {
}
}
func
TestValidateVolumeMounts
(
t
*
testing
.
T
)
{
func
TestValidateVolumeMounts
(
t
*
testing
.
T
)
{
volumes
:=
util
.
NewStringSet
(
"abc"
,
"123"
,
"abc-123"
)
volumes
:=
sets
.
NewString
(
"abc"
,
"123"
,
"abc-123"
)
successCase
:=
[]
api
.
VolumeMount
{
successCase
:=
[]
api
.
VolumeMount
{
{
Name
:
"abc"
,
MountPath
:
"/foo"
},
{
Name
:
"abc"
,
MountPath
:
"/foo"
},
...
@@ -896,7 +897,7 @@ func getResourceLimits(cpu, memory string) api.ResourceList {
...
@@ -896,7 +897,7 @@ func getResourceLimits(cpu, memory string) api.ResourceList {
}
}
func
TestValidateContainers
(
t
*
testing
.
T
)
{
func
TestValidateContainers
(
t
*
testing
.
T
)
{
volumes
:=
util
.
StringSet
{}
volumes
:=
sets
.
String
{}
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
AllowPrivileged
:
true
,
AllowPrivileged
:
true
,
})
})
...
...
pkg/apiserver/apiserver.go
View file @
a48f2182
...
@@ -42,6 +42,7 @@ import (
...
@@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/flushwriter"
"k8s.io/kubernetes/pkg/util/flushwriter"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/version"
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
...
@@ -115,7 +116,7 @@ const (
...
@@ -115,7 +116,7 @@ const (
// It is expected that the provided path root prefix will serve all operations. Root MUST NOT end
// It is expected that the provided path root prefix will serve all operations. Root MUST NOT end
// in a slash. A restful WebService is created for the group and version.
// in a slash. A restful WebService is created for the group and version.
func
(
g
*
APIGroupVersion
)
InstallREST
(
container
*
restful
.
Container
)
error
{
func
(
g
*
APIGroupVersion
)
InstallREST
(
container
*
restful
.
Container
)
error
{
info
:=
&
APIRequestInfoResolver
{
util
.
NewStringSet
(
strings
.
TrimPrefix
(
g
.
Root
,
"/"
)),
g
.
Mapper
}
info
:=
&
APIRequestInfoResolver
{
sets
.
NewString
(
strings
.
TrimPrefix
(
g
.
Root
,
"/"
)),
g
.
Mapper
}
prefix
:=
path
.
Join
(
g
.
Root
,
g
.
Version
)
prefix
:=
path
.
Join
(
g
.
Root
,
g
.
Version
)
installer
:=
&
APIInstaller
{
installer
:=
&
APIInstaller
{
...
...
pkg/apiserver/handlers.go
View file @
a48f2182
...
@@ -35,6 +35,7 @@ import (
...
@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// specialVerbs contains just strings which are used in REST paths for special actions that don't fall under the normal
// specialVerbs contains just strings which are used in REST paths for special actions that don't fall under the normal
...
@@ -351,7 +352,7 @@ type requestAttributeGetter struct {
...
@@ -351,7 +352,7 @@ type requestAttributeGetter struct {
// NewAttributeGetter returns an object which implements the RequestAttributeGetter interface.
// NewAttributeGetter returns an object which implements the RequestAttributeGetter interface.
func
NewRequestAttributeGetter
(
requestContextMapper
api
.
RequestContextMapper
,
restMapper
meta
.
RESTMapper
,
apiRoots
...
string
)
RequestAttributeGetter
{
func
NewRequestAttributeGetter
(
requestContextMapper
api
.
RequestContextMapper
,
restMapper
meta
.
RESTMapper
,
apiRoots
...
string
)
RequestAttributeGetter
{
return
&
requestAttributeGetter
{
requestContextMapper
,
&
APIRequestInfoResolver
{
util
.
NewStringSet
(
apiRoots
...
),
restMapper
}}
return
&
requestAttributeGetter
{
requestContextMapper
,
&
APIRequestInfoResolver
{
sets
.
NewString
(
apiRoots
...
),
restMapper
}}
}
}
func
(
r
*
requestAttributeGetter
)
GetAttribs
(
req
*
http
.
Request
)
authorizer
.
Attributes
{
func
(
r
*
requestAttributeGetter
)
GetAttribs
(
req
*
http
.
Request
)
authorizer
.
Attributes
{
...
@@ -417,7 +418,7 @@ type APIRequestInfo struct {
...
@@ -417,7 +418,7 @@ type APIRequestInfo struct {
}
}
type
APIRequestInfoResolver
struct
{
type
APIRequestInfoResolver
struct
{
APIPrefixes
util
.
StringSet
APIPrefixes
sets
.
String
RestMapper
meta
.
RESTMapper
RestMapper
meta
.
RESTMapper
}
}
...
...
pkg/apiserver/handlers_test.go
View file @
a48f2182
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
fakeRL
bool
type
fakeRL
bool
...
@@ -246,7 +246,7 @@ func TestGetAPIRequestInfo(t *testing.T) {
...
@@ -246,7 +246,7 @@ func TestGetAPIRequestInfo(t *testing.T) {
{
"PUT"
,
"/namespaces/other/finalize"
,
"update"
,
""
,
"other"
,
"finalize"
,
""
,
""
,
""
,
[]
string
{
"finalize"
}},
{
"PUT"
,
"/namespaces/other/finalize"
,
"update"
,
""
,
"other"
,
"finalize"
,
""
,
""
,
""
,
[]
string
{
"finalize"
}},
}
}
apiRequestInfoResolver
:=
&
APIRequestInfoResolver
{
util
.
NewStringSet
(
"api"
),
latest
.
RESTMapper
}
apiRequestInfoResolver
:=
&
APIRequestInfoResolver
{
sets
.
NewString
(
"api"
),
latest
.
RESTMapper
}
for
_
,
successCase
:=
range
successCases
{
for
_
,
successCase
:=
range
successCases
{
req
,
_
:=
http
.
NewRequest
(
successCase
.
method
,
successCase
.
url
,
nil
)
req
,
_
:=
http
.
NewRequest
(
successCase
.
method
,
successCase
.
url
,
nil
)
...
...
pkg/client/unversioned/cache/delta_fifo.go
View file @
a48f2182
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"fmt"
"fmt"
"sync"
"sync"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -319,7 +319,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
...
@@ -319,7 +319,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
return
nil
return
nil
}
}
keySet
:=
make
(
util
.
StringSet
,
len
(
list
))
keySet
:=
make
(
sets
.
String
,
len
(
list
))
for
_
,
item
:=
range
list
{
for
_
,
item
:=
range
list
{
key
,
err
:=
f
.
KeyOf
(
item
)
key
,
err
:=
f
.
KeyOf
(
item
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/client/unversioned/cache/expiration_cache_fakes.go
View file @
a48f2182
...
@@ -18,6 +18,7 @@ package cache
...
@@ -18,6 +18,7 @@ package cache
import
(
import
(
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
type
fakeThreadSafeMap
struct
{
type
fakeThreadSafeMap
struct
{
...
@@ -32,7 +33,7 @@ func (c *fakeThreadSafeMap) Delete(key string) {
...
@@ -32,7 +33,7 @@ func (c *fakeThreadSafeMap) Delete(key string) {
}
}
type
FakeExpirationPolicy
struct
{
type
FakeExpirationPolicy
struct
{
NeverExpire
util
.
StringSet
NeverExpire
sets
.
String
RetrieveKeyFunc
KeyFunc
RetrieveKeyFunc
KeyFunc
}
}
...
...
pkg/client/unversioned/cache/expiration_cache_test.go
View file @
a48f2182
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
TestTTLExpirationBasic
(
t
*
testing
.
T
)
{
func
TestTTLExpirationBasic
(
t
*
testing
.
T
)
{
...
@@ -30,7 +31,7 @@ func TestTTLExpirationBasic(t *testing.T) {
...
@@ -30,7 +31,7 @@ func TestTTLExpirationBasic(t *testing.T) {
ttlStore
:=
NewFakeExpirationStore
(
ttlStore
:=
NewFakeExpirationStore
(
testStoreKeyFunc
,
deleteChan
,
testStoreKeyFunc
,
deleteChan
,
&
FakeExpirationPolicy
{
&
FakeExpirationPolicy
{
NeverExpire
:
util
.
NewStringSet
(),
NeverExpire
:
sets
.
NewString
(),
RetrieveKeyFunc
:
func
(
obj
interface
{})
(
string
,
error
)
{
RetrieveKeyFunc
:
func
(
obj
interface
{})
(
string
,
error
)
{
return
obj
.
(
*
timestampedEntry
)
.
obj
.
(
testStoreObject
)
.
id
,
nil
return
obj
.
(
*
timestampedEntry
)
.
obj
.
(
testStoreObject
)
.
id
,
nil
},
},
...
@@ -66,14 +67,14 @@ func TestTTLList(t *testing.T) {
...
@@ -66,14 +67,14 @@ func TestTTLList(t *testing.T) {
{
id
:
"foo1"
,
val
:
"bar1"
},
{
id
:
"foo1"
,
val
:
"bar1"
},
{
id
:
"foo2"
,
val
:
"bar2"
},
{
id
:
"foo2"
,
val
:
"bar2"
},
}
}
expireKeys
:=
util
.
NewStringSet
(
testObjs
[
0
]
.
id
,
testObjs
[
2
]
.
id
)
expireKeys
:=
sets
.
NewString
(
testObjs
[
0
]
.
id
,
testObjs
[
2
]
.
id
)
deleteChan
:=
make
(
chan
string
)
deleteChan
:=
make
(
chan
string
)
defer
close
(
deleteChan
)
defer
close
(
deleteChan
)
ttlStore
:=
NewFakeExpirationStore
(
ttlStore
:=
NewFakeExpirationStore
(
testStoreKeyFunc
,
deleteChan
,
testStoreKeyFunc
,
deleteChan
,
&
FakeExpirationPolicy
{
&
FakeExpirationPolicy
{
NeverExpire
:
util
.
NewStringSet
(
testObjs
[
1
]
.
id
),
NeverExpire
:
sets
.
NewString
(
testObjs
[
1
]
.
id
),
RetrieveKeyFunc
:
func
(
obj
interface
{})
(
string
,
error
)
{
RetrieveKeyFunc
:
func
(
obj
interface
{})
(
string
,
error
)
{
return
obj
.
(
*
timestampedEntry
)
.
obj
.
(
testStoreObject
)
.
id
,
nil
return
obj
.
(
*
timestampedEntry
)
.
obj
.
(
testStoreObject
)
.
id
,
nil
},
},
...
...
pkg/client/unversioned/cache/index.go
View file @
a48f2182
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// Indexer is a storage interface that lets you list objects using multiple indexing functions
// Indexer is a storage interface that lets you list objects using multiple indexing functions
...
@@ -63,7 +63,7 @@ func MetaNamespaceIndexFunc(obj interface{}) ([]string, error) {
...
@@ -63,7 +63,7 @@ func MetaNamespaceIndexFunc(obj interface{}) ([]string, error) {
}
}
// Index maps the indexed value to a set of keys in the store that match on that value
// Index maps the indexed value to a set of keys in the store that match on that value
type
Index
map
[
string
]
util
.
StringSet
type
Index
map
[
string
]
sets
.
String
// Indexers maps a name to a IndexFunc
// Indexers maps a name to a IndexFunc
type
Indexers
map
[
string
]
IndexFunc
type
Indexers
map
[
string
]
IndexFunc
...
...
pkg/client/unversioned/cache/listers_test.go
View file @
a48f2182
...
@@ -22,12 +22,12 @@ import (
...
@@ -22,12 +22,12 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
TestStoreToMinionLister
(
t
*
testing
.
T
)
{
func
TestStoreToMinionLister
(
t
*
testing
.
T
)
{
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
ids
:=
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
)
ids
:=
sets
.
NewString
(
"foo"
,
"bar"
,
"baz"
)
for
id
:=
range
ids
{
for
id
:=
range
ids
{
store
.
Add
(
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
id
}})
store
.
Add
(
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
id
}})
}
}
...
@@ -52,7 +52,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -52,7 +52,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
inRCs
[]
*
api
.
ReplicationController
inRCs
[]
*
api
.
ReplicationController
list
func
()
([]
api
.
ReplicationController
,
error
)
list
func
()
([]
api
.
ReplicationController
,
error
)
outRCNames
util
.
StringSet
outRCNames
sets
.
String
expectErr
bool
expectErr
bool
}{
}{
// Basic listing with all labels and no selectors
// Basic listing with all labels and no selectors
...
@@ -63,7 +63,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -63,7 +63,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
list
:
func
()
([]
api
.
ReplicationController
,
error
)
{
list
:
func
()
([]
api
.
ReplicationController
,
error
)
{
return
lister
.
List
()
return
lister
.
List
()
},
},
outRCNames
:
util
.
NewStringSet
(
"basic"
),
outRCNames
:
sets
.
NewString
(
"basic"
),
},
},
// No pod labels
// No pod labels
{
{
...
@@ -81,7 +81,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -81,7 +81,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}
}
return
lister
.
GetPodControllers
(
pod
)
return
lister
.
GetPodControllers
(
pod
)
},
},
outRCNames
:
util
.
NewStringSet
(),
outRCNames
:
sets
.
NewString
(),
expectErr
:
true
,
expectErr
:
true
,
},
},
// No RC selectors
// No RC selectors
...
@@ -101,7 +101,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}
}
return
lister
.
GetPodControllers
(
pod
)
return
lister
.
GetPodControllers
(
pod
)
},
},
outRCNames
:
util
.
NewStringSet
(),
outRCNames
:
sets
.
NewString
(),
expectErr
:
true
,
expectErr
:
true
,
},
},
// Matching labels to selectors and namespace
// Matching labels to selectors and namespace
...
@@ -130,7 +130,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -130,7 +130,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}
}
return
lister
.
GetPodControllers
(
pod
)
return
lister
.
GetPodControllers
(
pod
)
},
},
outRCNames
:
util
.
NewStringSet
(
"bar"
),
outRCNames
:
sets
.
NewString
(
"bar"
),
},
},
}
}
for
_
,
c
:=
range
testCases
{
for
_
,
c
:=
range
testCases
{
...
@@ -162,7 +162,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -162,7 +162,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
inDSs
[]
*
expapi
.
DaemonSet
inDSs
[]
*
expapi
.
DaemonSet
list
func
()
([]
expapi
.
DaemonSet
,
error
)
list
func
()
([]
expapi
.
DaemonSet
,
error
)
outDaemonSetNames
util
.
StringSet
outDaemonSetNames
sets
.
String
expectErr
bool
expectErr
bool
}{
}{
// Basic listing
// Basic listing
...
@@ -173,7 +173,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -173,7 +173,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
list
:
func
()
([]
expapi
.
DaemonSet
,
error
)
{
list
:
func
()
([]
expapi
.
DaemonSet
,
error
)
{
return
lister
.
List
()
return
lister
.
List
()
},
},
outDaemonSetNames
:
util
.
NewStringSet
(
"basic"
),
outDaemonSetNames
:
sets
.
NewString
(
"basic"
),
},
},
// Listing multiple daemon sets
// Listing multiple daemon sets
{
{
...
@@ -185,7 +185,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -185,7 +185,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
list
:
func
()
([]
expapi
.
DaemonSet
,
error
)
{
list
:
func
()
([]
expapi
.
DaemonSet
,
error
)
{
return
lister
.
List
()
return
lister
.
List
()
},
},
outDaemonSetNames
:
util
.
NewStringSet
(
"basic"
,
"complex"
,
"complex2"
),
outDaemonSetNames
:
sets
.
NewString
(
"basic"
,
"complex"
,
"complex2"
),
},
},
// No pod labels
// No pod labels
{
{
...
@@ -203,7 +203,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -203,7 +203,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
}
}
return
lister
.
GetPodDaemonSets
(
pod
)
return
lister
.
GetPodDaemonSets
(
pod
)
},
},
outDaemonSetNames
:
util
.
NewStringSet
(),
outDaemonSetNames
:
sets
.
NewString
(),
expectErr
:
true
,
expectErr
:
true
,
},
},
// No DS selectors
// No DS selectors
...
@@ -223,7 +223,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -223,7 +223,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
}
}
return
lister
.
GetPodDaemonSets
(
pod
)
return
lister
.
GetPodDaemonSets
(
pod
)
},
},
outDaemonSetNames
:
util
.
NewStringSet
(),
outDaemonSetNames
:
sets
.
NewString
(),
expectErr
:
true
,
expectErr
:
true
,
},
},
// Matching labels to selectors and namespace
// Matching labels to selectors and namespace
...
@@ -252,7 +252,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -252,7 +252,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
}
}
return
lister
.
GetPodDaemonSets
(
pod
)
return
lister
.
GetPodDaemonSets
(
pod
)
},
},
outDaemonSetNames
:
util
.
NewStringSet
(
"bar"
),
outDaemonSetNames
:
sets
.
NewString
(
"bar"
),
},
},
}
}
for
_
,
c
:=
range
testCases
{
for
_
,
c
:=
range
testCases
{
...
...
pkg/client/unversioned/cache/store_test.go
View file @
a48f2182
...
@@ -19,7 +19,7 @@ package cache
...
@@ -19,7 +19,7 @@ package cache
import
(
import
(
"testing"
"testing"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// Test public interface
// Test public interface
...
@@ -54,7 +54,7 @@ func doTestStore(t *testing.T, store Store) {
...
@@ -54,7 +54,7 @@ func doTestStore(t *testing.T, store Store) {
store
.
Add
(
mkObj
(
"c"
,
"d"
))
store
.
Add
(
mkObj
(
"c"
,
"d"
))
store
.
Add
(
mkObj
(
"e"
,
"e"
))
store
.
Add
(
mkObj
(
"e"
,
"e"
))
{
{
found
:=
util
.
StringSet
{}
found
:=
sets
.
String
{}
for
_
,
item
:=
range
store
.
List
()
{
for
_
,
item
:=
range
store
.
List
()
{
found
.
Insert
(
item
.
(
testStoreObject
)
.
val
)
found
.
Insert
(
item
.
(
testStoreObject
)
.
val
)
}
}
...
@@ -73,7 +73,7 @@ func doTestStore(t *testing.T, store Store) {
...
@@ -73,7 +73,7 @@ func doTestStore(t *testing.T, store Store) {
},
"0"
)
},
"0"
)
{
{
found
:=
util
.
StringSet
{}
found
:=
sets
.
String
{}
for
_
,
item
:=
range
store
.
List
()
{
for
_
,
item
:=
range
store
.
List
()
{
found
.
Insert
(
item
.
(
testStoreObject
)
.
val
)
found
.
Insert
(
item
.
(
testStoreObject
)
.
val
)
}
}
...
@@ -93,17 +93,17 @@ func doTestIndex(t *testing.T, indexer Indexer) {
...
@@ -93,17 +93,17 @@ func doTestIndex(t *testing.T, indexer Indexer) {
}
}
// Test Index
// Test Index
expected
:=
map
[
string
]
util
.
StringSet
{}
expected
:=
map
[
string
]
sets
.
String
{}
expected
[
"b"
]
=
util
.
NewStringSet
(
"a"
,
"c"
)
expected
[
"b"
]
=
sets
.
NewString
(
"a"
,
"c"
)
expected
[
"f"
]
=
util
.
NewStringSet
(
"e"
)
expected
[
"f"
]
=
sets
.
NewString
(
"e"
)
expected
[
"h"
]
=
util
.
NewStringSet
(
"g"
)
expected
[
"h"
]
=
sets
.
NewString
(
"g"
)
indexer
.
Add
(
mkObj
(
"a"
,
"b"
))
indexer
.
Add
(
mkObj
(
"a"
,
"b"
))
indexer
.
Add
(
mkObj
(
"c"
,
"b"
))
indexer
.
Add
(
mkObj
(
"c"
,
"b"
))
indexer
.
Add
(
mkObj
(
"e"
,
"f"
))
indexer
.
Add
(
mkObj
(
"e"
,
"f"
))
indexer
.
Add
(
mkObj
(
"g"
,
"h"
))
indexer
.
Add
(
mkObj
(
"g"
,
"h"
))
{
{
for
k
,
v
:=
range
expected
{
for
k
,
v
:=
range
expected
{
found
:=
util
.
StringSet
{}
found
:=
sets
.
String
{}
indexResults
,
err
:=
indexer
.
Index
(
"by_val"
,
mkObj
(
""
,
k
))
indexResults
,
err
:=
indexer
.
Index
(
"by_val"
,
mkObj
(
""
,
k
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error %v"
,
err
)
t
.
Errorf
(
"Unexpected error %v"
,
err
)
...
...
pkg/client/unversioned/cache/thread_safe_store.go
View file @
a48f2182
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"sync"
"sync"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// ThreadSafeStore is an interface that allows concurrent access to a storage backend.
// ThreadSafeStore is an interface that allows concurrent access to a storage backend.
...
@@ -142,7 +142,7 @@ func (c *threadSafeMap) Index(indexName string, obj interface{}) ([]interface{},
...
@@ -142,7 +142,7 @@ func (c *threadSafeMap) Index(indexName string, obj interface{}) ([]interface{},
index
:=
c
.
indices
[
indexName
]
index
:=
c
.
indices
[
indexName
]
// need to de-dupe the return list. Since multiple keys are allowed, this can happen.
// need to de-dupe the return list. Since multiple keys are allowed, this can happen.
returnKeySet
:=
util
.
StringSet
{}
returnKeySet
:=
sets
.
String
{}
for
_
,
indexKey
:=
range
indexKeys
{
for
_
,
indexKey
:=
range
indexKeys
{
set
:=
index
[
indexKey
]
set
:=
index
[
indexKey
]
for
_
,
key
:=
range
set
.
List
()
{
for
_
,
key
:=
range
set
.
List
()
{
...
@@ -208,7 +208,7 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
...
@@ -208,7 +208,7 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
for
_
,
indexValue
:=
range
indexValues
{
for
_
,
indexValue
:=
range
indexValues
{
set
:=
index
[
indexValue
]
set
:=
index
[
indexValue
]
if
set
==
nil
{
if
set
==
nil
{
set
=
util
.
StringSet
{}
set
=
sets
.
String
{}
index
[
indexValue
]
=
set
index
[
indexValue
]
=
set
}
}
set
.
Insert
(
key
)
set
.
Insert
(
key
)
...
...
pkg/client/unversioned/debugging.go
View file @
a48f2182
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// RequestInfo keeps track of information about a request/response combination
// RequestInfo keeps track of information about a request/response combination
...
@@ -75,7 +75,7 @@ func (r RequestInfo) ToCurl() string {
...
@@ -75,7 +75,7 @@ func (r RequestInfo) ToCurl() string {
type
DebuggingRoundTripper
struct
{
type
DebuggingRoundTripper
struct
{
delegatedRoundTripper
http
.
RoundTripper
delegatedRoundTripper
http
.
RoundTripper
Levels
util
.
StringSet
Levels
sets
.
String
}
}
const
(
const
(
...
@@ -88,7 +88,7 @@ const (
...
@@ -88,7 +88,7 @@ const (
)
)
func
NewDebuggingRoundTripper
(
rt
http
.
RoundTripper
,
levels
...
string
)
*
DebuggingRoundTripper
{
func
NewDebuggingRoundTripper
(
rt
http
.
RoundTripper
,
levels
...
string
)
*
DebuggingRoundTripper
{
return
&
DebuggingRoundTripper
{
rt
,
util
.
NewStringSet
(
levels
...
)}
return
&
DebuggingRoundTripper
{
rt
,
sets
.
NewString
(
levels
...
)}
}
}
func
(
rt
*
DebuggingRoundTripper
)
RoundTrip
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
func
(
rt
*
DebuggingRoundTripper
)
RoundTrip
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
...
...
pkg/client/unversioned/flags_test.go
View file @
a48f2182
...
@@ -20,12 +20,12 @@ import (
...
@@ -20,12 +20,12 @@ import (
"testing"
"testing"
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
fakeFlagSet
struct
{
type
fakeFlagSet
struct
{
t
*
testing
.
T
t
*
testing
.
T
set
util
.
StringSet
set
sets
.
String
}
}
func
(
f
*
fakeFlagSet
)
StringVar
(
p
*
string
,
name
,
value
,
usage
string
)
{
func
(
f
*
fakeFlagSet
)
StringVar
(
p
*
string
,
name
,
value
,
usage
string
)
{
...
...
pkg/client/unversioned/helper.go
View file @
a48f2182
...
@@ -35,6 +35,7 @@ import (
...
@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/version"
)
)
...
@@ -187,7 +188,7 @@ func NegotiateVersion(client *Client, c *Config, version string, clientRegistere
...
@@ -187,7 +188,7 @@ func NegotiateVersion(client *Client, c *Config, version string, clientRegistere
return
""
,
err
return
""
,
err
}
}
}
}
clientVersions
:=
util
.
StringSet
{}
clientVersions
:=
sets
.
String
{}
for
_
,
v
:=
range
clientRegisteredVersions
{
for
_
,
v
:=
range
clientRegisteredVersions
{
clientVersions
.
Insert
(
v
)
clientVersions
.
Insert
(
v
)
}
}
...
@@ -195,7 +196,7 @@ func NegotiateVersion(client *Client, c *Config, version string, clientRegistere
...
@@ -195,7 +196,7 @@ func NegotiateVersion(client *Client, c *Config, version string, clientRegistere
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"couldn't read version from server: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"couldn't read version from server: %v"
,
err
)
}
}
serverVersions
:=
util
.
StringSet
{}
serverVersions
:=
sets
.
String
{}
for
_
,
v
:=
range
apiVersions
.
Versions
{
for
_
,
v
:=
range
apiVersions
.
Versions
{
serverVersions
.
Insert
(
v
)
serverVersions
.
Insert
(
v
)
}
}
...
...
pkg/client/unversioned/request.go
View file @
a48f2182
...
@@ -39,13 +39,14 @@ import (
...
@@ -39,13 +39,14 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
)
)
// specialParams lists parameters that are handled specially and which users of Request
// specialParams lists parameters that are handled specially and which users of Request
// are therefore not allowed to set manually.
// are therefore not allowed to set manually.
var
specialParams
=
util
.
NewStringSet
(
"timeout"
)
var
specialParams
=
sets
.
NewString
(
"timeout"
)
// HTTPClient is an interface for testing a request object.
// HTTPClient is an interface for testing a request object.
type
HTTPClient
interface
{
type
HTTPClient
interface
{
...
...
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
View file @
a48f2182
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
(
s
*
AWSCloud
)
ensureLoadBalancer
(
region
,
name
string
,
listeners
[]
*
elb
.
Listener
,
subnetIDs
[]
string
,
securityGroupIDs
[]
string
)
(
*
elb
.
LoadBalancerDescription
,
error
)
{
func
(
s
*
AWSCloud
)
ensureLoadBalancer
(
region
,
name
string
,
listeners
[]
*
elb
.
Listener
,
subnetIDs
[]
string
,
securityGroupIDs
[]
string
)
(
*
elb
.
LoadBalancerDescription
,
error
)
{
...
@@ -61,7 +61,7 @@ func (s *AWSCloud) ensureLoadBalancer(region, name string, listeners []*elb.List
...
@@ -61,7 +61,7 @@ func (s *AWSCloud) ensureLoadBalancer(region, name string, listeners []*elb.List
}
else
{
}
else
{
{
{
// Sync subnets
// Sync subnets
expected
:=
util
.
NewStringSet
(
subnetIDs
...
)
expected
:=
sets
.
NewString
(
subnetIDs
...
)
actual
:=
stringSetFromPointers
(
loadBalancer
.
Subnets
)
actual
:=
stringSetFromPointers
(
loadBalancer
.
Subnets
)
additions
:=
expected
.
Difference
(
actual
)
additions
:=
expected
.
Difference
(
actual
)
...
@@ -94,7 +94,7 @@ func (s *AWSCloud) ensureLoadBalancer(region, name string, listeners []*elb.List
...
@@ -94,7 +94,7 @@ func (s *AWSCloud) ensureLoadBalancer(region, name string, listeners []*elb.List
{
{
// Sync security groups
// Sync security groups
expected
:=
util
.
NewStringSet
(
securityGroupIDs
...
)
expected
:=
sets
.
NewString
(
securityGroupIDs
...
)
actual
:=
stringSetFromPointers
(
loadBalancer
.
SecurityGroups
)
actual
:=
stringSetFromPointers
(
loadBalancer
.
SecurityGroups
)
if
!
expected
.
Equal
(
actual
)
{
if
!
expected
.
Equal
(
actual
)
{
...
@@ -255,12 +255,12 @@ func (s *AWSCloud) ensureLoadBalancerHealthCheck(region string, loadBalancer *el
...
@@ -255,12 +255,12 @@ func (s *AWSCloud) ensureLoadBalancerHealthCheck(region string, loadBalancer *el
// Makes sure that exactly the specified hosts are registered as instances with the load balancer
// Makes sure that exactly the specified hosts are registered as instances with the load balancer
func
(
s
*
AWSCloud
)
ensureLoadBalancerInstances
(
elbClient
ELB
,
loadBalancerName
string
,
lbInstances
[]
*
elb
.
Instance
,
instances
[]
*
ec2
.
Instance
)
error
{
func
(
s
*
AWSCloud
)
ensureLoadBalancerInstances
(
elbClient
ELB
,
loadBalancerName
string
,
lbInstances
[]
*
elb
.
Instance
,
instances
[]
*
ec2
.
Instance
)
error
{
expected
:=
util
.
NewStringSet
()
expected
:=
sets
.
NewString
()
for
_
,
instance
:=
range
instances
{
for
_
,
instance
:=
range
instances
{
expected
.
Insert
(
orEmpty
(
instance
.
InstanceID
))
expected
.
Insert
(
orEmpty
(
instance
.
InstanceID
))
}
}
actual
:=
util
.
NewStringSet
()
actual
:=
sets
.
NewString
()
for
_
,
lbInstance
:=
range
lbInstances
{
for
_
,
lbInstance
:=
range
lbInstances
{
actual
.
Insert
(
orEmpty
(
lbInstance
.
InstanceID
))
actual
.
Insert
(
orEmpty
(
lbInstance
.
InstanceID
))
}
}
...
...
pkg/cloudprovider/providers/aws/aws_utils.go
View file @
a48f2182
...
@@ -18,10 +18,10 @@ package aws_cloud
...
@@ -18,10 +18,10 @@ package aws_cloud
import
(
import
(
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
stringSetToPointers
(
in
util
.
StringSet
)
[]
*
string
{
func
stringSetToPointers
(
in
sets
.
String
)
[]
*
string
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
...
@@ -32,11 +32,11 @@ func stringSetToPointers(in util.StringSet) []*string {
...
@@ -32,11 +32,11 @@ func stringSetToPointers(in util.StringSet) []*string {
return
out
return
out
}
}
func
stringSetFromPointers
(
in
[]
*
string
)
util
.
StringSet
{
func
stringSetFromPointers
(
in
[]
*
string
)
sets
.
String
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
util
.
NewStringSet
()
out
:=
sets
.
NewString
()
for
i
:=
range
in
{
for
i
:=
range
in
{
out
.
Insert
(
orEmpty
(
in
[
i
]))
out
.
Insert
(
orEmpty
(
in
[
i
]))
}
}
...
...
pkg/cloudprovider/providers/gce/gce.go
View file @
a48f2182
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -464,7 +464,7 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(name, region string, hosts []string)
...
@@ -464,7 +464,7 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(name, region string, hosts []string)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
existing
:=
util
.
NewStringSet
()
existing
:=
sets
.
NewString
()
for
_
,
instance
:=
range
pool
.
Instances
{
for
_
,
instance
:=
range
pool
.
Instances
{
existing
.
Insert
(
hostURLToComparablePath
(
instance
))
existing
.
Insert
(
hostURLToComparablePath
(
instance
))
}
}
...
...
pkg/controller/controller_utils_test.go
View file @
a48f2182
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// NewFakeControllerExpectationsLookup creates a fake store for PodExpectations.
// NewFakeControllerExpectationsLookup creates a fake store for PodExpectations.
...
@@ -224,13 +225,13 @@ func TestActivePodFiltering(t *testing.T) {
...
@@ -224,13 +225,13 @@ func TestActivePodFiltering(t *testing.T) {
podList
:=
newPodList
(
nil
,
5
,
api
.
PodRunning
,
rc
)
podList
:=
newPodList
(
nil
,
5
,
api
.
PodRunning
,
rc
)
podList
.
Items
[
0
]
.
Status
.
Phase
=
api
.
PodSucceeded
podList
.
Items
[
0
]
.
Status
.
Phase
=
api
.
PodSucceeded
podList
.
Items
[
1
]
.
Status
.
Phase
=
api
.
PodFailed
podList
.
Items
[
1
]
.
Status
.
Phase
=
api
.
PodFailed
expectedNames
:=
util
.
NewStringSet
()
expectedNames
:=
sets
.
NewString
()
for
_
,
pod
:=
range
podList
.
Items
[
2
:
]
{
for
_
,
pod
:=
range
podList
.
Items
[
2
:
]
{
expectedNames
.
Insert
(
pod
.
Name
)
expectedNames
.
Insert
(
pod
.
Name
)
}
}
got
:=
FilterActivePods
(
podList
.
Items
)
got
:=
FilterActivePods
(
podList
.
Items
)
gotNames
:=
util
.
NewStringSet
()
gotNames
:=
sets
.
NewString
()
for
_
,
pod
:=
range
got
{
for
_
,
pod
:=
range
got
{
gotNames
.
Insert
(
pod
.
Name
)
gotNames
.
Insert
(
pod
.
Name
)
}
}
...
...
pkg/controller/endpoint/endpoints_controller.go
View file @
a48f2182
...
@@ -33,6 +33,7 @@ import (
...
@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/workqueue"
"k8s.io/kubernetes/pkg/util/workqueue"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -141,8 +142,8 @@ func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) {
...
@@ -141,8 +142,8 @@ func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) {
e
.
queue
.
ShutDown
()
e
.
queue
.
ShutDown
()
}
}
func
(
e
*
EndpointController
)
getPodServiceMemberships
(
pod
*
api
.
Pod
)
(
util
.
StringSet
,
error
)
{
func
(
e
*
EndpointController
)
getPodServiceMemberships
(
pod
*
api
.
Pod
)
(
sets
.
String
,
error
)
{
set
:=
util
.
StringSet
{}
set
:=
sets
.
String
{}
services
,
err
:=
e
.
serviceStore
.
GetPodServices
(
pod
)
services
,
err
:=
e
.
serviceStore
.
GetPodServices
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
// don't log this error because this function makes pointless
// don't log this error because this function makes pointless
...
...
pkg/controller/framework/controller_test.go
View file @
a48f2182
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"github.com/google/gofuzz"
"github.com/google/gofuzz"
)
)
...
@@ -104,7 +104,7 @@ func Example() {
...
@@ -104,7 +104,7 @@ func Example() {
}
}
// Let's wait for the controller to process the things we just added.
// Let's wait for the controller to process the things we just added.
outputSet
:=
util
.
StringSet
{}
outputSet
:=
sets
.
String
{}
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
outputSet
.
Insert
(
<-
deletionCounter
)
outputSet
.
Insert
(
<-
deletionCounter
)
}
}
...
@@ -161,7 +161,7 @@ func ExampleInformer() {
...
@@ -161,7 +161,7 @@ func ExampleInformer() {
}
}
// Let's wait for the controller to process the things we just added.
// Let's wait for the controller to process the things we just added.
outputSet
:=
util
.
StringSet
{}
outputSet
:=
sets
.
String
{}
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
outputSet
.
Insert
(
<-
deletionCounter
)
outputSet
.
Insert
(
<-
deletionCounter
)
}
}
...
@@ -235,7 +235,7 @@ func TestHammerController(t *testing.T) {
...
@@ -235,7 +235,7 @@ func TestHammerController(t *testing.T) {
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
// Let's add a few objects to the source.
// Let's add a few objects to the source.
currentNames
:=
util
.
StringSet
{}
currentNames
:=
sets
.
String
{}
rs
:=
rand
.
NewSource
(
rand
.
Int63
())
rs
:=
rand
.
NewSource
(
rand
.
Int63
())
f
:=
fuzz
.
New
()
.
NilChance
(
.5
)
.
NumElements
(
0
,
2
)
.
RandSource
(
rs
)
f
:=
fuzz
.
New
()
.
NilChance
(
.5
)
.
NumElements
(
0
,
2
)
.
RandSource
(
rs
)
r
:=
rand
.
New
(
rs
)
// Mustn't use r and f concurrently!
r
:=
rand
.
New
(
rs
)
// Mustn't use r and f concurrently!
...
...
pkg/controller/namespace/namespace_controller.go
View file @
a48f2182
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -128,7 +129,7 @@ func finalize(kubeClient client.Interface, namespace api.Namespace) (*api.Namesp
...
@@ -128,7 +129,7 @@ func finalize(kubeClient client.Interface, namespace api.Namespace) (*api.Namesp
namespaceFinalize
:=
api
.
Namespace
{}
namespaceFinalize
:=
api
.
Namespace
{}
namespaceFinalize
.
ObjectMeta
=
namespace
.
ObjectMeta
namespaceFinalize
.
ObjectMeta
=
namespace
.
ObjectMeta
namespaceFinalize
.
Spec
=
namespace
.
Spec
namespaceFinalize
.
Spec
=
namespace
.
Spec
finalizerSet
:=
util
.
NewStringSet
()
finalizerSet
:=
sets
.
NewString
()
for
i
:=
range
namespace
.
Spec
.
Finalizers
{
for
i
:=
range
namespace
.
Spec
.
Finalizers
{
if
namespace
.
Spec
.
Finalizers
[
i
]
!=
api
.
FinalizerKubernetes
{
if
namespace
.
Spec
.
Finalizers
[
i
]
!=
api
.
FinalizerKubernetes
{
finalizerSet
.
Insert
(
string
(
namespace
.
Spec
.
Finalizers
[
i
]))
finalizerSet
.
Insert
(
string
(
namespace
.
Spec
.
Finalizers
[
i
]))
...
...
pkg/controller/namespace/namespace_controller_test.go
View file @
a48f2182
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
TestFinalized
(
t
*
testing
.
T
)
{
func
TestFinalized
(
t
*
testing
.
T
)
{
...
@@ -90,7 +91,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
...
@@ -90,7 +91,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
t
.
Errorf
(
"Unexpected error when synching namespace %v"
,
err
)
t
.
Errorf
(
"Unexpected error when synching namespace %v"
,
err
)
}
}
// TODO: Reuse the constants for all these strings from testclient
// TODO: Reuse the constants for all these strings from testclient
expectedActionSet
:=
util
.
NewStringSet
(
expectedActionSet
:=
sets
.
NewString
(
strings
.
Join
([]
string
{
"list"
,
"replicationcontrollers"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"replicationcontrollers"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"services"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"services"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"pods"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"pods"
,
""
},
"-"
),
...
@@ -112,7 +113,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
...
@@ -112,7 +113,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
)
)
}
}
actionSet
:=
util
.
NewStringSet
()
actionSet
:=
sets
.
NewString
()
for
_
,
action
:=
range
mockClient
.
Actions
()
{
for
_
,
action
:=
range
mockClient
.
Actions
()
{
actionSet
.
Insert
(
strings
.
Join
([]
string
{
action
.
GetVerb
(),
action
.
GetResource
(),
action
.
GetSubresource
()},
"-"
))
actionSet
.
Insert
(
strings
.
Join
([]
string
{
action
.
GetVerb
(),
action
.
GetResource
(),
action
.
GetSubresource
()},
"-"
))
}
}
...
...
pkg/controller/node/nodecontroller.go
View file @
a48f2182
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
var
(
var
(
...
@@ -58,7 +59,7 @@ type NodeController struct {
...
@@ -58,7 +59,7 @@ type NodeController struct {
cloud
cloudprovider
.
Interface
cloud
cloudprovider
.
Interface
clusterCIDR
*
net
.
IPNet
clusterCIDR
*
net
.
IPNet
deletingPodsRateLimiter
util
.
RateLimiter
deletingPodsRateLimiter
util
.
RateLimiter
knownNodeSet
util
.
StringSet
knownNodeSet
sets
.
String
kubeClient
client
.
Interface
kubeClient
client
.
Interface
// Method for easy mocking in unittest.
// Method for easy mocking in unittest.
lookupIP
func
(
host
string
)
([]
net
.
IP
,
error
)
lookupIP
func
(
host
string
)
([]
net
.
IP
,
error
)
...
@@ -126,7 +127,7 @@ func NewNodeController(
...
@@ -126,7 +127,7 @@ func NewNodeController(
evictorLock
:=
sync
.
Mutex
{}
evictorLock
:=
sync
.
Mutex
{}
return
&
NodeController
{
return
&
NodeController
{
cloud
:
cloud
,
cloud
:
cloud
,
knownNodeSet
:
make
(
util
.
StringSet
),
knownNodeSet
:
make
(
sets
.
String
),
kubeClient
:
kubeClient
,
kubeClient
:
kubeClient
,
recorder
:
recorder
,
recorder
:
recorder
,
podEvictionTimeout
:
podEvictionTimeout
,
podEvictionTimeout
:
podEvictionTimeout
,
...
@@ -211,8 +212,8 @@ func (nc *NodeController) Run(period time.Duration) {
...
@@ -211,8 +212,8 @@ func (nc *NodeController) Run(period time.Duration) {
}
}
// Generates num pod CIDRs that could be assigned to nodes.
// Generates num pod CIDRs that could be assigned to nodes.
func
generateCIDRs
(
clusterCIDR
*
net
.
IPNet
,
num
int
)
util
.
StringSet
{
func
generateCIDRs
(
clusterCIDR
*
net
.
IPNet
,
num
int
)
sets
.
String
{
res
:=
util
.
NewStringSet
()
res
:=
sets
.
NewString
()
cidrIP
:=
clusterCIDR
.
IP
.
To4
()
cidrIP
:=
clusterCIDR
.
IP
.
To4
()
for
i
:=
0
;
i
<
num
;
i
++
{
for
i
:=
0
;
i
<
num
;
i
++
{
// TODO: Make the CIDRs configurable.
// TODO: Make the CIDRs configurable.
...
@@ -256,7 +257,7 @@ func (nc *NodeController) monitorNodeStatus() error {
...
@@ -256,7 +257,7 @@ func (nc *NodeController) monitorNodeStatus() error {
// If there's a difference between lengths of known Nodes and observed nodes
// If there's a difference between lengths of known Nodes and observed nodes
// we must have removed some Node.
// we must have removed some Node.
if
len
(
nc
.
knownNodeSet
)
!=
len
(
nodes
.
Items
)
{
if
len
(
nc
.
knownNodeSet
)
!=
len
(
nodes
.
Items
)
{
observedSet
:=
make
(
util
.
StringSet
)
observedSet
:=
make
(
sets
.
String
)
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
.
Items
{
observedSet
.
Insert
(
node
.
Name
)
observedSet
.
Insert
(
node
.
Name
)
}
}
...
...
pkg/controller/node/rate_limited_queue.go
View file @
a48f2182
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// TimedValue is a value that should be processed at a designated time.
// TimedValue is a value that should be processed at a designated time.
...
@@ -58,7 +59,7 @@ func (h *TimedQueue) Pop() interface{} {
...
@@ -58,7 +59,7 @@ func (h *TimedQueue) Pop() interface{} {
type
UniqueQueue
struct
{
type
UniqueQueue
struct
{
lock
sync
.
Mutex
lock
sync
.
Mutex
queue
TimedQueue
queue
TimedQueue
set
util
.
StringSet
set
sets
.
String
}
}
// Adds a new value to the queue if it wasn't added before, or was explicitly removed by the
// Adds a new value to the queue if it wasn't added before, or was explicitly removed by the
...
@@ -143,7 +144,7 @@ func NewRateLimitedTimedQueue(limiter util.RateLimiter) *RateLimitedTimedQueue {
...
@@ -143,7 +144,7 @@ func NewRateLimitedTimedQueue(limiter util.RateLimiter) *RateLimitedTimedQueue {
return
&
RateLimitedTimedQueue
{
return
&
RateLimitedTimedQueue
{
queue
:
UniqueQueue
{
queue
:
UniqueQueue
{
queue
:
TimedQueue
{},
queue
:
TimedQueue
{},
set
:
util
.
NewStringSet
(),
set
:
sets
.
NewString
(),
},
},
limiter
:
limiter
,
limiter
:
limiter
,
}
}
...
...
pkg/controller/node/rate_limited_queue_test.go
View file @
a48f2182
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
CheckQueueEq
(
lhs
[]
string
,
rhs
TimedQueue
)
bool
{
func
CheckQueueEq
(
lhs
[]
string
,
rhs
TimedQueue
)
bool
{
...
@@ -33,7 +34,7 @@ func CheckQueueEq(lhs []string, rhs TimedQueue) bool {
...
@@ -33,7 +34,7 @@ func CheckQueueEq(lhs []string, rhs TimedQueue) bool {
return
true
return
true
}
}
func
CheckSetEq
(
lhs
,
rhs
util
.
StringSet
)
bool
{
func
CheckSetEq
(
lhs
,
rhs
sets
.
String
)
bool
{
return
lhs
.
HasAll
(
rhs
.
List
()
...
)
&&
rhs
.
HasAll
(
lhs
.
List
()
...
)
return
lhs
.
HasAll
(
rhs
.
List
()
...
)
&&
rhs
.
HasAll
(
lhs
.
List
()
...
)
}
}
...
@@ -51,7 +52,7 @@ func TestAddNode(t *testing.T) {
...
@@ -51,7 +52,7 @@ func TestAddNode(t *testing.T) {
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
}
}
setPattern
:=
util
.
NewStringSet
(
"first"
,
"second"
,
"third"
)
setPattern
:=
sets
.
NewString
(
"first"
,
"second"
,
"third"
)
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
}
}
...
@@ -75,7 +76,7 @@ func TestDelNode(t *testing.T) {
...
@@ -75,7 +76,7 @@ func TestDelNode(t *testing.T) {
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
}
}
setPattern
:=
util
.
NewStringSet
(
"second"
,
"third"
)
setPattern
:=
sets
.
NewString
(
"second"
,
"third"
)
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
}
}
...
@@ -97,7 +98,7 @@ func TestDelNode(t *testing.T) {
...
@@ -97,7 +98,7 @@ func TestDelNode(t *testing.T) {
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
}
}
setPattern
=
util
.
NewStringSet
(
"first"
,
"third"
)
setPattern
=
sets
.
NewString
(
"first"
,
"third"
)
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
}
}
...
@@ -119,7 +120,7 @@ func TestDelNode(t *testing.T) {
...
@@ -119,7 +120,7 @@ func TestDelNode(t *testing.T) {
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
t
.
Errorf
(
"Invalid queue. Got %v, expected %v"
,
evictor
.
queue
.
queue
,
queuePattern
)
}
}
setPattern
=
util
.
NewStringSet
(
"first"
,
"second"
)
setPattern
=
sets
.
NewString
(
"first"
,
"second"
)
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
if
len
(
evictor
.
queue
.
set
)
!=
len
(
setPattern
)
{
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
}
}
...
@@ -135,13 +136,13 @@ func TestTry(t *testing.T) {
...
@@ -135,13 +136,13 @@ func TestTry(t *testing.T) {
evictor
.
Add
(
"third"
)
evictor
.
Add
(
"third"
)
evictor
.
Remove
(
"second"
)
evictor
.
Remove
(
"second"
)
deletedMap
:=
util
.
NewStringSet
()
deletedMap
:=
sets
.
NewString
()
evictor
.
Try
(
func
(
value
TimedValue
)
(
bool
,
time
.
Duration
)
{
evictor
.
Try
(
func
(
value
TimedValue
)
(
bool
,
time
.
Duration
)
{
deletedMap
.
Insert
(
value
.
Value
)
deletedMap
.
Insert
(
value
.
Value
)
return
true
,
0
return
true
,
0
})
})
setPattern
:=
util
.
NewStringSet
(
"first"
,
"third"
)
setPattern
:=
sets
.
NewString
(
"first"
,
"third"
)
if
len
(
deletedMap
)
!=
len
(
setPattern
)
{
if
len
(
deletedMap
)
!=
len
(
setPattern
)
{
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
t
.
Fatalf
(
"Map %v should have length %d"
,
evictor
.
queue
.
set
,
len
(
setPattern
))
}
}
...
...
pkg/controller/replication/replication_controller_test.go
View file @
a48f2182
...
@@ -35,6 +35,7 @@ import (
...
@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -626,7 +627,7 @@ func TestUpdatePods(t *testing.T) {
...
@@ -626,7 +627,7 @@ func TestUpdatePods(t *testing.T) {
// both controllers
// both controllers
manager
.
updatePod
(
&
pod1
,
&
pod2
)
manager
.
updatePod
(
&
pod1
,
&
pod2
)
expected
:=
util
.
NewStringSet
(
testControllerSpec1
.
Name
,
testControllerSpec2
.
Name
)
expected
:=
sets
.
NewString
(
testControllerSpec1
.
Name
,
testControllerSpec2
.
Name
)
for
_
,
name
:=
range
expected
.
List
()
{
for
_
,
name
:=
range
expected
.
List
()
{
t
.
Logf
(
"Expecting update for %+v"
,
name
)
t
.
Logf
(
"Expecting update for %+v"
,
name
)
select
{
select
{
...
...
pkg/controller/resourcequota/resource_quota_controller_test.go
View file @
a48f2182
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
getResourceList
(
cpu
,
memory
string
)
api
.
ResourceList
{
func
getResourceList
(
cpu
,
memory
string
)
api
.
ResourceList
{
...
@@ -103,11 +103,11 @@ func TestFilterQuotaPods(t *testing.T) {
...
@@ -103,11 +103,11 @@ func TestFilterQuotaPods(t *testing.T) {
Status
:
api
.
PodStatus
{
Phase
:
api
.
PodFailed
},
Status
:
api
.
PodStatus
{
Phase
:
api
.
PodFailed
},
},
},
}
}
expectedResults
:=
util
.
NewStringSet
(
"pod-running"
,
expectedResults
:=
sets
.
NewString
(
"pod-running"
,
"pod-pending"
,
"pod-unknown"
,
"pod-failed-with-restart-always"
,
"pod-pending"
,
"pod-unknown"
,
"pod-failed-with-restart-always"
,
"pod-failed-with-restart-on-failure"
)
"pod-failed-with-restart-on-failure"
)
actualResults
:=
util
.
StringSet
{}
actualResults
:=
sets
.
String
{}
result
:=
FilterQuotaPods
(
pods
)
result
:=
FilterQuotaPods
(
pods
)
for
i
:=
range
result
{
for
i
:=
range
result
{
actualResults
.
Insert
(
result
[
i
]
.
Name
)
actualResults
.
Insert
(
result
[
i
]
.
Name
)
...
...
pkg/controller/serviceaccount/serviceaccounts_controller.go
View file @
a48f2182
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -45,7 +45,7 @@ func nameIndexFunc(obj interface{}) ([]string, error) {
...
@@ -45,7 +45,7 @@ func nameIndexFunc(obj interface{}) ([]string, error) {
// ServiceAccountsControllerOptions contains options for running a ServiceAccountsController
// ServiceAccountsControllerOptions contains options for running a ServiceAccountsController
type
ServiceAccountsControllerOptions
struct
{
type
ServiceAccountsControllerOptions
struct
{
// Names is the set of service account names to ensure exist in every namespace
// Names is the set of service account names to ensure exist in every namespace
Names
util
.
StringSet
Names
sets
.
String
// ServiceAccountResync is the interval between full resyncs of ServiceAccounts.
// ServiceAccountResync is the interval between full resyncs of ServiceAccounts.
// If non-zero, all service accounts will be re-listed this often.
// If non-zero, all service accounts will be re-listed this often.
...
@@ -59,7 +59,7 @@ type ServiceAccountsControllerOptions struct {
...
@@ -59,7 +59,7 @@ type ServiceAccountsControllerOptions struct {
}
}
func
DefaultServiceAccountsControllerOptions
()
ServiceAccountsControllerOptions
{
func
DefaultServiceAccountsControllerOptions
()
ServiceAccountsControllerOptions
{
return
ServiceAccountsControllerOptions
{
Names
:
util
.
NewStringSet
(
"default"
)}
return
ServiceAccountsControllerOptions
{
Names
:
sets
.
NewString
(
"default"
)}
}
}
// NewServiceAccountsController returns a new *ServiceAccountsController.
// NewServiceAccountsController returns a new *ServiceAccountsController.
...
@@ -117,7 +117,7 @@ type ServiceAccountsController struct {
...
@@ -117,7 +117,7 @@ type ServiceAccountsController struct {
stopChan
chan
struct
{}
stopChan
chan
struct
{}
client
client
.
Interface
client
client
.
Interface
names
util
.
StringSet
names
sets
.
String
serviceAccounts
cache
.
Indexer
serviceAccounts
cache
.
Indexer
namespaces
cache
.
Indexer
namespaces
cache
.
Indexer
...
...
pkg/controller/serviceaccount/serviceaccounts_controller_test.go
View file @
a48f2182
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
type
serverResponse
struct
{
type
serverResponse
struct
{
...
@@ -101,7 +102,7 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -101,7 +102,7 @@ func TestServiceAccountCreation(t *testing.T) {
"new active namespace missing serviceaccounts"
:
{
"new active namespace missing serviceaccounts"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
AddedNamespace
:
activeNS
,
AddedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
util
.
NewStringSet
(
defaultName
,
managedName
)
.
List
(),
ExpectCreatedServiceAccounts
:
sets
.
NewString
(
defaultName
,
managedName
)
.
List
(),
},
},
"new active namespace missing serviceaccount"
:
{
"new active namespace missing serviceaccount"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
managedServiceAccount
},
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
managedServiceAccount
},
...
@@ -123,7 +124,7 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -123,7 +124,7 @@ func TestServiceAccountCreation(t *testing.T) {
"updated active namespace missing serviceaccounts"
:
{
"updated active namespace missing serviceaccounts"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
UpdatedNamespace
:
activeNS
,
UpdatedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
util
.
NewStringSet
(
defaultName
,
managedName
)
.
List
(),
ExpectCreatedServiceAccounts
:
sets
.
NewString
(
defaultName
,
managedName
)
.
List
(),
},
},
"updated active namespace missing serviceaccount"
:
{
"updated active namespace missing serviceaccount"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
defaultServiceAccount
},
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
defaultServiceAccount
},
...
@@ -170,7 +171,7 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -170,7 +171,7 @@ func TestServiceAccountCreation(t *testing.T) {
for
k
,
tc
:=
range
testcases
{
for
k
,
tc
:=
range
testcases
{
client
:=
testclient
.
NewSimpleFake
(
defaultServiceAccount
,
managedServiceAccount
)
client
:=
testclient
.
NewSimpleFake
(
defaultServiceAccount
,
managedServiceAccount
)
options
:=
DefaultServiceAccountsControllerOptions
()
options
:=
DefaultServiceAccountsControllerOptions
()
options
.
Names
=
util
.
NewStringSet
(
defaultName
,
managedName
)
options
.
Names
=
sets
.
NewString
(
defaultName
,
managedName
)
controller
:=
NewServiceAccountsController
(
client
,
options
)
controller
:=
NewServiceAccountsController
(
client
,
options
)
if
tc
.
ExistingNamespace
!=
nil
{
if
tc
.
ExistingNamespace
!=
nil
{
...
...
pkg/controller/serviceaccount/tokens_controller.go
View file @
a48f2182
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/secret"
"k8s.io/kubernetes/pkg/registry/secret"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -495,8 +495,8 @@ func serviceAccountNameAndUID(secret *api.Secret) (string, string) {
...
@@ -495,8 +495,8 @@ func serviceAccountNameAndUID(secret *api.Secret) (string, string) {
return
secret
.
Annotations
[
api
.
ServiceAccountNameKey
],
secret
.
Annotations
[
api
.
ServiceAccountUIDKey
]
return
secret
.
Annotations
[
api
.
ServiceAccountNameKey
],
secret
.
Annotations
[
api
.
ServiceAccountUIDKey
]
}
}
func
getSecretReferences
(
serviceAccount
*
api
.
ServiceAccount
)
util
.
StringSet
{
func
getSecretReferences
(
serviceAccount
*
api
.
ServiceAccount
)
sets
.
String
{
references
:=
util
.
NewStringSet
()
references
:=
sets
.
NewString
()
for
_
,
secret
:=
range
serviceAccount
.
Secrets
{
for
_
,
secret
:=
range
serviceAccount
.
Secrets
{
references
.
Insert
(
secret
.
Name
)
references
.
Insert
(
secret
.
Name
)
}
}
...
...
pkg/credentialprovider/keyring.go
View file @
a48f2182
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// DockerKeyring tracks a set of docker registry credentials, maintaining a
// DockerKeyring tracks a set of docker registry credentials, maintaining a
...
@@ -90,7 +90,7 @@ func (dk *BasicDockerKeyring) Add(cfg DockerConfig) {
...
@@ -90,7 +90,7 @@ func (dk *BasicDockerKeyring) Add(cfg DockerConfig) {
}
}
}
}
eliminateDupes
:=
util
.
NewStringSet
(
dk
.
index
...
)
eliminateDupes
:=
sets
.
NewString
(
dk
.
index
...
)
dk
.
index
=
eliminateDupes
.
List
()
dk
.
index
=
eliminateDupes
.
List
()
// Update the index used to identify which credentials to use for a given
// Update the index used to identify which credentials to use for a given
...
...
pkg/expapi/latest/latest.go
View file @
a48f2182
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
_
"k8s.io/kubernetes/pkg/expapi"
_
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/expapi/v1"
"k8s.io/kubernetes/pkg/expapi/v1"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
var
(
var
(
...
@@ -51,9 +51,9 @@ func init() {
...
@@ -51,9 +51,9 @@ func init() {
// the list of kinds that are scoped at the root of the api hierarchy
// the list of kinds that are scoped at the root of the api hierarchy
// if a kind is not enumerated here, it is assumed to have a namespace scope
// if a kind is not enumerated here, it is assumed to have a namespace scope
rootScoped
:=
util
.
NewStringSet
()
rootScoped
:=
sets
.
NewString
()
ignoredKinds
:=
util
.
NewStringSet
()
ignoredKinds
:=
sets
.
NewString
()
RESTMapper
=
api
.
NewDefaultRESTMapper
(
"experimental"
,
Versions
,
InterfacesFor
,
importPrefix
,
ignoredKinds
,
rootScoped
)
RESTMapper
=
api
.
NewDefaultRESTMapper
(
"experimental"
,
Versions
,
InterfacesFor
,
importPrefix
,
ignoredKinds
,
rootScoped
)
api
.
RegisterRESTMapper
(
RESTMapper
)
api
.
RegisterRESTMapper
(
RESTMapper
)
...
...
pkg/expapi/validation/validation.go
View file @
a48f2182
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// ValidateHorizontalPodAutoscaler can be used to check whether the given autoscaler name is valid.
// ValidateHorizontalPodAutoscaler can be used to check whether the given autoscaler name is valid.
...
@@ -79,7 +80,7 @@ func ValidateThirdPartyResource(obj *expapi.ThirdPartyResource) errs.ValidationE
...
@@ -79,7 +80,7 @@ func ValidateThirdPartyResource(obj *expapi.ThirdPartyResource) errs.ValidationE
if
len
(
obj
.
Name
)
==
0
{
if
len
(
obj
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
obj
.
Name
,
"name must be non-empty"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
obj
.
Name
,
"name must be non-empty"
))
}
}
versions
:=
util
.
StringSet
{}
versions
:=
sets
.
String
{}
for
ix
:=
range
obj
.
Versions
{
for
ix
:=
range
obj
.
Versions
{
version
:=
&
obj
.
Versions
[
ix
]
version
:=
&
obj
.
Versions
[
ix
]
if
len
(
version
.
Name
)
==
0
{
if
len
(
version
.
Name
)
==
0
{
...
...
pkg/kubectl/cmd/config/navigation_step_parser.go
View file @
a48f2182
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"strings"
"strings"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
navigationSteps
struct
{
type
navigationSteps
struct
{
...
@@ -55,7 +55,7 @@ func newNavigationSteps(path string) (*navigationSteps, error) {
...
@@ -55,7 +55,7 @@ func newNavigationSteps(path string) (*navigationSteps, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
nextPart
:=
findNameStep
(
individualParts
[
currPartIndex
:
],
util
.
KeySet
(
reflect
.
ValueOf
(
mapValueOptions
)))
nextPart
:=
findNameStep
(
individualParts
[
currPartIndex
:
],
sets
.
KeySet
(
reflect
.
ValueOf
(
mapValueOptions
)))
steps
=
append
(
steps
,
navigationStep
{
nextPart
,
mapValueType
})
steps
=
append
(
steps
,
navigationStep
{
nextPart
,
mapValueType
})
currPartIndex
+=
len
(
strings
.
Split
(
nextPart
,
"."
))
currPartIndex
+=
len
(
strings
.
Split
(
nextPart
,
"."
))
...
@@ -103,7 +103,7 @@ func (s *navigationSteps) moreStepsRemaining() bool {
...
@@ -103,7 +103,7 @@ func (s *navigationSteps) moreStepsRemaining() bool {
// findNameStep takes the list of parts and a set of valid tags that can be used after the name. It then walks the list of parts
// findNameStep takes the list of parts and a set of valid tags that can be used after the name. It then walks the list of parts
// until it find a valid "next" tag or until it reaches the end of the parts and then builds the name back up out of the individual parts
// until it find a valid "next" tag or until it reaches the end of the parts and then builds the name back up out of the individual parts
func
findNameStep
(
parts
[]
string
,
typeOptions
util
.
StringSet
)
string
{
func
findNameStep
(
parts
[]
string
,
typeOptions
sets
.
String
)
string
{
if
len
(
parts
)
==
0
{
if
len
(
parts
)
==
0
{
return
""
return
""
}
}
...
@@ -141,7 +141,7 @@ func getPotentialTypeValues(typeValue reflect.Type) (map[string]reflect.Type, er
...
@@ -141,7 +141,7 @@ func getPotentialTypeValues(typeValue reflect.Type) (map[string]reflect.Type, er
return
ret
,
nil
return
ret
,
nil
}
}
func
findKnownValue
(
parts
[]
string
,
valueOptions
util
.
StringSet
)
int
{
func
findKnownValue
(
parts
[]
string
,
valueOptions
sets
.
String
)
int
{
for
i
:=
range
parts
{
for
i
:=
range
parts
{
if
valueOptions
.
Has
(
parts
[
i
])
{
if
valueOptions
.
Has
(
parts
[
i
])
{
return
i
return
i
...
...
pkg/kubectl/cmd/log.go
View file @
a48f2182
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
libutil
"k8s.io/kubernetes/pkg/util
"
"k8s.io/kubernetes/pkg/util/sets
"
)
)
const
(
const
(
...
@@ -42,7 +42,7 @@ $ kubectl logs -f 123456-7890 ruby-container`
...
@@ -42,7 +42,7 @@ $ kubectl logs -f 123456-7890 ruby-container`
func
selectContainer
(
pod
*
api
.
Pod
,
in
io
.
Reader
,
out
io
.
Writer
)
string
{
func
selectContainer
(
pod
*
api
.
Pod
,
in
io
.
Reader
,
out
io
.
Writer
)
string
{
fmt
.
Fprintf
(
out
,
"Please select a container:
\n
"
)
fmt
.
Fprintf
(
out
,
"Please select a container:
\n
"
)
options
:=
libutil
.
StringSet
{}
options
:=
sets
.
String
{}
for
ix
:=
range
pod
.
Spec
.
Containers
{
for
ix
:=
range
pod
.
Spec
.
Containers
{
fmt
.
Fprintf
(
out
,
"[%d] %s
\n
"
,
ix
+
1
,
pod
.
Spec
.
Containers
[
ix
]
.
Name
)
fmt
.
Fprintf
(
out
,
"[%d] %s
\n
"
,
ix
+
1
,
pod
.
Spec
.
Containers
[
ix
]
.
Name
)
options
.
Insert
(
pod
.
Spec
.
Containers
[
ix
]
.
Name
)
options
.
Insert
(
pod
.
Spec
.
Containers
[
ix
]
.
Name
)
...
...
pkg/kubectl/describe.go
View file @
a48f2182
...
@@ -33,7 +33,7 @@ import (
...
@@ -33,7 +33,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// Describer generates output for the named resource or an error
// Describer generates output for the named resource or an error
...
@@ -933,7 +933,7 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
...
@@ -933,7 +933,7 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
if
sp
.
NodePort
!=
0
{
if
sp
.
NodePort
!=
0
{
fmt
.
Fprintf
(
out
,
"NodePort:
\t
%s
\t
%d/%s
\n
"
,
name
,
sp
.
NodePort
,
sp
.
Protocol
)
fmt
.
Fprintf
(
out
,
"NodePort:
\t
%s
\t
%d/%s
\n
"
,
name
,
sp
.
NodePort
,
sp
.
Protocol
)
}
}
fmt
.
Fprintf
(
out
,
"Endpoints:
\t
%s
\n
"
,
formatEndpoints
(
endpoints
,
util
.
NewStringSet
(
sp
.
Name
)))
fmt
.
Fprintf
(
out
,
"Endpoints:
\t
%s
\n
"
,
formatEndpoints
(
endpoints
,
sets
.
NewString
(
sp
.
Name
)))
}
}
fmt
.
Fprintf
(
out
,
"Session Affinity:
\t
%s
\n
"
,
service
.
Spec
.
SessionAffinity
)
fmt
.
Fprintf
(
out
,
"Session Affinity:
\t
%s
\n
"
,
service
.
Spec
.
SessionAffinity
)
if
events
!=
nil
{
if
events
!=
nil
{
...
...
pkg/kubectl/resource/builder.go
View file @
a48f2182
...
@@ -28,8 +28,8 @@ import (
...
@@ -28,8 +28,8 @@ import (
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
)
)
var
FileExtensions
=
[]
string
{
".json"
,
".stdin"
,
".yaml"
,
".yml"
}
var
FileExtensions
=
[]
string
{
".json"
,
".stdin"
,
".yaml"
,
".yml"
}
...
@@ -685,7 +685,7 @@ func (b *Builder) Do() *Result {
...
@@ -685,7 +685,7 @@ func (b *Builder) Do() *Result {
// strings in the original order.
// strings in the original order.
func
SplitResourceArgument
(
arg
string
)
[]
string
{
func
SplitResourceArgument
(
arg
string
)
[]
string
{
out
:=
[]
string
{}
out
:=
[]
string
{}
set
:=
util
.
NewStringSet
()
set
:=
sets
.
NewString
()
for
_
,
s
:=
range
strings
.
Split
(
arg
,
","
)
{
for
_
,
s
:=
range
strings
.
Split
(
arg
,
","
)
{
if
set
.
Has
(
s
)
{
if
set
.
Has
(
s
)
{
continue
continue
...
...
pkg/kubectl/resource/result.go
View file @
a48f2182
...
@@ -24,8 +24,8 @@ import (
...
@@ -24,8 +24,8 @@ import (
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -123,7 +123,7 @@ func (r *Result) Object() (runtime.Object, error) {
...
@@ -123,7 +123,7 @@ func (r *Result) Object() (runtime.Object, error) {
return
nil
,
err
return
nil
,
err
}
}
versions
:=
util
.
StringSet
{}
versions
:=
sets
.
String
{}
objects
:=
[]
runtime
.
Object
{}
objects
:=
[]
runtime
.
Object
{}
for
_
,
info
:=
range
infos
{
for
_
,
info
:=
range
infos
{
if
info
.
Object
!=
nil
{
if
info
.
Object
!=
nil
{
...
...
pkg/kubectl/resource_printer.go
View file @
a48f2182
...
@@ -41,6 +41,7 @@ import (
...
@@ -41,6 +41,7 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/jsonpath"
"k8s.io/kubernetes/pkg/util/jsonpath"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// GetPrinter takes a format type, an optional format argument. It will return true
// GetPrinter takes a format type, an optional format argument. It will return true
...
@@ -435,7 +436,7 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
...
@@ -435,7 +436,7 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
}
}
// Pass ports=nil for all ports.
// Pass ports=nil for all ports.
func
formatEndpoints
(
endpoints
*
api
.
Endpoints
,
ports
util
.
StringSet
)
string
{
func
formatEndpoints
(
endpoints
*
api
.
Endpoints
,
ports
sets
.
String
)
string
{
if
len
(
endpoints
.
Subsets
)
==
0
{
if
len
(
endpoints
.
Subsets
)
==
0
{
return
"<none>"
return
"<none>"
}
}
...
...
pkg/kubectl/resource_printer_test.go
View file @
a48f2182
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
)
)
...
@@ -484,9 +485,9 @@ func TestPrinters(t *testing.T) {
...
@@ -484,9 +485,9 @@ func TestPrinters(t *testing.T) {
}}},
}}},
}
}
// map of printer name to set of objects it should fail on.
// map of printer name to set of objects it should fail on.
expectedErrors
:=
map
[
string
]
util
.
StringSet
{
expectedErrors
:=
map
[
string
]
sets
.
String
{
"template2"
:
util
.
NewStringSet
(
"pod"
,
"emptyPodList"
,
"endpoints"
),
"template2"
:
sets
.
NewString
(
"pod"
,
"emptyPodList"
,
"endpoints"
),
"jsonpath"
:
util
.
NewStringSet
(
"emptyPodList"
,
"nonEmptyPodList"
,
"endpoints"
),
"jsonpath"
:
sets
.
NewString
(
"emptyPodList"
,
"nonEmptyPodList"
,
"endpoints"
),
}
}
for
pName
,
p
:=
range
printers
{
for
pName
,
p
:=
range
printers
{
...
...
pkg/kubectl/rolling_updater_test.go
View file @
a48f2182
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
oldRc
(
replicas
int
,
original
int
)
*
api
.
ReplicationController
{
func
oldRc
(
replicas
int
,
original
int
)
*
api
.
ReplicationController
{
...
@@ -1140,7 +1141,7 @@ func TestAddDeploymentHash(t *testing.T) {
...
@@ -1140,7 +1141,7 @@ func TestAddDeploymentHash(t *testing.T) {
},
},
}
}
seen
:=
util
.
StringSet
{}
seen
:=
sets
.
String
{}
updatedRc
:=
false
updatedRc
:=
false
fakeClient
:=
&
client
.
FakeRESTClient
{
fakeClient
:=
&
client
.
FakeRESTClient
{
Codec
:
codec
,
Codec
:
codec
,
...
...
pkg/kubelet/config/config.go
View file @
a48f2182
...
@@ -29,10 +29,10 @@ import (
...
@@ -29,10 +29,10 @@ import (
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubeletTypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubeletTypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubeletUtil
"k8s.io/kubernetes/pkg/kubelet/util"
kubeletUtil
"k8s.io/kubernetes/pkg/kubelet/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/config"
"k8s.io/kubernetes/pkg/util/config"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// PodConfigNotificationMode describes how changes are sent to the update channel.
// PodConfigNotificationMode describes how changes are sent to the update channel.
...
@@ -61,7 +61,7 @@ type PodConfig struct {
...
@@ -61,7 +61,7 @@ type PodConfig struct {
// contains the list of all configured sources
// contains the list of all configured sources
sourcesLock
sync
.
Mutex
sourcesLock
sync
.
Mutex
sources
util
.
StringSet
sources
sets
.
String
}
}
// NewPodConfig creates an object that can merge many configuration sources into a stream
// NewPodConfig creates an object that can merge many configuration sources into a stream
...
@@ -73,7 +73,7 @@ func NewPodConfig(mode PodConfigNotificationMode, recorder record.EventRecorder)
...
@@ -73,7 +73,7 @@ func NewPodConfig(mode PodConfigNotificationMode, recorder record.EventRecorder)
pods
:
storage
,
pods
:
storage
,
mux
:
config
.
NewMux
(
storage
),
mux
:
config
.
NewMux
(
storage
),
updates
:
updates
,
updates
:
updates
,
sources
:
util
.
StringSet
{},
sources
:
sets
.
String
{},
}
}
return
podConfig
return
podConfig
}
}
...
@@ -124,7 +124,7 @@ type podStorage struct {
...
@@ -124,7 +124,7 @@ type podStorage struct {
// contains the set of all sources that have sent at least one SET
// contains the set of all sources that have sent at least one SET
sourcesSeenLock
sync
.
Mutex
sourcesSeenLock
sync
.
Mutex
sourcesSeen
util
.
StringSet
sourcesSeen
sets
.
String
// the EventRecorder to use
// the EventRecorder to use
recorder
record
.
EventRecorder
recorder
record
.
EventRecorder
...
@@ -138,7 +138,7 @@ func newPodStorage(updates chan<- kubelet.PodUpdate, mode PodConfigNotificationM
...
@@ -138,7 +138,7 @@ func newPodStorage(updates chan<- kubelet.PodUpdate, mode PodConfigNotificationM
pods
:
make
(
map
[
string
]
map
[
string
]
*
api
.
Pod
),
pods
:
make
(
map
[
string
]
map
[
string
]
*
api
.
Pod
),
mode
:
mode
,
mode
:
mode
,
updates
:
updates
,
updates
:
updates
,
sourcesSeen
:
util
.
StringSet
{},
sourcesSeen
:
sets
.
String
{},
recorder
:
recorder
,
recorder
:
recorder
,
}
}
}
}
...
@@ -306,7 +306,7 @@ func (s *podStorage) seenSources(sources ...string) bool {
...
@@ -306,7 +306,7 @@ func (s *podStorage) seenSources(sources ...string) bool {
}
}
func
filterInvalidPods
(
pods
[]
*
api
.
Pod
,
source
string
,
recorder
record
.
EventRecorder
)
(
filtered
[]
*
api
.
Pod
)
{
func
filterInvalidPods
(
pods
[]
*
api
.
Pod
,
source
string
,
recorder
record
.
EventRecorder
)
(
filtered
[]
*
api
.
Pod
)
{
names
:=
util
.
StringSet
{}
names
:=
sets
.
String
{}
for
i
,
pod
:=
range
pods
{
for
i
,
pod
:=
range
pods
{
var
errlist
[]
error
var
errlist
[]
error
if
errs
:=
validation
.
ValidatePod
(
pod
);
len
(
errs
)
!=
0
{
if
errs
:=
validation
.
ValidatePod
(
pod
);
len
(
errs
)
!=
0
{
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
a48f2182
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
docker
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// FakeDockerClient is a simple fake docker client, so that kubelet can be run for testing without requiring a real docker setup.
// FakeDockerClient is a simple fake docker client, so that kubelet can be run for testing without requiring a real docker setup.
...
@@ -45,7 +45,7 @@ type FakeDockerClient struct {
...
@@ -45,7 +45,7 @@ type FakeDockerClient struct {
pulled
[]
string
pulled
[]
string
Created
[]
string
Created
[]
string
Removed
[]
string
Removed
[]
string
RemovedImages
util
.
StringSet
RemovedImages
sets
.
String
VersionInfo
docker
.
Env
VersionInfo
docker
.
Env
Information
docker
.
Env
Information
docker
.
Env
ExecInspect
*
docker
.
ExecInspect
ExecInspect
*
docker
.
ExecInspect
...
...
pkg/kubelet/dockertools/manager.go
View file @
a48f2182
...
@@ -51,6 +51,7 @@ import (
...
@@ -51,6 +51,7 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/procfs"
"k8s.io/kubernetes/pkg/util/procfs"
"k8s.io/kubernetes/pkg/util/sets"
)
)
const
(
const
(
...
@@ -402,7 +403,7 @@ func (dm *DockerManager) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
...
@@ -402,7 +403,7 @@ func (dm *DockerManager) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
return
nil
,
err
return
nil
,
err
}
}
containerDone
:=
util
.
NewStringSet
()
containerDone
:=
sets
.
NewString
()
// Loop through list of running and exited docker containers to construct
// Loop through list of running and exited docker containers to construct
// the statuses. We assume docker returns a list of containers sorted in
// the statuses. We assume docker returns a list of containers sorted in
// reverse by time.
// reverse by time.
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
a48f2182
...
@@ -42,6 +42,7 @@ import (
...
@@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
uexec
"k8s.io/kubernetes/pkg/util/exec"
uexec
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/sets"
)
)
type
fakeHTTP
struct
{
type
fakeHTTP
struct
{
...
@@ -74,7 +75,7 @@ func (*fakeOptionGenerator) GenerateRunContainerOptions(pod *api.Pod, container
...
@@ -74,7 +75,7 @@ func (*fakeOptionGenerator) GenerateRunContainerOptions(pod *api.Pod, container
}
}
func
newTestDockerManagerWithHTTPClient
(
fakeHTTPClient
*
fakeHTTP
)
(
*
DockerManager
,
*
FakeDockerClient
)
{
func
newTestDockerManagerWithHTTPClient
(
fakeHTTPClient
*
fakeHTTP
)
(
*
DockerManager
,
*
FakeDockerClient
)
{
fakeDocker
:=
&
FakeDockerClient
{
VersionInfo
:
docker
.
Env
{
"Version=1.1.3"
,
"ApiVersion=1.15"
},
Errors
:
make
(
map
[
string
]
error
),
RemovedImages
:
util
.
StringSet
{}}
fakeDocker
:=
&
FakeDockerClient
{
VersionInfo
:
docker
.
Env
{
"Version=1.1.3"
,
"ApiVersion=1.15"
},
Errors
:
make
(
map
[
string
]
error
),
RemovedImages
:
sets
.
String
{}}
fakeRecorder
:=
&
record
.
FakeRecorder
{}
fakeRecorder
:=
&
record
.
FakeRecorder
{}
readinessManager
:=
kubecontainer
.
NewReadinessManager
()
readinessManager
:=
kubecontainer
.
NewReadinessManager
()
containerRefManager
:=
kubecontainer
.
NewRefManager
()
containerRefManager
:=
kubecontainer
.
NewRefManager
()
...
@@ -324,14 +325,14 @@ func TestGetPods(t *testing.T) {
...
@@ -324,14 +325,14 @@ func TestGetPods(t *testing.T) {
func
TestListImages
(
t
*
testing
.
T
)
{
func
TestListImages
(
t
*
testing
.
T
)
{
manager
,
fakeDocker
:=
newTestDockerManager
()
manager
,
fakeDocker
:=
newTestDockerManager
()
dockerImages
:=
[]
docker
.
APIImages
{{
ID
:
"1111"
},
{
ID
:
"2222"
},
{
ID
:
"3333"
}}
dockerImages
:=
[]
docker
.
APIImages
{{
ID
:
"1111"
},
{
ID
:
"2222"
},
{
ID
:
"3333"
}}
expected
:=
util
.
NewStringSet
([]
string
{
"1111"
,
"2222"
,
"3333"
}
...
)
expected
:=
sets
.
NewString
([]
string
{
"1111"
,
"2222"
,
"3333"
}
...
)
fakeDocker
.
Images
=
dockerImages
fakeDocker
.
Images
=
dockerImages
actualImages
,
err
:=
manager
.
ListImages
()
actualImages
,
err
:=
manager
.
ListImages
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error %v"
,
err
)
t
.
Fatalf
(
"unexpected error %v"
,
err
)
}
}
actual
:=
util
.
NewStringSet
()
actual
:=
sets
.
NewString
()
for
_
,
i
:=
range
actualImages
{
for
_
,
i
:=
range
actualImages
{
actual
.
Insert
(
i
.
ID
)
actual
.
Insert
(
i
.
ID
)
}
}
...
...
pkg/kubelet/image_manager.go
View file @
a48f2182
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// Manages lifecycle of all images.
// Manages lifecycle of all images.
...
@@ -141,14 +142,14 @@ func (im *realImageManager) detectImages(detected time.Time) error {
...
@@ -141,14 +142,14 @@ func (im *realImageManager) detectImages(detected time.Time) error {
}
}
// Make a set of images in use by containers.
// Make a set of images in use by containers.
imagesInUse
:=
util
.
NewStringSet
()
imagesInUse
:=
sets
.
NewString
()
for
_
,
container
:=
range
containers
{
for
_
,
container
:=
range
containers
{
imagesInUse
.
Insert
(
container
.
Image
)
imagesInUse
.
Insert
(
container
.
Image
)
}
}
// Add new images and record those being used.
// Add new images and record those being used.
now
:=
time
.
Now
()
now
:=
time
.
Now
()
currentImages
:=
util
.
NewStringSet
()
currentImages
:=
sets
.
NewString
()
im
.
imageRecordsLock
.
Lock
()
im
.
imageRecordsLock
.
Lock
()
defer
im
.
imageRecordsLock
.
Unlock
()
defer
im
.
imageRecordsLock
.
Unlock
()
for
_
,
image
:=
range
images
{
for
_
,
image
:=
range
images
{
...
@@ -286,7 +287,7 @@ func (ev byLastUsedAndDetected) Less(i, j int) bool {
...
@@ -286,7 +287,7 @@ func (ev byLastUsedAndDetected) Less(i, j int) bool {
}
}
}
}
func
isImageUsed
(
image
*
docker
.
APIImages
,
imagesInUse
util
.
StringSet
)
bool
{
func
isImageUsed
(
image
*
docker
.
APIImages
,
imagesInUse
sets
.
String
)
bool
{
// Check the image ID and all the RepoTags.
// Check the image ID and all the RepoTags.
if
_
,
ok
:=
imagesInUse
[
image
.
ID
];
ok
{
if
_
,
ok
:=
imagesInUse
[
image
.
ID
];
ok
{
return
true
return
true
...
...
pkg/kubelet/image_manager_test.go
View file @
a48f2182
...
@@ -28,14 +28,14 @@ import (
...
@@ -28,14 +28,14 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/record"
"k8s.io/kubernetes/pkg/client/unversioned/record"
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
var
zero
time
.
Time
var
zero
time
.
Time
func
newRealImageManager
(
policy
ImageGCPolicy
)
(
*
realImageManager
,
*
dockertools
.
FakeDockerClient
,
*
cadvisor
.
Mock
)
{
func
newRealImageManager
(
policy
ImageGCPolicy
)
(
*
realImageManager
,
*
dockertools
.
FakeDockerClient
,
*
cadvisor
.
Mock
)
{
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{
RemovedImages
:
util
.
NewStringSet
(),
RemovedImages
:
sets
.
NewString
(),
}
}
mockCadvisor
:=
new
(
cadvisor
.
Mock
)
mockCadvisor
:=
new
(
cadvisor
.
Mock
)
return
&
realImageManager
{
return
&
realImageManager
{
...
...
pkg/kubelet/kubelet.go
View file @
a48f2182
...
@@ -64,6 +64,7 @@ import (
...
@@ -64,6 +64,7 @@ import (
nodeutil
"k8s.io/kubernetes/pkg/util/node"
nodeutil
"k8s.io/kubernetes/pkg/util/node"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/procfs"
"k8s.io/kubernetes/pkg/util/procfs"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -983,7 +984,7 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Cont
...
@@ -983,7 +984,7 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Cont
return
opts
,
nil
return
opts
,
nil
}
}
var
masterServices
=
util
.
NewStringSet
(
"kubernetes"
)
var
masterServices
=
sets
.
NewString
(
"kubernetes"
)
// getServiceEnvVarMap makes a map[string]string of env vars for services a pod in namespace ns should see
// getServiceEnvVarMap makes a map[string]string of env vars for services a pod in namespace ns should see
func
(
kl
*
Kubelet
)
getServiceEnvVarMap
(
ns
string
)
(
map
[
string
]
string
,
error
)
{
func
(
kl
*
Kubelet
)
getServiceEnvVarMap
(
ns
string
)
(
map
[
string
]
string
,
error
)
{
...
@@ -1408,7 +1409,7 @@ func getDesiredVolumes(pods []*api.Pod) map[string]api.Volume {
...
@@ -1408,7 +1409,7 @@ func getDesiredVolumes(pods []*api.Pod) map[string]api.Volume {
// cleanupOrphanedPodDirs removes a pod directory if the pod is not in the
// cleanupOrphanedPodDirs removes a pod directory if the pod is not in the
// desired set of pods and there is no running containers in the pod.
// desired set of pods and there is no running containers in the pod.
func
(
kl
*
Kubelet
)
cleanupOrphanedPodDirs
(
pods
[]
*
api
.
Pod
,
runningPods
[]
*
kubecontainer
.
Pod
)
error
{
func
(
kl
*
Kubelet
)
cleanupOrphanedPodDirs
(
pods
[]
*
api
.
Pod
,
runningPods
[]
*
kubecontainer
.
Pod
)
error
{
active
:=
util
.
NewStringSet
()
active
:=
sets
.
NewString
()
for
_
,
pod
:=
range
pods
{
for
_
,
pod
:=
range
pods
{
active
.
Insert
(
string
(
pod
.
UID
))
active
.
Insert
(
string
(
pod
.
UID
))
}
}
...
@@ -1446,7 +1447,7 @@ func (kl *Kubelet) cleanupBandwidthLimits(allPods []*api.Pod) error {
...
@@ -1446,7 +1447,7 @@ func (kl *Kubelet) cleanupBandwidthLimits(allPods []*api.Pod) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
possibleCIDRs
:=
util
.
StringSet
{}
possibleCIDRs
:=
sets
.
String
{}
for
ix
:=
range
allPods
{
for
ix
:=
range
allPods
{
pod
:=
allPods
[
ix
]
pod
:=
allPods
[
ix
]
ingress
,
egress
,
err
:=
extractBandwidthResources
(
pod
)
ingress
,
egress
,
err
:=
extractBandwidthResources
(
pod
)
...
@@ -1486,7 +1487,7 @@ func (kl *Kubelet) cleanupOrphanedVolumes(pods []*api.Pod, runningPods []*kubeco
...
@@ -1486,7 +1487,7 @@ func (kl *Kubelet) cleanupOrphanedVolumes(pods []*api.Pod, runningPods []*kubeco
desiredVolumes
:=
getDesiredVolumes
(
pods
)
desiredVolumes
:=
getDesiredVolumes
(
pods
)
currentVolumes
:=
kl
.
getPodVolumesFromDisk
()
currentVolumes
:=
kl
.
getPodVolumesFromDisk
()
runningSet
:=
util
.
StringSet
{}
runningSet
:=
sets
.
String
{}
for
_
,
pod
:=
range
runningPods
{
for
_
,
pod
:=
range
runningPods
{
runningSet
.
Insert
(
string
(
pod
.
ID
))
runningSet
.
Insert
(
string
(
pod
.
ID
))
}
}
...
@@ -1724,7 +1725,7 @@ func (kl *Kubelet) HandlePodCleanups() error {
...
@@ -1724,7 +1725,7 @@ func (kl *Kubelet) HandlePodCleanups() error {
// podKiller launches a goroutine to kill a pod received from the channel if
// podKiller launches a goroutine to kill a pod received from the channel if
// another goroutine isn't already in action.
// another goroutine isn't already in action.
func
(
kl
*
Kubelet
)
podKiller
()
{
func
(
kl
*
Kubelet
)
podKiller
()
{
killing
:=
util
.
NewStringSet
()
killing
:=
sets
.
NewString
()
resultCh
:=
make
(
chan
types
.
UID
)
resultCh
:=
make
(
chan
types
.
UID
)
defer
close
(
resultCh
)
defer
close
(
resultCh
)
for
{
for
{
...
@@ -1771,7 +1772,7 @@ func (s podsByCreationTime) Less(i, j int) bool {
...
@@ -1771,7 +1772,7 @@ func (s podsByCreationTime) Less(i, j int) bool {
// checkHostPortConflicts detects pods with conflicted host ports.
// checkHostPortConflicts detects pods with conflicted host ports.
func
hasHostPortConflicts
(
pods
[]
*
api
.
Pod
)
bool
{
func
hasHostPortConflicts
(
pods
[]
*
api
.
Pod
)
bool
{
ports
:=
util
.
StringSet
{}
ports
:=
sets
.
String
{}
for
_
,
pod
:=
range
pods
{
for
_
,
pod
:=
range
pods
{
if
errs
:=
validation
.
AccumulateUniqueHostPorts
(
pod
.
Spec
.
Containers
,
&
ports
);
len
(
errs
)
>
0
{
if
errs
:=
validation
.
AccumulateUniqueHostPorts
(
pod
.
Spec
.
Containers
,
&
ports
);
len
(
errs
)
>
0
{
glog
.
Errorf
(
"Pod %q: HostPort is already allocated, ignoring: %v"
,
kubecontainer
.
GetPodFullName
(
pod
),
errs
)
glog
.
Errorf
(
"Pod %q: HostPort is already allocated, ignoring: %v"
,
kubecontainer
.
GetPodFullName
(
pod
),
errs
)
...
...
pkg/kubelet/mirror_client_test.go
View file @
a48f2182
...
@@ -22,14 +22,14 @@ import (
...
@@ -22,14 +22,14 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
fakeMirrorClient
struct
{
type
fakeMirrorClient
struct
{
mirrorPodLock
sync
.
RWMutex
mirrorPodLock
sync
.
RWMutex
// Note that a real mirror manager does not store the mirror pods in
// Note that a real mirror manager does not store the mirror pods in
// itself. This fake manager does this to track calls.
// itself. This fake manager does this to track calls.
mirrorPods
util
.
StringSet
mirrorPods
sets
.
String
createCounts
map
[
string
]
int
createCounts
map
[
string
]
int
deleteCounts
map
[
string
]
int
deleteCounts
map
[
string
]
int
}
}
...
@@ -53,7 +53,7 @@ func (fmc *fakeMirrorClient) DeleteMirrorPod(podFullName string) error {
...
@@ -53,7 +53,7 @@ func (fmc *fakeMirrorClient) DeleteMirrorPod(podFullName string) error {
func
newFakeMirrorClient
()
*
fakeMirrorClient
{
func
newFakeMirrorClient
()
*
fakeMirrorClient
{
m
:=
fakeMirrorClient
{}
m
:=
fakeMirrorClient
{}
m
.
mirrorPods
=
util
.
NewStringSet
()
m
.
mirrorPods
=
sets
.
NewString
()
m
.
createCounts
=
make
(
map
[
string
]
int
)
m
.
createCounts
=
make
(
map
[
string
]
int
)
m
.
deleteCounts
=
make
(
map
[
string
]
int
)
m
.
deleteCounts
=
make
(
map
[
string
]
int
)
return
&
m
return
&
m
...
...
pkg/labels/selector.go
View file @
a48f2182
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// Selector represents a label selector.
// Selector represents a label selector.
...
@@ -79,7 +80,7 @@ func (a ByKey) Less(i, j int) bool { return a[i].key < a[j].key }
...
@@ -79,7 +80,7 @@ func (a ByKey) Less(i, j int) bool { return a[i].key < a[j].key }
type
Requirement
struct
{
type
Requirement
struct
{
key
string
key
string
operator
Operator
operator
Operator
strValues
util
.
StringSet
strValues
sets
.
String
}
}
// NewRequirement is the constructor for a Requirement.
// NewRequirement is the constructor for a Requirement.
...
@@ -91,7 +92,7 @@ type Requirement struct {
...
@@ -91,7 +92,7 @@ type Requirement struct {
// of characters. See validateLabelKey for more details.
// of characters. See validateLabelKey for more details.
//
//
// The empty string is a valid value in the input values set.
// The empty string is a valid value in the input values set.
func
NewRequirement
(
key
string
,
op
Operator
,
vals
util
.
StringSet
)
(
*
Requirement
,
error
)
{
func
NewRequirement
(
key
string
,
op
Operator
,
vals
sets
.
String
)
(
*
Requirement
,
error
)
{
if
err
:=
validateLabelKey
(
key
);
err
!=
nil
{
if
err
:=
validateLabelKey
(
key
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -198,7 +199,7 @@ func (lsel LabelSelector) Add(key string, operator Operator, values []string) Se
...
@@ -198,7 +199,7 @@ func (lsel LabelSelector) Add(key string, operator Operator, values []string) Se
for
_
,
item
:=
range
lsel
{
for
_
,
item
:=
range
lsel
{
reqs
=
append
(
reqs
,
item
)
reqs
=
append
(
reqs
,
item
)
}
}
if
r
,
err
:=
NewRequirement
(
key
,
operator
,
util
.
NewStringSet
(
values
...
));
err
==
nil
{
if
r
,
err
:=
NewRequirement
(
key
,
operator
,
sets
.
NewString
(
values
...
));
err
==
nil
{
reqs
=
append
(
reqs
,
*
r
)
reqs
=
append
(
reqs
,
*
r
)
}
}
return
LabelSelector
(
reqs
)
return
LabelSelector
(
reqs
)
...
@@ -480,7 +481,7 @@ func (p *Parser) parseRequirement() (*Requirement, error) {
...
@@ -480,7 +481,7 @@ func (p *Parser) parseRequirement() (*Requirement, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
values
util
.
StringSet
var
values
sets
.
String
switch
operator
{
switch
operator
{
case
InOperator
,
NotInOperator
:
case
InOperator
,
NotInOperator
:
values
,
err
=
p
.
parseValues
()
values
,
err
=
p
.
parseValues
()
...
@@ -535,7 +536,7 @@ func (p *Parser) parseOperator() (op Operator, err error) {
...
@@ -535,7 +536,7 @@ func (p *Parser) parseOperator() (op Operator, err error) {
}
}
// parseValues parses the values for set based matching (x,y,z)
// parseValues parses the values for set based matching (x,y,z)
func
(
p
*
Parser
)
parseValues
()
(
util
.
StringSet
,
error
)
{
func
(
p
*
Parser
)
parseValues
()
(
sets
.
String
,
error
)
{
tok
,
lit
:=
p
.
consume
(
Values
)
tok
,
lit
:=
p
.
consume
(
Values
)
if
tok
!=
OpenParToken
{
if
tok
!=
OpenParToken
{
return
nil
,
fmt
.
Errorf
(
"found '%s' expected: '('"
,
lit
)
return
nil
,
fmt
.
Errorf
(
"found '%s' expected: '('"
,
lit
)
...
@@ -553,7 +554,7 @@ func (p *Parser) parseValues() (util.StringSet, error) {
...
@@ -553,7 +554,7 @@ func (p *Parser) parseValues() (util.StringSet, error) {
return
s
,
nil
return
s
,
nil
case
ClosedParToken
:
// handles "()"
case
ClosedParToken
:
// handles "()"
p
.
consume
(
Values
)
p
.
consume
(
Values
)
return
util
.
NewStringSet
(
""
),
nil
return
sets
.
NewString
(
""
),
nil
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"found '%s', expected: ',', ')' or identifier"
,
lit
)
return
nil
,
fmt
.
Errorf
(
"found '%s', expected: ',', ')' or identifier"
,
lit
)
}
}
...
@@ -561,8 +562,8 @@ func (p *Parser) parseValues() (util.StringSet, error) {
...
@@ -561,8 +562,8 @@ func (p *Parser) parseValues() (util.StringSet, error) {
// parseIdentifiersList parses a (possibly empty) list of
// parseIdentifiersList parses a (possibly empty) list of
// of comma separated (possibly empty) identifiers
// of comma separated (possibly empty) identifiers
func
(
p
*
Parser
)
parseIdentifiersList
()
(
util
.
StringSet
,
error
)
{
func
(
p
*
Parser
)
parseIdentifiersList
()
(
sets
.
String
,
error
)
{
s
:=
util
.
NewStringSet
()
s
:=
sets
.
NewString
()
for
{
for
{
tok
,
lit
:=
p
.
consume
(
Values
)
tok
,
lit
:=
p
.
consume
(
Values
)
switch
tok
{
switch
tok
{
...
@@ -597,8 +598,8 @@ func (p *Parser) parseIdentifiersList() (util.StringSet, error) {
...
@@ -597,8 +598,8 @@ func (p *Parser) parseIdentifiersList() (util.StringSet, error) {
}
}
// parseExactValue parses the only value for exact match style
// parseExactValue parses the only value for exact match style
func
(
p
*
Parser
)
parseExactValue
()
(
util
.
StringSet
,
error
)
{
func
(
p
*
Parser
)
parseExactValue
()
(
sets
.
String
,
error
)
{
s
:=
util
.
NewStringSet
()
s
:=
sets
.
NewString
()
tok
,
lit
:=
p
.
consume
(
Values
)
tok
,
lit
:=
p
.
consume
(
Values
)
if
tok
==
IdentifierToken
{
if
tok
==
IdentifierToken
{
s
.
Insert
(
lit
)
s
.
Insert
(
lit
)
...
@@ -670,7 +671,7 @@ func SelectorFromSet(ls Set) Selector {
...
@@ -670,7 +671,7 @@ func SelectorFromSet(ls Set) Selector {
}
}
var
requirements
[]
Requirement
var
requirements
[]
Requirement
for
label
,
value
:=
range
ls
{
for
label
,
value
:=
range
ls
{
if
r
,
err
:=
NewRequirement
(
label
,
EqualsOperator
,
util
.
NewStringSet
(
value
));
err
!=
nil
{
if
r
,
err
:=
NewRequirement
(
label
,
EqualsOperator
,
sets
.
NewString
(
value
));
err
!=
nil
{
//TODO: double check errors when input comes from serialization?
//TODO: double check errors when input comes from serialization?
return
LabelSelector
{}
return
LabelSelector
{}
}
else
{
}
else
{
...
...
pkg/labels/selector_test.go
View file @
a48f2182
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"strings"
"strings"
"testing"
"testing"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
TestSelectorParse
(
t
*
testing
.
T
)
{
func
TestSelectorParse
(
t
*
testing
.
T
)
{
...
@@ -273,16 +273,16 @@ func TestRequirementConstructor(t *testing.T) {
...
@@ -273,16 +273,16 @@ func TestRequirementConstructor(t *testing.T) {
requirementConstructorTests
:=
[]
struct
{
requirementConstructorTests
:=
[]
struct
{
Key
string
Key
string
Op
Operator
Op
Operator
Vals
util
.
StringSet
Vals
sets
.
String
Success
bool
Success
bool
}{
}{
{
"x"
,
InOperator
,
nil
,
false
},
{
"x"
,
InOperator
,
nil
,
false
},
{
"x"
,
NotInOperator
,
util
.
NewStringSet
(),
false
},
{
"x"
,
NotInOperator
,
sets
.
NewString
(),
false
},
{
"x"
,
InOperator
,
util
.
NewStringSet
(
"foo"
),
true
},
{
"x"
,
InOperator
,
sets
.
NewString
(
"foo"
),
true
},
{
"x"
,
NotInOperator
,
util
.
NewStringSet
(
"foo"
),
true
},
{
"x"
,
NotInOperator
,
sets
.
NewString
(
"foo"
),
true
},
{
"x"
,
ExistsOperator
,
nil
,
true
},
{
"x"
,
ExistsOperator
,
nil
,
true
},
{
"1foo"
,
InOperator
,
util
.
NewStringSet
(
"bar"
),
true
},
{
"1foo"
,
InOperator
,
sets
.
NewString
(
"bar"
),
true
},
{
"1234"
,
InOperator
,
util
.
NewStringSet
(
"bar"
),
true
},
{
"1234"
,
InOperator
,
sets
.
NewString
(
"bar"
),
true
},
{
strings
.
Repeat
(
"a"
,
254
),
ExistsOperator
,
nil
,
false
},
//breaks DNS rule that len(key) <= 253
{
strings
.
Repeat
(
"a"
,
254
),
ExistsOperator
,
nil
,
false
},
//breaks DNS rule that len(key) <= 253
}
}
for
_
,
rc
:=
range
requirementConstructorTests
{
for
_
,
rc
:=
range
requirementConstructorTests
{
...
@@ -302,23 +302,23 @@ func TestToString(t *testing.T) {
...
@@ -302,23 +302,23 @@ func TestToString(t *testing.T) {
Valid
bool
Valid
bool
}{
}{
{
&
LabelSelector
{
{
&
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"abc"
,
"def"
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"abc"
,
"def"
),
t
),
getRequirement
(
"y"
,
NotInOperator
,
util
.
NewStringSet
(
"jkl"
),
t
),
getRequirement
(
"y"
,
NotInOperator
,
sets
.
NewString
(
"jkl"
),
t
),
getRequirement
(
"z"
,
ExistsOperator
,
nil
,
t
)},
getRequirement
(
"z"
,
ExistsOperator
,
nil
,
t
)},
"x in (abc,def),y notin (jkl),z"
,
true
},
"x in (abc,def),y notin (jkl),z"
,
true
},
{
&
LabelSelector
{
{
&
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"abc"
,
"def"
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"abc"
,
"def"
),
t
),
req
},
// adding empty req for the trailing ','
req
},
// adding empty req for the trailing ','
"x in (abc,def),"
,
false
},
"x in (abc,def),"
,
false
},
{
&
LabelSelector
{
{
&
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
"abc"
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
"abc"
),
t
),
getRequirement
(
"y"
,
InOperator
,
util
.
NewStringSet
(
"jkl"
,
"mno"
),
t
),
getRequirement
(
"y"
,
InOperator
,
sets
.
NewString
(
"jkl"
,
"mno"
),
t
),
getRequirement
(
"z"
,
NotInOperator
,
util
.
NewStringSet
(
""
),
t
)},
getRequirement
(
"z"
,
NotInOperator
,
sets
.
NewString
(
""
),
t
)},
"x notin (abc),y in (jkl,mno),z notin ()"
,
true
},
"x notin (abc),y in (jkl,mno),z notin ()"
,
true
},
{
&
LabelSelector
{
{
&
LabelSelector
{
getRequirement
(
"x"
,
EqualsOperator
,
util
.
NewStringSet
(
"abc"
),
t
),
getRequirement
(
"x"
,
EqualsOperator
,
sets
.
NewString
(
"abc"
),
t
),
getRequirement
(
"y"
,
DoubleEqualsOperator
,
util
.
NewStringSet
(
"jkl"
),
t
),
getRequirement
(
"y"
,
DoubleEqualsOperator
,
sets
.
NewString
(
"jkl"
),
t
),
getRequirement
(
"z"
,
NotEqualsOperator
,
util
.
NewStringSet
(
"a"
),
t
)},
getRequirement
(
"z"
,
NotEqualsOperator
,
sets
.
NewString
(
"a"
),
t
)},
"x=abc,y==jkl,z!=a"
,
true
},
"x=abc,y==jkl,z!=a"
,
true
},
}
}
for
_
,
ts
:=
range
toStringTests
{
for
_
,
ts
:=
range
toStringTests
{
...
@@ -341,19 +341,19 @@ func TestRequirementLabelSelectorMatching(t *testing.T) {
...
@@ -341,19 +341,19 @@ func TestRequirementLabelSelectorMatching(t *testing.T) {
req
,
req
,
},
false
},
},
false
},
{
Set
{
"x"
:
"foo"
,
"y"
:
"baz"
},
&
LabelSelector
{
{
Set
{
"x"
:
"foo"
,
"y"
:
"baz"
},
&
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"foo"
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"foo"
),
t
),
getRequirement
(
"y"
,
NotInOperator
,
util
.
NewStringSet
(
"alpha"
),
t
),
getRequirement
(
"y"
,
NotInOperator
,
sets
.
NewString
(
"alpha"
),
t
),
},
true
},
},
true
},
{
Set
{
"x"
:
"foo"
,
"y"
:
"baz"
},
&
LabelSelector
{
{
Set
{
"x"
:
"foo"
,
"y"
:
"baz"
},
&
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"foo"
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"foo"
),
t
),
getRequirement
(
"y"
,
InOperator
,
util
.
NewStringSet
(
"alpha"
),
t
),
getRequirement
(
"y"
,
InOperator
,
sets
.
NewString
(
"alpha"
),
t
),
},
false
},
},
false
},
{
Set
{
"y"
:
""
},
&
LabelSelector
{
{
Set
{
"y"
:
""
},
&
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
""
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
""
),
t
),
getRequirement
(
"y"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"y"
,
ExistsOperator
,
nil
,
t
),
},
true
},
},
true
},
{
Set
{
"y"
:
"baz"
},
&
LabelSelector
{
{
Set
{
"y"
:
"baz"
},
&
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
""
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
""
),
t
),
},
false
},
},
false
},
}
}
for
_
,
lsm
:=
range
labelSelectorMatchingTests
{
for
_
,
lsm
:=
range
labelSelectorMatchingTests
{
...
@@ -378,60 +378,60 @@ func TestSetSelectorParser(t *testing.T) {
...
@@ -378,60 +378,60 @@ func TestSetSelectorParser(t *testing.T) {
getRequirement
(
"this-is-a-dns.domain.com/key-with-dash"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"this-is-a-dns.domain.com/key-with-dash"
,
ExistsOperator
,
nil
,
t
),
},
true
,
true
},
},
true
,
true
},
{
"this-is-another-dns.domain.com/key-with-dash in (so,what)"
,
LabelSelector
{
{
"this-is-another-dns.domain.com/key-with-dash in (so,what)"
,
LabelSelector
{
getRequirement
(
"this-is-another-dns.domain.com/key-with-dash"
,
InOperator
,
util
.
NewStringSet
(
"so"
,
"what"
),
t
),
getRequirement
(
"this-is-another-dns.domain.com/key-with-dash"
,
InOperator
,
sets
.
NewString
(
"so"
,
"what"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"0.1.2.domain/99 notin (10.10.100.1, tick.tack.clock)"
,
LabelSelector
{
{
"0.1.2.domain/99 notin (10.10.100.1, tick.tack.clock)"
,
LabelSelector
{
getRequirement
(
"0.1.2.domain/99"
,
NotInOperator
,
util
.
NewStringSet
(
"10.10.100.1"
,
"tick.tack.clock"
),
t
),
getRequirement
(
"0.1.2.domain/99"
,
NotInOperator
,
sets
.
NewString
(
"10.10.100.1"
,
"tick.tack.clock"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"foo in (abc)"
,
LabelSelector
{
{
"foo in (abc)"
,
LabelSelector
{
getRequirement
(
"foo"
,
InOperator
,
util
.
NewStringSet
(
"abc"
),
t
),
getRequirement
(
"foo"
,
InOperator
,
sets
.
NewString
(
"abc"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x notin
\n
(abc)"
,
LabelSelector
{
{
"x notin
\n
(abc)"
,
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
"abc"
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
"abc"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x notin
\t
(abc,def)"
,
LabelSelector
{
{
"x notin
\t
(abc,def)"
,
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
"abc"
,
"def"
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
"abc"
,
"def"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x in (abc,def)"
,
LabelSelector
{
{
"x in (abc,def)"
,
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"abc"
,
"def"
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"abc"
,
"def"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x in (abc,)"
,
LabelSelector
{
{
"x in (abc,)"
,
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
"abc"
,
""
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
"abc"
,
""
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x in ()"
,
LabelSelector
{
{
"x in ()"
,
LabelSelector
{
getRequirement
(
"x"
,
InOperator
,
util
.
NewStringSet
(
""
),
t
),
getRequirement
(
"x"
,
InOperator
,
sets
.
NewString
(
""
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x notin (abc,,def),bar,z in (),w"
,
LabelSelector
{
{
"x notin (abc,,def),bar,z in (),w"
,
LabelSelector
{
getRequirement
(
"bar"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"bar"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"w"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"w"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
"abc"
,
""
,
"def"
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
"abc"
,
""
,
"def"
),
t
),
getRequirement
(
"z"
,
InOperator
,
util
.
NewStringSet
(
""
),
t
),
getRequirement
(
"z"
,
InOperator
,
sets
.
NewString
(
""
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x,y in (a)"
,
LabelSelector
{
{
"x,y in (a)"
,
LabelSelector
{
getRequirement
(
"y"
,
InOperator
,
util
.
NewStringSet
(
"a"
),
t
),
getRequirement
(
"y"
,
InOperator
,
sets
.
NewString
(
"a"
),
t
),
getRequirement
(
"x"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"x"
,
ExistsOperator
,
nil
,
t
),
},
false
,
true
},
},
false
,
true
},
{
"x=a"
,
LabelSelector
{
{
"x=a"
,
LabelSelector
{
getRequirement
(
"x"
,
EqualsOperator
,
util
.
NewStringSet
(
"a"
),
t
),
getRequirement
(
"x"
,
EqualsOperator
,
sets
.
NewString
(
"a"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x=a,y!=b"
,
LabelSelector
{
{
"x=a,y!=b"
,
LabelSelector
{
getRequirement
(
"x"
,
EqualsOperator
,
util
.
NewStringSet
(
"a"
),
t
),
getRequirement
(
"x"
,
EqualsOperator
,
sets
.
NewString
(
"a"
),
t
),
getRequirement
(
"y"
,
NotEqualsOperator
,
util
.
NewStringSet
(
"b"
),
t
),
getRequirement
(
"y"
,
NotEqualsOperator
,
sets
.
NewString
(
"b"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x=a,y!=b,z in (h,i,j)"
,
LabelSelector
{
{
"x=a,y!=b,z in (h,i,j)"
,
LabelSelector
{
getRequirement
(
"x"
,
EqualsOperator
,
util
.
NewStringSet
(
"a"
),
t
),
getRequirement
(
"x"
,
EqualsOperator
,
sets
.
NewString
(
"a"
),
t
),
getRequirement
(
"y"
,
NotEqualsOperator
,
util
.
NewStringSet
(
"b"
),
t
),
getRequirement
(
"y"
,
NotEqualsOperator
,
sets
.
NewString
(
"b"
),
t
),
getRequirement
(
"z"
,
InOperator
,
util
.
NewStringSet
(
"h"
,
"i"
,
"j"
),
t
),
getRequirement
(
"z"
,
InOperator
,
sets
.
NewString
(
"h"
,
"i"
,
"j"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x=a||y=b"
,
LabelSelector
{},
false
,
false
},
{
"x=a||y=b"
,
LabelSelector
{},
false
,
false
},
{
"x,,y"
,
nil
,
true
,
false
},
{
"x,,y"
,
nil
,
true
,
false
},
{
",x,y"
,
nil
,
true
,
false
},
{
",x,y"
,
nil
,
true
,
false
},
{
"x nott in (y)"
,
nil
,
true
,
false
},
{
"x nott in (y)"
,
nil
,
true
,
false
},
{
"x notin ( )"
,
LabelSelector
{
{
"x notin ( )"
,
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
""
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
""
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"x notin (, a)"
,
LabelSelector
{
{
"x notin (, a)"
,
LabelSelector
{
getRequirement
(
"x"
,
NotInOperator
,
util
.
NewStringSet
(
""
,
"a"
),
t
),
getRequirement
(
"x"
,
NotInOperator
,
sets
.
NewString
(
""
,
"a"
),
t
),
},
true
,
true
},
},
true
,
true
},
{
"a in (xyz),"
,
nil
,
true
,
false
},
{
"a in (xyz),"
,
nil
,
true
,
false
},
{
"a in (xyz)b notin ()"
,
nil
,
true
,
false
},
{
"a in (xyz)b notin ()"
,
nil
,
true
,
false
},
...
@@ -439,7 +439,7 @@ func TestSetSelectorParser(t *testing.T) {
...
@@ -439,7 +439,7 @@ func TestSetSelectorParser(t *testing.T) {
getRequirement
(
"a"
,
ExistsOperator
,
nil
,
t
),
getRequirement
(
"a"
,
ExistsOperator
,
nil
,
t
),
},
true
,
true
},
},
true
,
true
},
{
"a in (x,y,notin, z,in)"
,
LabelSelector
{
{
"a in (x,y,notin, z,in)"
,
LabelSelector
{
getRequirement
(
"a"
,
InOperator
,
util
.
NewStringSet
(
"in"
,
"notin"
,
"x"
,
"y"
,
"z"
),
t
),
getRequirement
(
"a"
,
InOperator
,
sets
.
NewString
(
"in"
,
"notin"
,
"x"
,
"y"
,
"z"
),
t
),
},
true
,
true
},
// operator 'in' inside list of identifiers
},
true
,
true
},
// operator 'in' inside list of identifiers
{
"a in (xyz abc)"
,
nil
,
false
,
false
},
// no comma
{
"a in (xyz abc)"
,
nil
,
false
,
false
},
// no comma
{
"a notin("
,
nil
,
true
,
false
},
// bad formed
{
"a notin("
,
nil
,
true
,
false
},
// bad formed
...
@@ -458,7 +458,7 @@ func TestSetSelectorParser(t *testing.T) {
...
@@ -458,7 +458,7 @@ func TestSetSelectorParser(t *testing.T) {
}
}
}
}
func
getRequirement
(
key
string
,
op
Operator
,
vals
util
.
StringSet
,
t
*
testing
.
T
)
Requirement
{
func
getRequirement
(
key
string
,
op
Operator
,
vals
sets
.
String
,
t
*
testing
.
T
)
Requirement
{
req
,
err
:=
NewRequirement
(
key
,
op
,
vals
)
req
,
err
:=
NewRequirement
(
key
,
op
,
vals
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"NewRequirement(%v, %v, %v) resulted in error:%v"
,
key
,
op
,
vals
,
err
)
t
.
Errorf
(
"NewRequirement(%v, %v, %v) resulted in error:%v"
,
key
,
op
,
vals
,
err
)
...
@@ -480,16 +480,16 @@ func TestAdd(t *testing.T) {
...
@@ -480,16 +480,16 @@ func TestAdd(t *testing.T) {
"key"
,
"key"
,
InOperator
,
InOperator
,
[]
string
{
"value"
},
[]
string
{
"value"
},
LabelSelector
{
Requirement
{
"key"
,
InOperator
,
util
.
NewStringSet
(
"value"
)}},
LabelSelector
{
Requirement
{
"key"
,
InOperator
,
sets
.
NewString
(
"value"
)}},
},
},
{
{
LabelSelector
{
Requirement
{
"key"
,
InOperator
,
util
.
NewStringSet
(
"value"
)}},
LabelSelector
{
Requirement
{
"key"
,
InOperator
,
sets
.
NewString
(
"value"
)}},
"key2"
,
"key2"
,
EqualsOperator
,
EqualsOperator
,
[]
string
{
"value2"
},
[]
string
{
"value2"
},
LabelSelector
{
LabelSelector
{
Requirement
{
"key"
,
InOperator
,
util
.
NewStringSet
(
"value"
)},
Requirement
{
"key"
,
InOperator
,
sets
.
NewString
(
"value"
)},
Requirement
{
"key2"
,
EqualsOperator
,
util
.
NewStringSet
(
"value2"
)},
Requirement
{
"key2"
,
EqualsOperator
,
sets
.
NewString
(
"value2"
)},
},
},
},
},
}
}
...
...
pkg/master/master.go
View file @
a48f2182
...
@@ -79,6 +79,7 @@ import (
...
@@ -79,6 +79,7 @@ import (
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/ui"
"k8s.io/kubernetes/pkg/ui"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
daemonetcd
"k8s.io/kubernetes/pkg/registry/daemonset/etcd"
daemonetcd
"k8s.io/kubernetes/pkg/registry/daemonset/etcd"
horizontalpodautoscaleretcd
"k8s.io/kubernetes/pkg/registry/horizontalpodautoscaler/etcd"
horizontalpodautoscaleretcd
"k8s.io/kubernetes/pkg/registry/horizontalpodautoscaler/etcd"
...
@@ -566,7 +567,7 @@ func (m *Master) init(c *Config) {
...
@@ -566,7 +567,7 @@ func (m *Master) init(c *Config) {
apiserver
.
InstallSupport
(
m
.
muxHelper
,
m
.
rootWebService
,
c
.
EnableProfiling
,
healthzChecks
...
)
apiserver
.
InstallSupport
(
m
.
muxHelper
,
m
.
rootWebService
,
c
.
EnableProfiling
,
healthzChecks
...
)
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
c
.
APIPrefix
,
apiVersions
)
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
c
.
APIPrefix
,
apiVersions
)
defaultVersion
:=
m
.
defaultAPIGroupVersion
()
defaultVersion
:=
m
.
defaultAPIGroupVersion
()
requestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
util
.
NewStringSet
(
strings
.
TrimPrefix
(
defaultVersion
.
Root
,
"/"
)),
RestMapper
:
defaultVersion
.
Mapper
}
requestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
sets
.
NewString
(
strings
.
TrimPrefix
(
defaultVersion
.
Root
,
"/"
)),
RestMapper
:
defaultVersion
.
Mapper
}
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
requestInfoResolver
,
apiVersions
)
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
requestInfoResolver
,
apiVersions
)
if
m
.
exp
{
if
m
.
exp
{
...
@@ -575,7 +576,7 @@ func (m *Master) init(c *Config) {
...
@@ -575,7 +576,7 @@ func (m *Master) init(c *Config) {
glog
.
Fatalf
(
"Unable to setup experimental api: %v"
,
err
)
glog
.
Fatalf
(
"Unable to setup experimental api: %v"
,
err
)
}
}
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
c
.
ExpAPIPrefix
,
[]
string
{
expVersion
.
Version
})
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
c
.
ExpAPIPrefix
,
[]
string
{
expVersion
.
Version
})
expRequestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
util
.
NewStringSet
(
strings
.
TrimPrefix
(
expVersion
.
Root
,
"/"
)),
RestMapper
:
expVersion
.
Mapper
}
expRequestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
sets
.
NewString
(
strings
.
TrimPrefix
(
expVersion
.
Root
,
"/"
)),
RestMapper
:
expVersion
.
Mapper
}
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
expRequestInfoResolver
,
[]
string
{
expVersion
.
Version
})
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
expRequestInfoResolver
,
[]
string
{
expVersion
.
Version
})
}
}
...
@@ -784,7 +785,7 @@ func (m *Master) InstallThirdPartyAPI(rsrc *expapi.ThirdPartyResource) error {
...
@@ -784,7 +785,7 @@ func (m *Master) InstallThirdPartyAPI(rsrc *expapi.ThirdPartyResource) error {
}
}
thirdPartyPrefix
:=
"/thirdparty/"
+
group
+
"/"
thirdPartyPrefix
:=
"/thirdparty/"
+
group
+
"/"
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
thirdPartyPrefix
,
[]
string
{
rsrc
.
Versions
[
0
]
.
Name
})
apiserver
.
AddApiWebService
(
m
.
handlerContainer
,
thirdPartyPrefix
,
[]
string
{
rsrc
.
Versions
[
0
]
.
Name
})
thirdPartyRequestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
util
.
NewStringSet
(
strings
.
TrimPrefix
(
group
,
"/"
)),
RestMapper
:
thirdparty
.
Mapper
}
thirdPartyRequestInfoResolver
:=
&
apiserver
.
APIRequestInfoResolver
{
APIPrefixes
:
sets
.
NewString
(
strings
.
TrimPrefix
(
group
,
"/"
)),
RestMapper
:
thirdparty
.
Mapper
}
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
thirdPartyRequestInfoResolver
,
[]
string
{
thirdparty
.
Version
})
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
thirdPartyRequestInfoResolver
,
[]
string
{
thirdparty
.
Version
})
return
nil
return
nil
}
}
...
...
pkg/registry/generic/etcd/etcd_test.go
View file @
a48f2182
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/coreos/go-etcd/etcd"
"github.com/coreos/go-etcd/etcd"
)
)
...
@@ -93,7 +94,7 @@ func NewTestGenericEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, *Etcd) {
...
@@ -93,7 +94,7 @@ func NewTestGenericEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, *Etcd) {
// setMatcher is a matcher that matches any pod with id in the set.
// setMatcher is a matcher that matches any pod with id in the set.
// Makes testing simpler.
// Makes testing simpler.
type
setMatcher
struct
{
type
setMatcher
struct
{
util
.
StringSet
sets
.
String
}
}
func
(
sm
setMatcher
)
Matches
(
obj
runtime
.
Object
)
(
bool
,
error
)
{
func
(
sm
setMatcher
)
Matches
(
obj
runtime
.
Object
)
(
bool
,
error
)
{
...
@@ -189,7 +190,7 @@ func TestEtcdList(t *testing.T) {
...
@@ -189,7 +190,7 @@ func TestEtcdList(t *testing.T) {
R
:
singleElemListResp
,
R
:
singleElemListResp
,
E
:
nil
,
E
:
nil
,
},
},
m
:
setMatcher
{
util
.
NewStringSet
(
"foo"
)},
m
:
setMatcher
{
sets
.
NewString
(
"foo"
)},
out
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
podA
}},
out
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
podA
}},
succeed
:
true
,
succeed
:
true
,
},
},
...
@@ -198,7 +199,7 @@ func TestEtcdList(t *testing.T) {
...
@@ -198,7 +199,7 @@ func TestEtcdList(t *testing.T) {
R
:
normalListResp
,
R
:
normalListResp
,
E
:
nil
,
E
:
nil
,
},
},
m
:
setMatcher
{
util
.
NewStringSet
(
"foo"
,
"makeMatchSingleReturnFalse"
)},
m
:
setMatcher
{
sets
.
NewString
(
"foo"
,
"makeMatchSingleReturnFalse"
)},
out
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
podA
}},
out
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
podA
}},
succeed
:
true
,
succeed
:
true
,
},
},
...
@@ -560,8 +561,8 @@ func TestEtcdDelete(t *testing.T) {
...
@@ -560,8 +561,8 @@ func TestEtcdDelete(t *testing.T) {
func
TestEtcdWatch
(
t
*
testing
.
T
)
{
func
TestEtcdWatch
(
t
*
testing
.
T
)
{
table
:=
map
[
string
]
generic
.
Matcher
{
table
:=
map
[
string
]
generic
.
Matcher
{
"single"
:
setMatcher
{
util
.
NewStringSet
(
"foo"
)},
"single"
:
setMatcher
{
sets
.
NewString
(
"foo"
)},
"multi"
:
setMatcher
{
util
.
NewStringSet
(
"foo"
,
"bar"
)},
"multi"
:
setMatcher
{
sets
.
NewString
(
"foo"
,
"bar"
)},
}
}
for
name
,
m
:=
range
table
{
for
name
,
m
:=
range
table
{
...
...
pkg/registry/service/ipallocator/allocator_test.go
View file @
a48f2182
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"testing"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
func
TestAllocate
(
t
*
testing
.
T
)
{
func
TestAllocate
(
t
*
testing
.
T
)
{
...
@@ -34,7 +34,7 @@ func TestAllocate(t *testing.T) {
...
@@ -34,7 +34,7 @@ func TestAllocate(t *testing.T) {
if
f
:=
r
.
Free
();
f
!=
254
{
if
f
:=
r
.
Free
();
f
!=
254
{
t
.
Errorf
(
"unexpected free %d"
,
f
)
t
.
Errorf
(
"unexpected free %d"
,
f
)
}
}
found
:=
util
.
NewStringSet
()
found
:=
sets
.
NewString
()
count
:=
0
count
:=
0
for
r
.
Free
()
>
0
{
for
r
.
Free
()
>
0
{
ip
,
err
:=
r
.
AllocateNext
()
ip
,
err
:=
r
.
AllocateNext
()
...
@@ -118,7 +118,7 @@ func TestAllocateSmall(t *testing.T) {
...
@@ -118,7 +118,7 @@ func TestAllocateSmall(t *testing.T) {
if
f
:=
r
.
Free
();
f
!=
2
{
if
f
:=
r
.
Free
();
f
!=
2
{
t
.
Errorf
(
"free: %d"
,
f
)
t
.
Errorf
(
"free: %d"
,
f
)
}
}
found
:=
util
.
NewStringSet
()
found
:=
sets
.
NewString
()
for
i
:=
0
;
i
<
2
;
i
++
{
for
i
:=
0
;
i
<
2
;
i
++
{
ip
,
err
:=
r
.
AllocateNext
()
ip
,
err
:=
r
.
AllocateNext
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/registry/service/portallocator/allocator_test.go
View file @
a48f2182
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
TestAllocate
(
t
*
testing
.
T
)
{
func
TestAllocate
(
t
*
testing
.
T
)
{
...
@@ -34,7 +35,7 @@ func TestAllocate(t *testing.T) {
...
@@ -34,7 +35,7 @@ func TestAllocate(t *testing.T) {
if
f
:=
r
.
Free
();
f
!=
201
{
if
f
:=
r
.
Free
();
f
!=
201
{
t
.
Errorf
(
"unexpected free %d"
,
f
)
t
.
Errorf
(
"unexpected free %d"
,
f
)
}
}
found
:=
util
.
NewStringSet
()
found
:=
sets
.
NewString
()
count
:=
0
count
:=
0
for
r
.
Free
()
>
0
{
for
r
.
Free
()
>
0
{
p
,
err
:=
r
.
AllocateNext
()
p
,
err
:=
r
.
AllocateNext
()
...
...
pkg/runtime/conversion_generator.go
View file @
a48f2182
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"strings"
"strings"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
type
ConversionGenerator
interface
{
type
ConversionGenerator
interface
{
...
@@ -33,7 +33,7 @@ type ConversionGenerator interface {
...
@@ -33,7 +33,7 @@ type ConversionGenerator interface {
WriteConversionFunctions
(
w
io
.
Writer
)
error
WriteConversionFunctions
(
w
io
.
Writer
)
error
RegisterConversionFunctions
(
w
io
.
Writer
,
pkg
string
)
error
RegisterConversionFunctions
(
w
io
.
Writer
,
pkg
string
)
error
AddImport
(
pkg
string
)
string
AddImport
(
pkg
string
)
string
RepackImports
(
exclude
util
.
StringSet
)
RepackImports
(
exclude
sets
.
String
)
WriteImports
(
w
io
.
Writer
)
error
WriteImports
(
w
io
.
Writer
)
error
OverwritePackage
(
pkg
,
overwrite
string
)
OverwritePackage
(
pkg
,
overwrite
string
)
AssumePrivateConversions
()
AssumePrivateConversions
()
...
@@ -279,7 +279,7 @@ func (g *conversionGenerator) targetPackage(pkg string) {
...
@@ -279,7 +279,7 @@ func (g *conversionGenerator) targetPackage(pkg string) {
g
.
shortImports
[
""
]
=
pkg
g
.
shortImports
[
""
]
=
pkg
}
}
func
(
g
*
conversionGenerator
)
RepackImports
(
exclude
util
.
StringSet
)
{
func
(
g
*
conversionGenerator
)
RepackImports
(
exclude
sets
.
String
)
{
var
packages
[]
string
var
packages
[]
string
for
key
:=
range
g
.
imports
{
for
key
:=
range
g
.
imports
{
packages
=
append
(
packages
,
key
)
packages
=
append
(
packages
,
key
)
...
...
pkg/runtime/deep_copy_generator.go
View file @
a48f2182
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"strings"
"strings"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// TODO(wojtek-t): As suggested in #8320, we should consider the strategy
// TODO(wojtek-t): As suggested in #8320, we should consider the strategy
...
@@ -69,7 +69,7 @@ type DeepCopyGenerator interface {
...
@@ -69,7 +69,7 @@ type DeepCopyGenerator interface {
OverwritePackage
(
pkg
,
overwrite
string
)
OverwritePackage
(
pkg
,
overwrite
string
)
}
}
func
NewDeepCopyGenerator
(
scheme
*
conversion
.
Scheme
,
targetPkg
string
,
include
util
.
StringSet
)
DeepCopyGenerator
{
func
NewDeepCopyGenerator
(
scheme
*
conversion
.
Scheme
,
targetPkg
string
,
include
sets
.
String
)
DeepCopyGenerator
{
g
:=
&
deepCopyGenerator
{
g
:=
&
deepCopyGenerator
{
scheme
:
scheme
,
scheme
:
scheme
,
targetPkg
:
targetPkg
,
targetPkg
:
targetPkg
,
...
@@ -100,7 +100,7 @@ type deepCopyGenerator struct {
...
@@ -100,7 +100,7 @@ type deepCopyGenerator struct {
shortImports
map
[
string
]
string
shortImports
map
[
string
]
string
pkgOverwrites
map
[
string
]
string
pkgOverwrites
map
[
string
]
string
replace
map
[
pkgPathNamePair
]
reflect
.
Type
replace
map
[
pkgPathNamePair
]
reflect
.
Type
include
util
.
StringSet
include
sets
.
String
}
}
func
(
g
*
deepCopyGenerator
)
addImportByPath
(
pkg
string
)
string
{
func
(
g
*
deepCopyGenerator
)
addImportByPath
(
pkg
string
)
string
{
...
...
pkg/storage/cacher_test.go
View file @
a48f2182
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -160,7 +161,7 @@ func TestListFromMemory(t *testing.T) {
...
@@ -160,7 +161,7 @@ func TestListFromMemory(t *testing.T) {
if
len
(
result
.
Items
)
!=
2
{
if
len
(
result
.
Items
)
!=
2
{
t
.
Errorf
(
"unexpected list result: %d"
,
len
(
result
.
Items
))
t
.
Errorf
(
"unexpected list result: %d"
,
len
(
result
.
Items
))
}
}
keys
:=
util
.
StringSet
{}
keys
:=
sets
.
String
{}
for
_
,
item
:=
range
result
.
Items
{
for
_
,
item
:=
range
result
.
Items
{
keys
.
Insert
(
item
.
ObjectMeta
.
Name
)
keys
.
Insert
(
item
.
ObjectMeta
.
Name
)
}
}
...
...
pkg/storage/watch_cache_test.go
View file @
a48f2182
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/client/unversioned/cache"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -76,7 +77,7 @@ func TestWatchCacheBasic(t *testing.T) {
...
@@ -76,7 +77,7 @@ func TestWatchCacheBasic(t *testing.T) {
store
.
Add
(
makeTestPod
(
"pod2"
,
5
))
store
.
Add
(
makeTestPod
(
"pod2"
,
5
))
store
.
Add
(
makeTestPod
(
"pod3"
,
6
))
store
.
Add
(
makeTestPod
(
"pod3"
,
6
))
{
{
podNames
:=
util
.
StringSet
{}
podNames
:=
sets
.
String
{}
for
_
,
item
:=
range
store
.
List
()
{
for
_
,
item
:=
range
store
.
List
()
{
podNames
.
Insert
(
item
.
(
*
api
.
Pod
)
.
ObjectMeta
.
Name
)
podNames
.
Insert
(
item
.
(
*
api
.
Pod
)
.
ObjectMeta
.
Name
)
}
}
...
@@ -94,7 +95,7 @@ func TestWatchCacheBasic(t *testing.T) {
...
@@ -94,7 +95,7 @@ func TestWatchCacheBasic(t *testing.T) {
makeTestPod
(
"pod5"
,
8
),
makeTestPod
(
"pod5"
,
8
),
},
"8"
)
},
"8"
)
{
{
podNames
:=
util
.
StringSet
{}
podNames
:=
sets
.
String
{}
for
_
,
item
:=
range
store
.
List
()
{
for
_
,
item
:=
range
store
.
List
()
{
podNames
.
Insert
(
item
.
(
*
api
.
Pod
)
.
ObjectMeta
.
Name
)
podNames
.
Insert
(
item
.
(
*
api
.
Pod
)
.
ObjectMeta
.
Name
)
}
}
...
...
pkg/util/bandwidth/linux.go
View file @
a48f2182
...
@@ -25,8 +25,8 @@ import (
...
@@ -25,8 +25,8 @@ import (
"strings"
"strings"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -65,7 +65,7 @@ func (t *tcShaper) nextClassID() (int, error) {
...
@@ -65,7 +65,7 @@ func (t *tcShaper) nextClassID() (int, error) {
}
}
scanner
:=
bufio
.
NewScanner
(
bytes
.
NewBuffer
(
data
))
scanner
:=
bufio
.
NewScanner
(
bytes
.
NewBuffer
(
data
))
classes
:=
util
.
StringSet
{}
classes
:=
sets
.
String
{}
for
scanner
.
Scan
()
{
for
scanner
.
Scan
()
{
line
:=
strings
.
TrimSpace
(
scanner
.
Text
())
line
:=
strings
.
TrimSpace
(
scanner
.
Text
())
// skip empty lines
// skip empty lines
...
...
pkg/util/iptables/iptables.go
View file @
a48f2182
...
@@ -26,8 +26,8 @@ import (
...
@@ -26,8 +26,8 @@ import (
"github.com/coreos/go-semver/semver"
"github.com/coreos/go-semver/semver"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util"
utilexec
"k8s.io/kubernetes/pkg/util/exec"
utilexec
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/sets"
)
)
type
RulePosition
string
type
RulePosition
string
...
@@ -352,7 +352,7 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
...
@@ -352,7 +352,7 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
tmpField
:=
strings
.
Trim
(
args
[
i
],
"
\"
"
)
tmpField
:=
strings
.
Trim
(
args
[
i
],
"
\"
"
)
argsCopy
=
append
(
argsCopy
,
strings
.
Fields
(
tmpField
)
...
)
argsCopy
=
append
(
argsCopy
,
strings
.
Fields
(
tmpField
)
...
)
}
}
argset
:=
util
.
NewStringSet
(
argsCopy
...
)
argset
:=
sets
.
NewString
(
argsCopy
...
)
for
_
,
line
:=
range
strings
.
Split
(
string
(
out
),
"
\n
"
)
{
for
_
,
line
:=
range
strings
.
Split
(
string
(
out
),
"
\n
"
)
{
var
fields
=
strings
.
Fields
(
line
)
var
fields
=
strings
.
Fields
(
line
)
...
@@ -370,7 +370,7 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
...
@@ -370,7 +370,7 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
}
}
// TODO: This misses reorderings e.g. "-x foo ! -y bar" will match "! -x foo -y bar"
// TODO: This misses reorderings e.g. "-x foo ! -y bar" will match "! -x foo -y bar"
if
util
.
NewStringSet
(
fields
...
)
.
IsSuperset
(
argset
)
{
if
sets
.
NewString
(
fields
...
)
.
IsSuperset
(
argset
)
{
return
true
,
nil
return
true
,
nil
}
}
glog
.
V
(
5
)
.
Infof
(
"DBG: fields is not a superset of args: fields=%v args=%v"
,
fields
,
args
)
glog
.
V
(
5
)
.
Infof
(
"DBG: fields is not a superset of args: fields=%v args=%v"
,
fields
,
args
)
...
...
pkg/util/iptables/iptables_test.go
View file @
a48f2182
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"strings"
"strings"
"testing"
"testing"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/sets"
)
)
func
getIptablesCommand
(
protocol
Protocol
)
string
{
func
getIptablesCommand
(
protocol
Protocol
)
string
{
...
@@ -68,7 +68,7 @@ func testEnsureChain(t *testing.T, protocol Protocol) {
...
@@ -68,7 +68,7 @@ func testEnsureChain(t *testing.T, protocol Protocol) {
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
cmd
:=
getIptablesCommand
(
protocol
)
cmd
:=
getIptablesCommand
(
protocol
)
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
cmd
,
"-t"
,
"nat"
,
"-N"
,
"FOOBAR"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
cmd
,
"-t"
,
"nat"
,
"-N"
,
"FOOBAR"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
// Exists.
// Exists.
...
@@ -121,7 +121,7 @@ func TestFlushChain(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestFlushChain(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-F"
,
"FOOBAR"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-F"
,
"FOOBAR"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
// Failure.
// Failure.
...
@@ -158,7 +158,7 @@ func TestDeleteChain(t *testing.T) {
...
@@ -158,7 +158,7 @@ func TestDeleteChain(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-X"
,
"FOOBAR"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-X"
,
"FOOBAR"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
// Failure.
// Failure.
...
@@ -196,7 +196,7 @@ func TestEnsureRuleAlreadyExists(t *testing.T) {
...
@@ -196,7 +196,7 @@ func TestEnsureRuleAlreadyExists(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-C"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-C"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
}
}
...
@@ -232,7 +232,7 @@ func TestEnsureRuleNew(t *testing.T) {
...
@@ -232,7 +232,7 @@ func TestEnsureRuleNew(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
3
{
if
fcmd
.
CombinedOutputCalls
!=
3
{
t
.
Errorf
(
"expected 3 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 3 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
2
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-A"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
2
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-A"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
2
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
2
])
}
}
}
}
...
@@ -319,7 +319,7 @@ func TestDeleteRuleAlreadyExists(t *testing.T) {
...
@@ -319,7 +319,7 @@ func TestDeleteRuleAlreadyExists(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-C"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-C"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
}
}
...
@@ -352,7 +352,7 @@ func TestDeleteRuleNew(t *testing.T) {
...
@@ -352,7 +352,7 @@ func TestDeleteRuleNew(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
3
{
if
fcmd
.
CombinedOutputCalls
!=
3
{
t
.
Errorf
(
"expected 3 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 3 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
2
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-D"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
2
]
...
)
.
HasAll
(
"iptables"
,
"-t"
,
"nat"
,
"-D"
,
"OUTPUT"
,
"abc"
,
"123"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
2
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
2
])
}
}
}
}
...
@@ -484,7 +484,7 @@ COMMIT
...
@@ -484,7 +484,7 @@ COMMIT
if
fcmd
.
CombinedOutputCalls
!=
1
{
if
fcmd
.
CombinedOutputCalls
!=
1
{
t
.
Errorf
(
"expected 1 CombinedOutput() call, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 1 CombinedOutput() call, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"iptables-save"
,
"-t"
,
"nat"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"iptables-save"
,
"-t"
,
"nat"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
}
}
}
}
...
@@ -522,7 +522,7 @@ COMMIT
...
@@ -522,7 +522,7 @@ COMMIT
if
fcmd
.
CombinedOutputCalls
!=
1
{
if
fcmd
.
CombinedOutputCalls
!=
1
{
t
.
Errorf
(
"expected 1 CombinedOutput() call, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 1 CombinedOutput() call, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"iptables-save"
,
"-t"
,
"nat"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"iptables-save"
,
"-t"
,
"nat"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
}
}
}
}
...
@@ -573,7 +573,7 @@ func TestWaitFlagUnavailable(t *testing.T) {
...
@@ -573,7 +573,7 @@ func TestWaitFlagUnavailable(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w"
,
"-w2"
)
{
if
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w"
,
"-w2"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
}
}
...
@@ -601,10 +601,10 @@ func TestWaitFlagOld(t *testing.T) {
...
@@ -601,10 +601,10 @@ func TestWaitFlagOld(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-w"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-w"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
if
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w2"
)
{
if
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w2"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
}
}
...
@@ -632,10 +632,10 @@ func TestWaitFlagNew(t *testing.T) {
...
@@ -632,10 +632,10 @@ func TestWaitFlagNew(t *testing.T) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-w2"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
"iptables"
,
"-w2"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
if
util
.
NewStringSet
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w"
)
{
if
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAny
(
"-w"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
}
}
}
pkg/util/proxy/transport.go
View file @
a48f2182
...
@@ -31,38 +31,38 @@ import (
...
@@ -31,38 +31,38 @@ import (
"golang.org/x/net/html"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
"golang.org/x/net/html/atom"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
// atomsToAttrs states which attributes of which tags require URL substitution.
// atomsToAttrs states which attributes of which tags require URL substitution.
// Sources: http://www.w3.org/TR/REC-html40/index/attributes.html
// Sources: http://www.w3.org/TR/REC-html40/index/attributes.html
// http://www.w3.org/html/wg/drafts/html/master/index.html#attributes-1
// http://www.w3.org/html/wg/drafts/html/master/index.html#attributes-1
var
atomsToAttrs
=
map
[
atom
.
Atom
]
util
.
StringSet
{
var
atomsToAttrs
=
map
[
atom
.
Atom
]
sets
.
String
{
atom
.
A
:
util
.
NewStringSet
(
"href"
),
atom
.
A
:
sets
.
NewString
(
"href"
),
atom
.
Applet
:
util
.
NewStringSet
(
"codebase"
),
atom
.
Applet
:
sets
.
NewString
(
"codebase"
),
atom
.
Area
:
util
.
NewStringSet
(
"href"
),
atom
.
Area
:
sets
.
NewString
(
"href"
),
atom
.
Audio
:
util
.
NewStringSet
(
"src"
),
atom
.
Audio
:
sets
.
NewString
(
"src"
),
atom
.
Base
:
util
.
NewStringSet
(
"href"
),
atom
.
Base
:
sets
.
NewString
(
"href"
),
atom
.
Blockquote
:
util
.
NewStringSet
(
"cite"
),
atom
.
Blockquote
:
sets
.
NewString
(
"cite"
),
atom
.
Body
:
util
.
NewStringSet
(
"background"
),
atom
.
Body
:
sets
.
NewString
(
"background"
),
atom
.
Button
:
util
.
NewStringSet
(
"formaction"
),
atom
.
Button
:
sets
.
NewString
(
"formaction"
),
atom
.
Command
:
util
.
NewStringSet
(
"icon"
),
atom
.
Command
:
sets
.
NewString
(
"icon"
),
atom
.
Del
:
util
.
NewStringSet
(
"cite"
),
atom
.
Del
:
sets
.
NewString
(
"cite"
),
atom
.
Embed
:
util
.
NewStringSet
(
"src"
),
atom
.
Embed
:
sets
.
NewString
(
"src"
),
atom
.
Form
:
util
.
NewStringSet
(
"action"
),
atom
.
Form
:
sets
.
NewString
(
"action"
),
atom
.
Frame
:
util
.
NewStringSet
(
"longdesc"
,
"src"
),
atom
.
Frame
:
sets
.
NewString
(
"longdesc"
,
"src"
),
atom
.
Head
:
util
.
NewStringSet
(
"profile"
),
atom
.
Head
:
sets
.
NewString
(
"profile"
),
atom
.
Html
:
util
.
NewStringSet
(
"manifest"
),
atom
.
Html
:
sets
.
NewString
(
"manifest"
),
atom
.
Iframe
:
util
.
NewStringSet
(
"longdesc"
,
"src"
),
atom
.
Iframe
:
sets
.
NewString
(
"longdesc"
,
"src"
),
atom
.
Img
:
util
.
NewStringSet
(
"longdesc"
,
"src"
,
"usemap"
),
atom
.
Img
:
sets
.
NewString
(
"longdesc"
,
"src"
,
"usemap"
),
atom
.
Input
:
util
.
NewStringSet
(
"src"
,
"usemap"
,
"formaction"
),
atom
.
Input
:
sets
.
NewString
(
"src"
,
"usemap"
,
"formaction"
),
atom
.
Ins
:
util
.
NewStringSet
(
"cite"
),
atom
.
Ins
:
sets
.
NewString
(
"cite"
),
atom
.
Link
:
util
.
NewStringSet
(
"href"
),
atom
.
Link
:
sets
.
NewString
(
"href"
),
atom
.
Object
:
util
.
NewStringSet
(
"classid"
,
"codebase"
,
"data"
,
"usemap"
),
atom
.
Object
:
sets
.
NewString
(
"classid"
,
"codebase"
,
"data"
,
"usemap"
),
atom
.
Q
:
util
.
NewStringSet
(
"cite"
),
atom
.
Q
:
sets
.
NewString
(
"cite"
),
atom
.
Script
:
util
.
NewStringSet
(
"src"
),
atom
.
Script
:
sets
.
NewString
(
"src"
),
atom
.
Source
:
util
.
NewStringSet
(
"src"
),
atom
.
Source
:
sets
.
NewString
(
"src"
),
atom
.
Video
:
util
.
NewStringSet
(
"poster"
,
"src"
),
atom
.
Video
:
sets
.
NewString
(
"poster"
,
"src"
),
// TODO: css URLs hidden in style elements.
// TODO: css URLs hidden in style elements.
}
}
...
...
pkg/util/set.go
→
pkg/util/set
s/set
.go
View file @
a48f2182
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
util
package
sets
import
(
import
(
"reflect"
"reflect"
...
@@ -26,19 +26,19 @@ import (
...
@@ -26,19 +26,19 @@ import (
type
Empty
struct
{}
type
Empty
struct
{}
// StringSet is a set of strings, implemented via map[string]struct{} for minimal memory consumption.
// StringSet is a set of strings, implemented via map[string]struct{} for minimal memory consumption.
type
String
Set
map
[
string
]
Empty
type
String
map
[
string
]
Empty
// New
StringSet
creates a StringSet from a list of values.
// New creates a StringSet from a list of values.
func
NewString
Set
(
items
...
string
)
StringSet
{
func
NewString
(
items
...
string
)
String
{
ss
:=
String
Set
{}
ss
:=
String
{}
ss
.
Insert
(
items
...
)
ss
.
Insert
(
items
...
)
return
ss
return
ss
}
}
// KeySet creates a StringSet from a keys of a map[string](? extends interface{}). Since you can't describe that map type in the Go type system
// KeySet creates a StringSet from a keys of a map[string](? extends interface{}). Since you can't describe that map type in the Go type system
// the reflected value is required.
// the reflected value is required.
func
KeySet
(
theMap
reflect
.
Value
)
String
Set
{
func
KeySet
(
theMap
reflect
.
Value
)
String
{
ret
:=
String
Set
{}
ret
:=
String
{}
for
_
,
keyValue
:=
range
theMap
.
MapKeys
()
{
for
_
,
keyValue
:=
range
theMap
.
MapKeys
()
{
ret
.
Insert
(
keyValue
.
String
())
ret
.
Insert
(
keyValue
.
String
())
...
@@ -48,27 +48,27 @@ func KeySet(theMap reflect.Value) StringSet {
...
@@ -48,27 +48,27 @@ func KeySet(theMap reflect.Value) StringSet {
}
}
// Insert adds items to the set.
// Insert adds items to the set.
func
(
s
String
Set
)
Insert
(
items
...
string
)
{
func
(
s
String
)
Insert
(
items
...
string
)
{
for
_
,
item
:=
range
items
{
for
_
,
item
:=
range
items
{
s
[
item
]
=
Empty
{}
s
[
item
]
=
Empty
{}
}
}
}
}
// Delete removes all items from the set.
// Delete removes all items from the set.
func
(
s
String
Set
)
Delete
(
items
...
string
)
{
func
(
s
String
)
Delete
(
items
...
string
)
{
for
_
,
item
:=
range
items
{
for
_
,
item
:=
range
items
{
delete
(
s
,
item
)
delete
(
s
,
item
)
}
}
}
}
// Has returns true iff item is contained in the set.
// Has returns true iff item is contained in the set.
func
(
s
String
Set
)
Has
(
item
string
)
bool
{
func
(
s
String
)
Has
(
item
string
)
bool
{
_
,
contained
:=
s
[
item
]
_
,
contained
:=
s
[
item
]
return
contained
return
contained
}
}
// HasAll returns true iff all items are contained in the set.
// HasAll returns true iff all items are contained in the set.
func
(
s
String
Set
)
HasAll
(
items
...
string
)
bool
{
func
(
s
String
)
HasAll
(
items
...
string
)
bool
{
for
_
,
item
:=
range
items
{
for
_
,
item
:=
range
items
{
if
!
s
.
Has
(
item
)
{
if
!
s
.
Has
(
item
)
{
return
false
return
false
...
@@ -78,7 +78,7 @@ func (s StringSet) HasAll(items ...string) bool {
...
@@ -78,7 +78,7 @@ func (s StringSet) HasAll(items ...string) bool {
}
}
// HasAny returns true if any items are contained in the set.
// HasAny returns true if any items are contained in the set.
func
(
s
String
Set
)
HasAny
(
items
...
string
)
bool
{
func
(
s
String
)
HasAny
(
items
...
string
)
bool
{
for
_
,
item
:=
range
items
{
for
_
,
item
:=
range
items
{
if
s
.
Has
(
item
)
{
if
s
.
Has
(
item
)
{
return
true
return
true
...
@@ -93,8 +93,8 @@ func (s StringSet) HasAny(items ...string) bool {
...
@@ -93,8 +93,8 @@ func (s StringSet) HasAny(items ...string) bool {
// s2 = {1, 2, 4, 5}
// s2 = {1, 2, 4, 5}
// s1.Difference(s2) = {3}
// s1.Difference(s2) = {3}
// s2.Difference(s1) = {4, 5}
// s2.Difference(s1) = {4, 5}
func
(
s
String
Set
)
Difference
(
s2
StringSet
)
StringSet
{
func
(
s
String
)
Difference
(
s2
String
)
String
{
result
:=
NewString
Set
()
result
:=
NewString
()
for
key
:=
range
s
{
for
key
:=
range
s
{
if
!
s2
.
Has
(
key
)
{
if
!
s2
.
Has
(
key
)
{
result
.
Insert
(
key
)
result
.
Insert
(
key
)
...
@@ -110,8 +110,8 @@ func (s StringSet) Difference(s2 StringSet) StringSet {
...
@@ -110,8 +110,8 @@ func (s StringSet) Difference(s2 StringSet) StringSet {
// s2 = {3, 4}
// s2 = {3, 4}
// s1.Union(s2) = {1, 2, 3, 4}
// s1.Union(s2) = {1, 2, 3, 4}
// s2.Union(s1) = {1, 2, 3, 4}
// s2.Union(s1) = {1, 2, 3, 4}
func
(
s1
String
Set
)
Union
(
s2
StringSet
)
StringSet
{
func
(
s1
String
)
Union
(
s2
String
)
String
{
result
:=
NewString
Set
()
result
:=
NewString
()
for
key
:=
range
s1
{
for
key
:=
range
s1
{
result
.
Insert
(
key
)
result
.
Insert
(
key
)
}
}
...
@@ -122,7 +122,7 @@ func (s1 StringSet) Union(s2 StringSet) StringSet {
...
@@ -122,7 +122,7 @@ func (s1 StringSet) Union(s2 StringSet) StringSet {
}
}
// IsSuperset returns true iff s1 is a superset of s2.
// IsSuperset returns true iff s1 is a superset of s2.
func
(
s1
String
Set
)
IsSuperset
(
s2
StringSet
)
bool
{
func
(
s1
String
)
IsSuperset
(
s2
String
)
bool
{
for
item
:=
range
s2
{
for
item
:=
range
s2
{
if
!
s1
.
Has
(
item
)
{
if
!
s1
.
Has
(
item
)
{
return
false
return
false
...
@@ -134,7 +134,7 @@ func (s1 StringSet) IsSuperset(s2 StringSet) bool {
...
@@ -134,7 +134,7 @@ func (s1 StringSet) IsSuperset(s2 StringSet) bool {
// Equal returns true iff s1 is equal (as a set) to s2.
// Equal returns true iff s1 is equal (as a set) to s2.
// Two sets are equal if their membership is identical.
// Two sets are equal if their membership is identical.
// (In practice, this means same elements, order doesn't matter)
// (In practice, this means same elements, order doesn't matter)
func
(
s1
String
Set
)
Equal
(
s2
StringSet
)
bool
{
func
(
s1
String
)
Equal
(
s2
String
)
bool
{
if
len
(
s1
)
!=
len
(
s2
)
{
if
len
(
s1
)
!=
len
(
s2
)
{
return
false
return
false
}
}
...
@@ -147,7 +147,7 @@ func (s1 StringSet) Equal(s2 StringSet) bool {
...
@@ -147,7 +147,7 @@ func (s1 StringSet) Equal(s2 StringSet) bool {
}
}
// List returns the contents as a sorted string slice.
// List returns the contents as a sorted string slice.
func
(
s
String
Set
)
List
()
[]
string
{
func
(
s
String
)
List
()
[]
string
{
res
:=
make
([]
string
,
0
,
len
(
s
))
res
:=
make
([]
string
,
0
,
len
(
s
))
for
key
:=
range
s
{
for
key
:=
range
s
{
res
=
append
(
res
,
key
)
res
=
append
(
res
,
key
)
...
@@ -157,7 +157,7 @@ func (s StringSet) List() []string {
...
@@ -157,7 +157,7 @@ func (s StringSet) List() []string {
}
}
// Returns a single element from the set.
// Returns a single element from the set.
func
(
s
String
Set
)
PopAny
()
(
string
,
bool
)
{
func
(
s
String
)
PopAny
()
(
string
,
bool
)
{
for
key
:=
range
s
{
for
key
:=
range
s
{
s
.
Delete
(
key
)
s
.
Delete
(
key
)
return
key
,
true
return
key
,
true
...
@@ -166,6 +166,6 @@ func (s StringSet) PopAny() (string, bool) {
...
@@ -166,6 +166,6 @@ func (s StringSet) PopAny() (string, bool) {
}
}
// Len returns the size of the set.
// Len returns the size of the set.
func
(
s
String
Set
)
Len
()
int
{
func
(
s
String
)
Len
()
int
{
return
len
(
s
)
return
len
(
s
)
}
}
pkg/util/set_test.go
→
pkg/util/set
s/set
_test.go
View file @
a48f2182
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
util
package
sets
import
(
import
(
"reflect"
"reflect"
...
@@ -22,8 +22,8 @@ import (
...
@@ -22,8 +22,8 @@ import (
)
)
func
TestStringSet
(
t
*
testing
.
T
)
{
func
TestStringSet
(
t
*
testing
.
T
)
{
s
:=
String
Set
{}
s
:=
String
{}
s2
:=
String
Set
{}
s2
:=
String
{}
if
len
(
s
)
!=
0
{
if
len
(
s
)
!=
0
{
t
.
Errorf
(
"Expected len=0: %d"
,
len
(
s
))
t
.
Errorf
(
"Expected len=0: %d"
,
len
(
s
))
}
}
...
@@ -60,7 +60,7 @@ func TestStringSet(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestStringSet(t *testing.T) {
}
}
func
TestStringSetDeleteMultiples
(
t
*
testing
.
T
)
{
func
TestStringSetDeleteMultiples
(
t
*
testing
.
T
)
{
s
:=
String
Set
{}
s
:=
String
{}
s
.
Insert
(
"a"
,
"b"
,
"c"
)
s
.
Insert
(
"a"
,
"b"
,
"c"
)
if
len
(
s
)
!=
3
{
if
len
(
s
)
!=
3
{
t
.
Errorf
(
"Expected len=3: %d"
,
len
(
s
))
t
.
Errorf
(
"Expected len=3: %d"
,
len
(
s
))
...
@@ -83,7 +83,7 @@ func TestStringSetDeleteMultiples(t *testing.T) {
...
@@ -83,7 +83,7 @@ func TestStringSetDeleteMultiples(t *testing.T) {
}
}
func
TestNewStringSet
(
t
*
testing
.
T
)
{
func
TestNewStringSet
(
t
*
testing
.
T
)
{
s
:=
NewString
Set
(
"a"
,
"b"
,
"c"
)
s
:=
NewString
(
"a"
,
"b"
,
"c"
)
if
len
(
s
)
!=
3
{
if
len
(
s
)
!=
3
{
t
.
Errorf
(
"Expected len=3: %d"
,
len
(
s
))
t
.
Errorf
(
"Expected len=3: %d"
,
len
(
s
))
}
}
...
@@ -93,15 +93,15 @@ func TestNewStringSet(t *testing.T) {
...
@@ -93,15 +93,15 @@ func TestNewStringSet(t *testing.T) {
}
}
func
TestStringSetList
(
t
*
testing
.
T
)
{
func
TestStringSetList
(
t
*
testing
.
T
)
{
s
:=
NewString
Set
(
"z"
,
"y"
,
"x"
,
"a"
)
s
:=
NewString
(
"z"
,
"y"
,
"x"
,
"a"
)
if
!
reflect
.
DeepEqual
(
s
.
List
(),
[]
string
{
"a"
,
"x"
,
"y"
,
"z"
})
{
if
!
reflect
.
DeepEqual
(
s
.
List
(),
[]
string
{
"a"
,
"x"
,
"y"
,
"z"
})
{
t
.
Errorf
(
"List gave unexpected result: %#v"
,
s
.
List
())
t
.
Errorf
(
"List gave unexpected result: %#v"
,
s
.
List
())
}
}
}
}
func
TestStringSetDifference
(
t
*
testing
.
T
)
{
func
TestStringSetDifference
(
t
*
testing
.
T
)
{
a
:=
NewString
Set
(
"1"
,
"2"
,
"3"
)
a
:=
NewString
(
"1"
,
"2"
,
"3"
)
b
:=
NewString
Set
(
"1"
,
"2"
,
"4"
,
"5"
)
b
:=
NewString
(
"1"
,
"2"
,
"4"
,
"5"
)
c
:=
a
.
Difference
(
b
)
c
:=
a
.
Difference
(
b
)
d
:=
b
.
Difference
(
a
)
d
:=
b
.
Difference
(
a
)
if
len
(
c
)
!=
1
{
if
len
(
c
)
!=
1
{
...
@@ -119,7 +119,7 @@ func TestStringSetDifference(t *testing.T) {
...
@@ -119,7 +119,7 @@ func TestStringSetDifference(t *testing.T) {
}
}
func
TestStringSetHasAny
(
t
*
testing
.
T
)
{
func
TestStringSetHasAny
(
t
*
testing
.
T
)
{
a
:=
NewString
Set
(
"1"
,
"2"
,
"3"
)
a
:=
NewString
(
"1"
,
"2"
,
"3"
)
if
!
a
.
HasAny
(
"1"
,
"4"
)
{
if
!
a
.
HasAny
(
"1"
,
"4"
)
{
t
.
Errorf
(
"expected true, got false"
)
t
.
Errorf
(
"expected true, got false"
)
...
@@ -132,37 +132,37 @@ func TestStringSetHasAny(t *testing.T) {
...
@@ -132,37 +132,37 @@ func TestStringSetHasAny(t *testing.T) {
func
TestStringSetEquals
(
t
*
testing
.
T
)
{
func
TestStringSetEquals
(
t
*
testing
.
T
)
{
// Simple case (order doesn't matter)
// Simple case (order doesn't matter)
a
:=
NewString
Set
(
"1"
,
"2"
)
a
:=
NewString
(
"1"
,
"2"
)
b
:=
NewString
Set
(
"2"
,
"1"
)
b
:=
NewString
(
"2"
,
"1"
)
if
!
a
.
Equal
(
b
)
{
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
}
// It is a set; duplicates are ignored
// It is a set; duplicates are ignored
b
=
NewString
Set
(
"2"
,
"2"
,
"1"
)
b
=
NewString
(
"2"
,
"2"
,
"1"
)
if
!
a
.
Equal
(
b
)
{
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
}
// Edge cases around empty sets / empty strings
// Edge cases around empty sets / empty strings
a
=
NewString
Set
()
a
=
NewString
()
b
=
NewString
Set
()
b
=
NewString
()
if
!
a
.
Equal
(
b
)
{
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
}
b
=
NewString
Set
(
"1"
,
"2"
,
"3"
)
b
=
NewString
(
"1"
,
"2"
,
"3"
)
if
a
.
Equal
(
b
)
{
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
}
b
=
NewString
Set
(
"1"
,
"2"
,
""
)
b
=
NewString
(
"1"
,
"2"
,
""
)
if
a
.
Equal
(
b
)
{
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
}
// Check for equality after mutation
// Check for equality after mutation
a
=
NewString
Set
()
a
=
NewString
()
a
.
Insert
(
"1"
)
a
.
Insert
(
"1"
)
if
a
.
Equal
(
b
)
{
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
...
...
pkg/volume/gce_pd/gce_util.go
View file @
a48f2182
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/operationmanager"
"k8s.io/kubernetes/pkg/util/operationmanager"
"k8s.io/kubernetes/pkg/util/sets"
)
)
const
(
const
(
...
@@ -62,7 +63,7 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
...
@@ -62,7 +63,7 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error filepath.Glob(
\"
%s
\"
): %v
\r\n
"
,
diskSDPattern
,
err
)
glog
.
Errorf
(
"Error filepath.Glob(
\"
%s
\"
): %v
\r\n
"
,
diskSDPattern
,
err
)
}
}
sdBeforeSet
:=
util
.
NewStringSet
(
sdBefore
...
)
sdBeforeSet
:=
sets
.
NewString
(
sdBefore
...
)
devicePath
,
err
:=
attachDiskAndVerify
(
b
,
sdBeforeSet
)
devicePath
,
err
:=
attachDiskAndVerify
(
b
,
sdBeforeSet
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -120,7 +121,7 @@ func (util *GCEDiskUtil) DetachDisk(c *gcePersistentDiskCleaner) error {
...
@@ -120,7 +121,7 @@ func (util *GCEDiskUtil) DetachDisk(c *gcePersistentDiskCleaner) error {
}
}
// Attaches the specified persistent disk device to node, verifies that it is attached, and retries if it fails.
// Attaches the specified persistent disk device to node, verifies that it is attached, and retries if it fails.
func
attachDiskAndVerify
(
b
*
gcePersistentDiskBuilder
,
sdBeforeSet
util
.
StringSet
)
(
string
,
error
)
{
func
attachDiskAndVerify
(
b
*
gcePersistentDiskBuilder
,
sdBeforeSet
sets
.
String
)
(
string
,
error
)
{
devicePaths
:=
getDiskByIdPaths
(
b
.
gcePersistentDisk
)
devicePaths
:=
getDiskByIdPaths
(
b
.
gcePersistentDisk
)
var
gce
cloudprovider
.
Interface
var
gce
cloudprovider
.
Interface
for
numRetries
:=
0
;
numRetries
<
maxRetries
;
numRetries
++
{
for
numRetries
:=
0
;
numRetries
<
maxRetries
;
numRetries
++
{
...
@@ -287,7 +288,7 @@ func pathExists(path string) (bool, error) {
...
@@ -287,7 +288,7 @@ func pathExists(path string) (bool, error) {
// Calls "udevadm trigger --action=change" for newly created "/dev/sd*" drives (exist only in after set).
// Calls "udevadm trigger --action=change" for newly created "/dev/sd*" drives (exist only in after set).
// This is workaround for Issue #7972. Once the underlying issue has been resolved, this may be removed.
// This is workaround for Issue #7972. Once the underlying issue has been resolved, this may be removed.
func
udevadmChangeToNewDrives
(
sdBeforeSet
util
.
StringSet
)
error
{
func
udevadmChangeToNewDrives
(
sdBeforeSet
sets
.
String
)
error
{
sdAfter
,
err
:=
filepath
.
Glob
(
diskSDPattern
)
sdAfter
,
err
:=
filepath
.
Glob
(
diskSDPattern
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error filepath.Glob(
\"
%s
\"
): %v
\r\n
"
,
diskSDPattern
,
err
)
return
fmt
.
Errorf
(
"Error filepath.Glob(
\"
%s
\"
): %v
\r\n
"
,
diskSDPattern
,
err
)
...
...
plugin/pkg/admission/namespace/lifecycle/admission.go
View file @
a48f2182
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -46,7 +46,7 @@ type lifecycle struct {
...
@@ -46,7 +46,7 @@ type lifecycle struct {
*
admission
.
Handler
*
admission
.
Handler
client
client
.
Interface
client
client
.
Interface
store
cache
.
Store
store
cache
.
Store
immortalNamespaces
util
.
StringSet
immortalNamespaces
sets
.
String
}
}
func
(
l
*
lifecycle
)
Admit
(
a
admission
.
Attributes
)
(
err
error
)
{
func
(
l
*
lifecycle
)
Admit
(
a
admission
.
Attributes
)
(
err
error
)
{
...
@@ -120,6 +120,6 @@ func NewLifecycle(c client.Interface) admission.Interface {
...
@@ -120,6 +120,6 @@ func NewLifecycle(c client.Interface) admission.Interface {
Handler
:
admission
.
NewHandler
(
admission
.
Create
,
admission
.
Update
,
admission
.
Delete
),
Handler
:
admission
.
NewHandler
(
admission
.
Create
,
admission
.
Update
,
admission
.
Delete
),
client
:
c
,
client
:
c
,
store
:
store
,
store
:
store
,
immortalNamespaces
:
util
.
NewStringSet
(
api
.
NamespaceDefault
),
immortalNamespaces
:
sets
.
NewString
(
api
.
NamespaceDefault
),
}
}
}
}
plugin/pkg/admission/serviceaccount/admission.go
View file @
a48f2182
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet"
"k8s.io/kubernetes/pkg/kubelet"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -249,7 +249,7 @@ func (s *serviceAccount) getReferencedServiceAccountToken(serviceAccount *api.Se
...
@@ -249,7 +249,7 @@ func (s *serviceAccount) getReferencedServiceAccountToken(serviceAccount *api.Se
return
""
,
err
return
""
,
err
}
}
references
:=
util
.
NewStringSet
()
references
:=
sets
.
NewString
()
for
_
,
secret
:=
range
serviceAccount
.
Secrets
{
for
_
,
secret
:=
range
serviceAccount
.
Secrets
{
references
.
Insert
(
secret
.
Name
)
references
.
Insert
(
secret
.
Name
)
}
}
...
@@ -293,7 +293,7 @@ func (s *serviceAccount) getServiceAccountTokens(serviceAccount *api.ServiceAcco
...
@@ -293,7 +293,7 @@ func (s *serviceAccount) getServiceAccountTokens(serviceAccount *api.ServiceAcco
func
(
s
*
serviceAccount
)
limitSecretReferences
(
serviceAccount
*
api
.
ServiceAccount
,
pod
*
api
.
Pod
)
error
{
func
(
s
*
serviceAccount
)
limitSecretReferences
(
serviceAccount
*
api
.
ServiceAccount
,
pod
*
api
.
Pod
)
error
{
// Ensure all secrets the pod references are allowed by the service account
// Ensure all secrets the pod references are allowed by the service account
mountableSecrets
:=
util
.
NewStringSet
()
mountableSecrets
:=
sets
.
NewString
()
for
_
,
s
:=
range
serviceAccount
.
Secrets
{
for
_
,
s
:=
range
serviceAccount
.
Secrets
{
mountableSecrets
.
Insert
(
s
.
Name
)
mountableSecrets
.
Insert
(
s
.
Name
)
}
}
...
@@ -309,7 +309,7 @@ func (s *serviceAccount) limitSecretReferences(serviceAccount *api.ServiceAccoun
...
@@ -309,7 +309,7 @@ func (s *serviceAccount) limitSecretReferences(serviceAccount *api.ServiceAccoun
}
}
// limit pull secret references as well
// limit pull secret references as well
pullSecrets
:=
util
.
NewStringSet
()
pullSecrets
:=
sets
.
NewString
()
for
_
,
s
:=
range
serviceAccount
.
ImagePullSecrets
{
for
_
,
s
:=
range
serviceAccount
.
ImagePullSecrets
{
pullSecrets
.
Insert
(
s
.
Name
)
pullSecrets
.
Insert
(
s
.
Name
)
}
}
...
@@ -340,7 +340,7 @@ func (s *serviceAccount) mountServiceAccountToken(serviceAccount *api.ServiceAcc
...
@@ -340,7 +340,7 @@ func (s *serviceAccount) mountServiceAccountToken(serviceAccount *api.ServiceAcc
// Find the volume and volume name for the ServiceAccountTokenSecret if it already exists
// Find the volume and volume name for the ServiceAccountTokenSecret if it already exists
tokenVolumeName
:=
""
tokenVolumeName
:=
""
hasTokenVolume
:=
false
hasTokenVolume
:=
false
allVolumeNames
:=
util
.
NewStringSet
()
allVolumeNames
:=
sets
.
NewString
()
for
_
,
volume
:=
range
pod
.
Spec
.
Volumes
{
for
_
,
volume
:=
range
pod
.
Spec
.
Volumes
{
allVolumeNames
.
Insert
(
volume
.
Name
)
allVolumeNames
.
Insert
(
volume
.
Name
)
if
volume
.
Secret
!=
nil
&&
volume
.
Secret
.
SecretName
==
serviceAccountToken
{
if
volume
.
Secret
!=
nil
&&
volume
.
Secret
.
SecretName
==
serviceAccountToken
{
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
a48f2182
...
@@ -18,7 +18,7 @@ limitations under the License.
...
@@ -18,7 +18,7 @@ limitations under the License.
package
defaults
package
defaults
import
(
import
(
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
...
@@ -48,8 +48,8 @@ func init() {
...
@@ -48,8 +48,8 @@ func init() {
)
)
}
}
func
defaultPredicates
()
util
.
StringSet
{
func
defaultPredicates
()
sets
.
String
{
return
util
.
NewStringSet
(
return
sets
.
NewString
(
// Fit is defined based on the absence of port conflicts.
// Fit is defined based on the absence of port conflicts.
factory
.
RegisterFitPredicate
(
"PodFitsPorts"
,
predicates
.
PodFitsPorts
),
factory
.
RegisterFitPredicate
(
"PodFitsPorts"
,
predicates
.
PodFitsPorts
),
// Fit is determined by resource availability.
// Fit is determined by resource availability.
...
@@ -73,8 +73,8 @@ func defaultPredicates() util.StringSet {
...
@@ -73,8 +73,8 @@ func defaultPredicates() util.StringSet {
)
)
}
}
func
defaultPriorities
()
util
.
StringSet
{
func
defaultPriorities
()
sets
.
String
{
return
util
.
NewStringSet
(
return
sets
.
NewString
(
// Prioritize nodes by least requested utilization.
// Prioritize nodes by least requested utilization.
factory
.
RegisterPriorityFunction
(
"LeastRequestedPriority"
,
priorities
.
LeastRequestedPriority
,
1
),
factory
.
RegisterPriorityFunction
(
"LeastRequestedPriority"
,
priorities
.
LeastRequestedPriority
,
1
),
// Prioritizes nodes to help achieve balanced resource usage
// Prioritizes nodes to help achieve balanced resource usage
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
a48f2182
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
...
@@ -137,13 +138,13 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler
...
@@ -137,13 +138,13 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler
return
nil
,
err
return
nil
,
err
}
}
predicateKeys
:=
util
.
NewStringSet
()
predicateKeys
:=
sets
.
NewString
()
for
_
,
predicate
:=
range
policy
.
Predicates
{
for
_
,
predicate
:=
range
policy
.
Predicates
{
glog
.
V
(
2
)
.
Infof
(
"Registering predicate: %s"
,
predicate
.
Name
)
glog
.
V
(
2
)
.
Infof
(
"Registering predicate: %s"
,
predicate
.
Name
)
predicateKeys
.
Insert
(
RegisterCustomFitPredicate
(
predicate
))
predicateKeys
.
Insert
(
RegisterCustomFitPredicate
(
predicate
))
}
}
priorityKeys
:=
util
.
NewStringSet
()
priorityKeys
:=
sets
.
NewString
()
for
_
,
priority
:=
range
policy
.
Priorities
{
for
_
,
priority
:=
range
policy
.
Priorities
{
glog
.
V
(
2
)
.
Infof
(
"Registering priority: %s"
,
priority
.
Name
)
glog
.
V
(
2
)
.
Infof
(
"Registering priority: %s"
,
priority
.
Name
)
priorityKeys
.
Insert
(
RegisterCustomPriorityFunction
(
priority
))
priorityKeys
.
Insert
(
RegisterCustomPriorityFunction
(
priority
))
...
@@ -153,7 +154,7 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler
...
@@ -153,7 +154,7 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler
}
}
// Creates a scheduler from a set of registered fit predicate keys and priority keys.
// Creates a scheduler from a set of registered fit predicate keys and priority keys.
func
(
f
*
ConfigFactory
)
CreateFromKeys
(
predicateKeys
,
priorityKeys
util
.
StringSet
)
(
*
scheduler
.
Config
,
error
)
{
func
(
f
*
ConfigFactory
)
CreateFromKeys
(
predicateKeys
,
priorityKeys
sets
.
String
)
(
*
scheduler
.
Config
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"creating scheduler with fit predicates '%v' and priority functions '%v"
,
predicateKeys
,
priorityKeys
)
glog
.
V
(
2
)
.
Infof
(
"creating scheduler with fit predicates '%v' and priority functions '%v"
,
predicateKeys
,
priorityKeys
)
pluginArgs
:=
PluginFactoryArgs
{
pluginArgs
:=
PluginFactoryArgs
{
PodLister
:
f
.
PodLister
,
PodLister
:
f
.
PodLister
,
...
...
plugin/pkg/scheduler/factory/plugins.go
View file @
a48f2182
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"strings"
"strings"
"sync"
"sync"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities"
...
@@ -66,8 +66,8 @@ const (
...
@@ -66,8 +66,8 @@ const (
)
)
type
AlgorithmProviderConfig
struct
{
type
AlgorithmProviderConfig
struct
{
FitPredicateKeys
util
.
StringSet
FitPredicateKeys
sets
.
String
PriorityFunctionKeys
util
.
StringSet
PriorityFunctionKeys
sets
.
String
}
}
// RegisterFitPredicate registers a fit predicate with the algorithm
// RegisterFitPredicate registers a fit predicate with the algorithm
...
@@ -209,7 +209,7 @@ func IsPriorityFunctionRegistered(name string) bool {
...
@@ -209,7 +209,7 @@ func IsPriorityFunctionRegistered(name string) bool {
// Registers a new algorithm provider with the algorithm registry. This should
// Registers a new algorithm provider with the algorithm registry. This should
// be called from the init function in a provider plugin.
// be called from the init function in a provider plugin.
func
RegisterAlgorithmProvider
(
name
string
,
predicateKeys
,
priorityKeys
util
.
StringSet
)
string
{
func
RegisterAlgorithmProvider
(
name
string
,
predicateKeys
,
priorityKeys
sets
.
String
)
string
{
schedulerFactoryMutex
.
Lock
()
schedulerFactoryMutex
.
Lock
()
defer
schedulerFactoryMutex
.
Unlock
()
defer
schedulerFactoryMutex
.
Unlock
()
validateAlgorithmNameOrDie
(
name
)
validateAlgorithmNameOrDie
(
name
)
...
@@ -234,7 +234,7 @@ func GetAlgorithmProvider(name string) (*AlgorithmProviderConfig, error) {
...
@@ -234,7 +234,7 @@ func GetAlgorithmProvider(name string) (*AlgorithmProviderConfig, error) {
return
&
provider
,
nil
return
&
provider
,
nil
}
}
func
getFitPredicateFunctions
(
names
util
.
StringSet
,
args
PluginFactoryArgs
)
(
map
[
string
]
algorithm
.
FitPredicate
,
error
)
{
func
getFitPredicateFunctions
(
names
sets
.
String
,
args
PluginFactoryArgs
)
(
map
[
string
]
algorithm
.
FitPredicate
,
error
)
{
schedulerFactoryMutex
.
Lock
()
schedulerFactoryMutex
.
Lock
()
defer
schedulerFactoryMutex
.
Unlock
()
defer
schedulerFactoryMutex
.
Unlock
()
...
@@ -249,7 +249,7 @@ func getFitPredicateFunctions(names util.StringSet, args PluginFactoryArgs) (map
...
@@ -249,7 +249,7 @@ func getFitPredicateFunctions(names util.StringSet, args PluginFactoryArgs) (map
return
predicates
,
nil
return
predicates
,
nil
}
}
func
getPriorityFunctionConfigs
(
names
util
.
StringSet
,
args
PluginFactoryArgs
)
([]
algorithm
.
PriorityConfig
,
error
)
{
func
getPriorityFunctionConfigs
(
names
sets
.
String
,
args
PluginFactoryArgs
)
([]
algorithm
.
PriorityConfig
,
error
)
{
schedulerFactoryMutex
.
Lock
()
schedulerFactoryMutex
.
Lock
()
defer
schedulerFactoryMutex
.
Unlock
()
defer
schedulerFactoryMutex
.
Unlock
()
...
...
plugin/pkg/scheduler/generic_scheduler.go
View file @
a48f2182
...
@@ -25,12 +25,12 @@ import (
...
@@ -25,12 +25,12 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
)
)
type
FailedPredicateMap
map
[
string
]
util
.
StringSet
type
FailedPredicateMap
map
[
string
]
sets
.
String
type
FitError
struct
{
type
FitError
struct
{
Pod
*
api
.
Pod
Pod
*
api
.
Pod
...
@@ -124,7 +124,7 @@ func findNodesThatFit(pod *api.Pod, podLister algorithm.PodLister, predicateFunc
...
@@ -124,7 +124,7 @@ func findNodesThatFit(pod *api.Pod, podLister algorithm.PodLister, predicateFunc
if
!
fit
{
if
!
fit
{
fits
=
false
fits
=
false
if
_
,
found
:=
failedPredicateMap
[
node
.
Name
];
!
found
{
if
_
,
found
:=
failedPredicateMap
[
node
.
Name
];
!
found
{
failedPredicateMap
[
node
.
Name
]
=
util
.
StringSet
{}
failedPredicateMap
[
node
.
Name
]
=
sets
.
String
{}
}
}
if
predicates
.
FailedResourceType
!=
""
{
if
predicates
.
FailedResourceType
!=
""
{
failedPredicateMap
[
node
.
Name
]
.
Insert
(
predicates
.
FailedResourceType
)
failedPredicateMap
[
node
.
Name
]
.
Insert
(
predicates
.
FailedResourceType
)
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
a48f2182
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"testing"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
)
)
...
@@ -101,7 +101,7 @@ func TestSelectHost(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestSelectHost(t *testing.T) {
scheduler
:=
genericScheduler
{
random
:
rand
.
New
(
rand
.
NewSource
(
0
))}
scheduler
:=
genericScheduler
{
random
:
rand
.
New
(
rand
.
NewSource
(
0
))}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
list
algorithm
.
HostPriorityList
list
algorithm
.
HostPriorityList
possibleHosts
util
.
StringSet
possibleHosts
sets
.
String
expectsErr
bool
expectsErr
bool
}{
}{
{
{
...
@@ -109,7 +109,7 @@ func TestSelectHost(t *testing.T) {
...
@@ -109,7 +109,7 @@ func TestSelectHost(t *testing.T) {
{
Host
:
"machine1.1"
,
Score
:
1
},
{
Host
:
"machine1.1"
,
Score
:
1
},
{
Host
:
"machine2.1"
,
Score
:
2
},
{
Host
:
"machine2.1"
,
Score
:
2
},
},
},
possibleHosts
:
util
.
NewStringSet
(
"machine2.1"
),
possibleHosts
:
sets
.
NewString
(
"machine2.1"
),
expectsErr
:
false
,
expectsErr
:
false
,
},
},
// equal scores
// equal scores
...
@@ -120,7 +120,7 @@ func TestSelectHost(t *testing.T) {
...
@@ -120,7 +120,7 @@ func TestSelectHost(t *testing.T) {
{
Host
:
"machine1.3"
,
Score
:
2
},
{
Host
:
"machine1.3"
,
Score
:
2
},
{
Host
:
"machine2.1"
,
Score
:
2
},
{
Host
:
"machine2.1"
,
Score
:
2
},
},
},
possibleHosts
:
util
.
NewStringSet
(
"machine1.2"
,
"machine1.3"
,
"machine2.1"
),
possibleHosts
:
sets
.
NewString
(
"machine1.2"
,
"machine1.3"
,
"machine2.1"
),
expectsErr
:
false
,
expectsErr
:
false
,
},
},
// out of order scores
// out of order scores
...
@@ -132,13 +132,13 @@ func TestSelectHost(t *testing.T) {
...
@@ -132,13 +132,13 @@ func TestSelectHost(t *testing.T) {
{
Host
:
"machine3.1"
,
Score
:
1
},
{
Host
:
"machine3.1"
,
Score
:
1
},
{
Host
:
"machine1.3"
,
Score
:
3
},
{
Host
:
"machine1.3"
,
Score
:
3
},
},
},
possibleHosts
:
util
.
NewStringSet
(
"machine1.1"
,
"machine1.2"
,
"machine1.3"
),
possibleHosts
:
sets
.
NewString
(
"machine1.1"
,
"machine1.2"
,
"machine1.3"
),
expectsErr
:
false
,
expectsErr
:
false
,
},
},
// empty priorityList
// empty priorityList
{
{
list
:
[]
algorithm
.
HostPriority
{},
list
:
[]
algorithm
.
HostPriority
{},
possibleHosts
:
util
.
NewStringSet
(),
possibleHosts
:
sets
.
NewString
(),
expectsErr
:
true
,
expectsErr
:
true
,
},
},
}
}
...
...
test/e2e/daemon_restart.go
View file @
a48f2182
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -140,7 +141,7 @@ func getContainerRestarts(c *client.Client, ns string, labelSelector labels.Sele
...
@@ -140,7 +141,7 @@ func getContainerRestarts(c *client.Client, ns string, labelSelector labels.Sele
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
labelSelector
,
fields
.
Everything
())
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
labelSelector
,
fields
.
Everything
())
expectNoError
(
err
)
expectNoError
(
err
)
failedContainers
:=
0
failedContainers
:=
0
containerRestartNodes
:=
util
.
NewStringSet
()
containerRestartNodes
:=
sets
.
NewString
()
for
_
,
p
:=
range
pods
.
Items
{
for
_
,
p
:=
range
pods
.
Items
{
for
_
,
v
:=
range
FailedContainers
(
&
p
)
{
for
_
,
v
:=
range
FailedContainers
(
&
p
)
{
failedContainers
=
failedContainers
+
v
.
restarts
failedContainers
=
failedContainers
+
v
.
restarts
...
@@ -224,8 +225,8 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -224,8 +225,8 @@ var _ = Describe("DaemonRestart", func() {
// Only check the keys, the pods can be different if the kubelet updated it.
// Only check the keys, the pods can be different if the kubelet updated it.
// TODO: Can it really?
// TODO: Can it really?
existingKeys
:=
util
.
NewStringSet
()
existingKeys
:=
sets
.
NewString
()
newKeys
:=
util
.
NewStringSet
()
newKeys
:=
sets
.
NewString
()
for
_
,
k
:=
range
existingPods
.
ListKeys
()
{
for
_
,
k
:=
range
existingPods
.
ListKeys
()
{
existingKeys
.
Insert
(
k
)
existingKeys
.
Insert
(
k
)
}
}
...
...
test/e2e/density.go
View file @
a48f2182
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -148,7 +149,7 @@ var _ = Describe("Density", func() {
...
@@ -148,7 +149,7 @@ var _ = Describe("Density", func() {
expectNoError
(
writePerfData
(
c
,
fmt
.
Sprintf
(
testContext
.
OutputDir
+
"/%s"
,
uuid
),
"after"
))
expectNoError
(
writePerfData
(
c
,
fmt
.
Sprintf
(
testContext
.
OutputDir
+
"/%s"
,
uuid
),
"after"
))
// Verify latency metrics
// Verify latency metrics
highLatencyRequests
,
err
:=
HighLatencyRequests
(
c
,
3
*
time
.
Second
,
util
.
NewStringSet
(
"events"
))
highLatencyRequests
,
err
:=
HighLatencyRequests
(
c
,
3
*
time
.
Second
,
sets
.
NewString
(
"events"
))
expectNoError
(
err
)
expectNoError
(
err
)
Expect
(
highLatencyRequests
)
.
NotTo
(
BeNumerically
(
">"
,
0
),
"There should be no high-latency requests"
)
Expect
(
highLatencyRequests
)
.
NotTo
(
BeNumerically
(
">"
,
0
),
"There should be no high-latency requests"
)
})
})
...
...
test/e2e/kubelet.go
View file @
a48f2182
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -41,8 +42,8 @@ const (
...
@@ -41,8 +42,8 @@ const (
// getPodMatches returns a set of pod names on the given node that matches the
// getPodMatches returns a set of pod names on the given node that matches the
// podNamePrefix and namespace.
// podNamePrefix and namespace.
func
getPodMatches
(
c
*
client
.
Client
,
nodeName
string
,
podNamePrefix
string
,
namespace
string
)
util
.
StringSet
{
func
getPodMatches
(
c
*
client
.
Client
,
nodeName
string
,
podNamePrefix
string
,
namespace
string
)
sets
.
String
{
matches
:=
util
.
NewStringSet
()
matches
:=
sets
.
NewString
()
Logf
(
"Checking pods on node %v via /runningpods endpoint"
,
nodeName
)
Logf
(
"Checking pods on node %v via /runningpods endpoint"
,
nodeName
)
runningPods
,
err
:=
GetKubeletPods
(
c
,
nodeName
)
runningPods
,
err
:=
GetKubeletPods
(
c
,
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -65,9 +66,9 @@ func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, name
...
@@ -65,9 +66,9 @@ func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, name
// information; they are reconstructed by examining the container runtime. In
// information; they are reconstructed by examining the container runtime. In
// the scope of this test, we do not expect pod naming conflicts so
// the scope of this test, we do not expect pod naming conflicts so
// podNamePrefix should be sufficient to identify the pods.
// podNamePrefix should be sufficient to identify the pods.
func
waitTillNPodsRunningOnNodes
(
c
*
client
.
Client
,
nodeNames
util
.
StringSet
,
podNamePrefix
string
,
namespace
string
,
targetNumPods
int
,
timeout
time
.
Duration
)
error
{
func
waitTillNPodsRunningOnNodes
(
c
*
client
.
Client
,
nodeNames
sets
.
String
,
podNamePrefix
string
,
namespace
string
,
targetNumPods
int
,
timeout
time
.
Duration
)
error
{
return
wait
.
Poll
(
pollInterval
,
timeout
,
func
()
(
bool
,
error
)
{
return
wait
.
Poll
(
pollInterval
,
timeout
,
func
()
(
bool
,
error
)
{
matchCh
:=
make
(
chan
util
.
StringSet
,
len
(
nodeNames
))
matchCh
:=
make
(
chan
sets
.
String
,
len
(
nodeNames
))
for
_
,
item
:=
range
nodeNames
.
List
()
{
for
_
,
item
:=
range
nodeNames
.
List
()
{
// Launch a goroutine per node to check the pods running on the nodes.
// Launch a goroutine per node to check the pods running on the nodes.
nodeName
:=
item
nodeName
:=
item
...
@@ -76,7 +77,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
...
@@ -76,7 +77,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
}()
}()
}
}
seen
:=
util
.
NewStringSet
()
seen
:=
sets
.
NewString
()
for
i
:=
0
;
i
<
len
(
nodeNames
.
List
());
i
++
{
for
i
:=
0
;
i
<
len
(
nodeNames
.
List
());
i
++
{
seen
=
seen
.
Union
(
<-
matchCh
)
seen
=
seen
.
Union
(
<-
matchCh
)
}
}
...
@@ -90,7 +91,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
...
@@ -90,7 +91,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
var
_
=
Describe
(
"kubelet"
,
func
()
{
var
_
=
Describe
(
"kubelet"
,
func
()
{
var
numNodes
int
var
numNodes
int
var
nodeNames
util
.
StringSet
var
nodeNames
sets
.
String
framework
:=
NewFramework
(
"kubelet"
)
framework
:=
NewFramework
(
"kubelet"
)
var
resourceMonitor
*
resourceMonitor
var
resourceMonitor
*
resourceMonitor
...
@@ -98,7 +99,7 @@ var _ = Describe("kubelet", func() {
...
@@ -98,7 +99,7 @@ var _ = Describe("kubelet", func() {
nodes
,
err
:=
framework
.
Client
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
nodes
,
err
:=
framework
.
Client
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
expectNoError
(
err
)
numNodes
=
len
(
nodes
.
Items
)
numNodes
=
len
(
nodes
.
Items
)
nodeNames
=
util
.
NewStringSet
()
nodeNames
=
sets
.
NewString
()
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
.
Items
{
nodeNames
.
Insert
(
node
.
Name
)
nodeNames
.
Insert
(
node
.
Name
)
}
}
...
...
test/e2e/kubelet_stats.go
View file @
a48f2182
...
@@ -37,6 +37,7 @@ import (
...
@@ -37,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/prometheus/client_golang/extraction"
"github.com/prometheus/client_golang/extraction"
"github.com/prometheus/client_golang/model"
"github.com/prometheus/client_golang/model"
...
@@ -66,7 +67,7 @@ func (a KubeletMetricByLatency) Less(i, j int) bool { return a[i].Latency > a[j]
...
@@ -66,7 +67,7 @@ func (a KubeletMetricByLatency) Less(i, j int) bool { return a[i].Latency > a[j]
type
kubeletMetricIngester
[]
KubeletMetric
type
kubeletMetricIngester
[]
KubeletMetric
func
(
k
*
kubeletMetricIngester
)
Ingest
(
samples
model
.
Samples
)
error
{
func
(
k
*
kubeletMetricIngester
)
Ingest
(
samples
model
.
Samples
)
error
{
acceptedMethods
:=
util
.
NewStringSet
(
acceptedMethods
:=
sets
.
NewString
(
metrics
.
PodWorkerLatencyKey
,
metrics
.
PodWorkerLatencyKey
,
metrics
.
PodWorkerStartLatencyKey
,
metrics
.
PodWorkerStartLatencyKey
,
metrics
.
SyncPodsLatencyKey
,
metrics
.
SyncPodsLatencyKey
,
...
...
test/e2e/load.go
View file @
a48f2182
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
...
@@ -86,7 +86,7 @@ var _ = Describe("Load capacity", func() {
...
@@ -86,7 +86,7 @@ var _ = Describe("Load capacity", func() {
}
}
// Verify latency metrics
// Verify latency metrics
highLatencyRequests
,
err
:=
HighLatencyRequests
(
c
,
3
*
time
.
Second
,
util
.
NewStringSet
(
"events"
))
highLatencyRequests
,
err
:=
HighLatencyRequests
(
c
,
3
*
time
.
Second
,
sets
.
NewString
(
"events"
))
expectNoError
(
err
,
"Too many instances metrics above the threshold"
)
expectNoError
(
err
,
"Too many instances metrics above the threshold"
)
Expect
(
highLatencyRequests
)
.
NotTo
(
BeNumerically
(
">"
,
0
))
Expect
(
highLatencyRequests
)
.
NotTo
(
BeNumerically
(
">"
,
0
))
})
})
...
...
test/e2e/service_latency.go
View file @
a48f2182
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -70,7 +71,7 @@ var _ = Describe("Service endpoints latency", func() {
...
@@ -70,7 +71,7 @@ var _ = Describe("Service endpoints latency", func() {
f
.
Client
.
RESTClient
.
Throttle
=
util
.
NewFakeRateLimiter
()
f
.
Client
.
RESTClient
.
Throttle
=
util
.
NewFakeRateLimiter
()
defer
func
()
{
f
.
Client
.
RESTClient
.
Throttle
=
oldThrottle
}()
defer
func
()
{
f
.
Client
.
RESTClient
.
Throttle
=
oldThrottle
}()
failing
:=
util
.
NewStringSet
()
failing
:=
sets
.
NewString
()
d
,
err
:=
runServiceLatencies
(
f
,
parallelTrials
,
totalTrials
)
d
,
err
:=
runServiceLatencies
(
f
,
parallelTrials
,
totalTrials
)
if
err
!=
nil
{
if
err
!=
nil
{
failing
.
Insert
(
fmt
.
Sprintf
(
"Not all RC/pod/service trials succeeded: %v"
,
err
))
failing
.
Insert
(
fmt
.
Sprintf
(
"Not all RC/pod/service trials succeeded: %v"
,
err
))
...
...
test/e2e/util.go
View file @
a48f2182
...
@@ -45,6 +45,7 @@ import (
...
@@ -45,6 +45,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -1096,7 +1097,7 @@ type podInfo struct {
...
@@ -1096,7 +1097,7 @@ type podInfo struct {
type
PodDiff
map
[
string
]
*
podInfo
type
PodDiff
map
[
string
]
*
podInfo
// Print formats and prints the give PodDiff.
// Print formats and prints the give PodDiff.
func
(
p
PodDiff
)
Print
(
ignorePhases
util
.
StringSet
)
{
func
(
p
PodDiff
)
Print
(
ignorePhases
sets
.
String
)
{
for
name
,
info
:=
range
p
{
for
name
,
info
:=
range
p
{
if
ignorePhases
.
Has
(
info
.
phase
)
{
if
ignorePhases
.
Has
(
info
.
phase
)
{
continue
continue
...
@@ -1258,7 +1259,7 @@ func RunRC(config RCConfig) error {
...
@@ -1258,7 +1259,7 @@ func RunRC(config RCConfig) error {
unknown
:=
0
unknown
:=
0
inactive
:=
0
inactive
:=
0
failedContainers
:=
0
failedContainers
:=
0
containerRestartNodes
:=
util
.
NewStringSet
()
containerRestartNodes
:=
sets
.
NewString
()
pods
:=
podStore
.
List
()
pods
:=
podStore
.
List
()
created
:=
[]
*
api
.
Pod
{}
created
:=
[]
*
api
.
Pod
{}
...
@@ -1312,7 +1313,7 @@ func RunRC(config RCConfig) error {
...
@@ -1312,7 +1313,7 @@ func RunRC(config RCConfig) error {
// - diagnose by comparing the previous "2 Pod states" lines for inactive pods
// - diagnose by comparing the previous "2 Pod states" lines for inactive pods
errorStr
:=
fmt
.
Sprintf
(
"Number of reported pods changed: %d vs %d"
,
len
(
pods
),
len
(
oldPods
))
errorStr
:=
fmt
.
Sprintf
(
"Number of reported pods changed: %d vs %d"
,
len
(
pods
),
len
(
oldPods
))
Logf
(
"%v, pods that changed since the last iteration:"
,
errorStr
)
Logf
(
"%v, pods that changed since the last iteration:"
,
errorStr
)
Diff
(
oldPods
,
pods
)
.
Print
(
util
.
NewStringSet
())
Diff
(
oldPods
,
pods
)
.
Print
(
sets
.
NewString
())
return
fmt
.
Errorf
(
errorStr
)
return
fmt
.
Errorf
(
errorStr
)
}
}
...
@@ -1342,7 +1343,7 @@ func RunRC(config RCConfig) error {
...
@@ -1342,7 +1343,7 @@ func RunRC(config RCConfig) error {
}
}
func
dumpPodDebugInfo
(
c
*
client
.
Client
,
pods
[]
*
api
.
Pod
)
{
func
dumpPodDebugInfo
(
c
*
client
.
Client
,
pods
[]
*
api
.
Pod
)
{
badNodes
:=
util
.
NewStringSet
()
badNodes
:=
sets
.
NewString
()
for
_
,
p
:=
range
pods
{
for
_
,
p
:=
range
pods
{
if
p
.
Status
.
Phase
!=
api
.
PodRunning
{
if
p
.
Status
.
Phase
!=
api
.
PodRunning
{
if
p
.
Spec
.
NodeName
!=
""
{
if
p
.
Spec
.
NodeName
!=
""
{
...
@@ -1851,8 +1852,8 @@ func ReadLatencyMetrics(c *client.Client) ([]LatencyMetric, error) {
...
@@ -1851,8 +1852,8 @@ func ReadLatencyMetrics(c *client.Client) ([]LatencyMetric, error) {
// Prints summary metrics for request types with latency above threshold
// Prints summary metrics for request types with latency above threshold
// and returns number of such request types.
// and returns number of such request types.
func
HighLatencyRequests
(
c
*
client
.
Client
,
threshold
time
.
Duration
,
ignoredResources
util
.
StringSet
)
(
int
,
error
)
{
func
HighLatencyRequests
(
c
*
client
.
Client
,
threshold
time
.
Duration
,
ignoredResources
sets
.
String
)
(
int
,
error
)
{
ignoredVerbs
:=
util
.
NewStringSet
(
"WATCHLIST"
,
"PROXY"
)
ignoredVerbs
:=
sets
.
NewString
(
"WATCHLIST"
,
"PROXY"
)
metrics
,
err
:=
ReadLatencyMetrics
(
c
)
metrics
,
err
:=
ReadLatencyMetrics
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
test/images/network-tester/webserver.go
View file @
a48f2182
...
@@ -45,7 +45,7 @@ import (
...
@@ -45,7 +45,7 @@ import (
"time"
"time"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
)
)
var
(
var
(
...
@@ -235,7 +235,7 @@ func contactOthers(state *State) {
...
@@ -235,7 +235,7 @@ func contactOthers(state *State) {
time
.
Sleep
(
time
.
Duration
(
1
+
rand
.
Intn
(
10
))
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
1
+
rand
.
Intn
(
10
))
*
time
.
Second
)
}
}
eps
:=
util
.
StringSet
{}
eps
:=
sets
.
String
{}
for
_
,
ss
:=
range
endpoints
.
Subsets
{
for
_
,
ss
:=
range
endpoints
.
Subsets
{
for
_
,
a
:=
range
ss
.
Addresses
{
for
_
,
a
:=
range
ss
.
Addresses
{
for
_
,
p
:=
range
ss
.
Ports
{
for
_
,
p
:=
range
ss
.
Ports
{
...
...
test/integration/service_account_test.go
View file @
a48f2182
...
@@ -45,7 +45,7 @@ import (
...
@@ -45,7 +45,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/sets
"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
serviceaccountadmission
"k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
serviceaccountadmission
"k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/union"
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/union"
...
@@ -170,7 +170,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
...
@@ -170,7 +170,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
}
}
// Wait for tokens to be deleted
// Wait for tokens to be deleted
tokensToCleanup
:=
util
.
NewStringSet
(
token1Name
,
token2Name
,
token3Name
)
tokensToCleanup
:=
sets
.
NewString
(
token1Name
,
token2Name
,
token3Name
)
err
=
wait
.
Poll
(
time
.
Second
,
10
*
time
.
Second
,
func
()
(
bool
,
error
)
{
err
=
wait
.
Poll
(
time
.
Second
,
10
*
time
.
Second
,
func
()
(
bool
,
error
)
{
// Get all secrets in the namespace
// Get all secrets in the namespace
secrets
,
err
:=
c
.
Secrets
(
ns
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
secrets
,
err
:=
c
.
Secrets
(
ns
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
...
...
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