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
4df68f03
Commit
4df68f03
authored
Sep 15, 2015
by
liguangbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change iff to if and only if to improve annotation readability
parent
db128ac0
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
44 additions
and
42 deletions
+44
-42
resource.go
contrib/mesos/pkg/scheduler/resource/resource.go
+6
-6
update-generated-swagger-docs.sh
hack/update-generated-swagger-docs.sh
+2
-2
types.go
pkg/api/v1/types.go
+2
-2
types_swagger_doc_generated.go
pkg/api/v1/types_swagger_doc_generated.go
+2
-2
types_swagger_doc_generated.go
pkg/apis/experimental/v1/types_swagger_doc_generated.go
+2
-2
expiration_cache.go
pkg/client/cache/expiration_cache.go
+1
-1
listers.go
pkg/client/cache/listers.go
+2
-1
conditions.go
pkg/client/unversioned/conditions.go
+2
-2
helper.go
pkg/client/unversioned/helper.go
+1
-1
aws.go
pkg/cloudprovider/providers/aws/aws.go
+2
-2
scheme.go
pkg/conversion/scheme.go
+2
-1
file.go
pkg/kubelet/config/file.go
+2
-2
manager.go
pkg/kubelet/dockertools/manager.go
+1
-1
matcher.go
pkg/registry/generic/matcher.go
+1
-1
etcd.go
pkg/registry/pod/etcd/etcd.go
+2
-2
etcd_util.go
pkg/storage/etcd/etcd_util.go
+5
-5
interfaces.go
pkg/storage/interfaces.go
+1
-1
atomic_value.go
pkg/util/atomic_value.go
+1
-1
set.go
pkg/util/sets/set.go
+4
-4
scheduler.go
plugin/pkg/scheduler/scheduler.go
+3
-3
No files found.
contrib/mesos/pkg/scheduler/resource/resource.go
View file @
4df68f03
...
@@ -42,8 +42,8 @@ func PodMemLimit(pod *api.Pod) MegaBytes {
...
@@ -42,8 +42,8 @@ func PodMemLimit(pod *api.Pod) MegaBytes {
}
}
// limitPodResource sets the given default resource limit for each container that
// limitPodResource sets the given default resource limit for each container that
// does not limit the given resource yet. limitPodResource returns true if
f at least one
// does not limit the given resource yet. limitPodResource returns true if
and only if
// container had no limit for that resource.
//
at least one
container had no limit for that resource.
func
limitPodResource
(
pod
*
api
.
Pod
,
resourceName
api
.
ResourceName
,
defaultLimit
resource
.
Quantity
)
bool
{
func
limitPodResource
(
pod
*
api
.
Pod
,
resourceName
api
.
ResourceName
,
defaultLimit
resource
.
Quantity
)
bool
{
unlimited
:=
false
unlimited
:=
false
for
j
:=
range
pod
.
Spec
.
Containers
{
for
j
:=
range
pod
.
Spec
.
Containers
{
...
@@ -79,16 +79,16 @@ func unlimitedCountainerNum(pod *api.Pod, resourceName api.ResourceName) int {
...
@@ -79,16 +79,16 @@ func unlimitedCountainerNum(pod *api.Pod, resourceName api.ResourceName) int {
}
}
// limitPodCPU sets DefaultContainerCPUs for the CPU limit of each container that
// limitPodCPU sets DefaultContainerCPUs for the CPU limit of each container that
// does not limit its CPU resource yet. limitPodCPU returns true if
f at least one
// does not limit its CPU resource yet. limitPodCPU returns true if
and only if
// container had no CPU limit set.
//
at least one
container had no CPU limit set.
func
LimitPodCPU
(
pod
*
api
.
Pod
,
defaultLimit
CPUShares
)
bool
{
func
LimitPodCPU
(
pod
*
api
.
Pod
,
defaultLimit
CPUShares
)
bool
{
defaultCPUQuantity
:=
resource
.
NewMilliQuantity
(
int64
(
float64
(
defaultLimit
)
*
1000.0
),
resource
.
DecimalSI
)
defaultCPUQuantity
:=
resource
.
NewMilliQuantity
(
int64
(
float64
(
defaultLimit
)
*
1000.0
),
resource
.
DecimalSI
)
return
limitPodResource
(
pod
,
api
.
ResourceCPU
,
*
defaultCPUQuantity
)
return
limitPodResource
(
pod
,
api
.
ResourceCPU
,
*
defaultCPUQuantity
)
}
}
// limitPodMem sets DefaultContainerMem for the memory limit of each container that
// limitPodMem sets DefaultContainerMem for the memory limit of each container that
// does not limit its memory resource yet. limitPodMem returns true if
f at least one
// does not limit its memory resource yet. limitPodMem returns true if
and only if
// container had no memory limit set.
//
at least one
container had no memory limit set.
func
LimitPodMem
(
pod
*
api
.
Pod
,
defaultLimit
MegaBytes
)
bool
{
func
LimitPodMem
(
pod
*
api
.
Pod
,
defaultLimit
MegaBytes
)
bool
{
defaultMemQuantity
:=
resource
.
NewQuantity
(
int64
(
float64
(
defaultLimit
)
*
1024.0
*
1024.0
),
resource
.
BinarySI
)
defaultMemQuantity
:=
resource
.
NewQuantity
(
int64
(
float64
(
defaultLimit
)
*
1024.0
*
1024.0
),
resource
.
BinarySI
)
return
limitPodResource
(
pod
,
api
.
ResourceMemory
,
*
defaultMemQuantity
)
return
limitPodResource
(
pod
,
api
.
ResourceMemory
,
*
defaultMemQuantity
)
...
...
hack/update-generated-swagger-docs.sh
View file @
4df68f03
...
@@ -37,8 +37,8 @@ function generate_version() {
...
@@ -37,8 +37,8 @@ function generate_version() {
// generate Swagger API documentation for its models. Please read this PR for more
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
//
// TODOs are ignored from the parser
. (e.g. TODO(andronat):... || TODO:...) if
f
// TODOs are ignored from the parser
(e.g. TODO(andronat):... || TODO:...) if and only i
f
// are on one line! For multiple line or blocks that you want to ignore use ---.
//
they
are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
// Any context after a --- is ignored.
//
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
...
...
pkg/api/v1/types.go
View file @
4df68f03
...
@@ -27,8 +27,8 @@ import (
...
@@ -27,8 +27,8 @@ import (
// generate Swagger API documentation for its models. Please read this PR for more
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
//
// TODOs are ignored from the parser
. (e.g. TODO(andronat):... || TODO:...) if
f
// TODOs are ignored from the parser
(e.g. TODO(andronat):... || TODO:...) if and only i
f
// are on one line! For multiple line or blocks that you want to ignore use ---.
//
they
are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored and not exported to the SwaggerAPI.
// Any context after a --- is ignored and not exported to the SwaggerAPI.
//
//
// The aforementioned methods can be generated by hack/update-generated-swagger-docs.sh
// The aforementioned methods can be generated by hack/update-generated-swagger-docs.sh
...
...
pkg/api/v1/types_swagger_doc_generated.go
View file @
4df68f03
...
@@ -20,8 +20,8 @@ package v1
...
@@ -20,8 +20,8 @@ package v1
// generate Swagger API documentation for its models. Please read this PR for more
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
//
// TODOs are ignored from the parser
. (e.g. TODO(andronat):... || TODO:...) if
f
// TODOs are ignored from the parser
(e.g. TODO(andronat):... || TODO:...) if and only i
f
// are on one line! For multiple line or blocks that you want to ignore use ---.
//
they
are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
// Any context after a --- is ignored.
//
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
...
...
pkg/apis/experimental/v1/types_swagger_doc_generated.go
View file @
4df68f03
...
@@ -20,8 +20,8 @@ package v1
...
@@ -20,8 +20,8 @@ package v1
// generate Swagger API documentation for its models. Please read this PR for more
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
//
// TODOs are ignored from the parser
. (e.g. TODO(andronat):... || TODO:...) if
f
// TODOs are ignored from the parser
(e.g. TODO(andronat):... || TODO:...) if and only i
f
// are on one line! For multiple line or blocks that you want to ignore use ---.
//
they
are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
// Any context after a --- is ignored.
//
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
...
...
pkg/client/cache/expiration_cache.go
View file @
4df68f03
...
@@ -73,7 +73,7 @@ func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bo
...
@@ -73,7 +73,7 @@ func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bo
return
nil
,
false
return
nil
,
false
}
}
// getOrExpire retrieves the object from the timestampedEntry iff it hasn't
// getOrExpire retrieves the object from the timestampedEntry if
and only i
f it hasn't
// already expired. It kicks-off a go routine to delete expired objects from
// already expired. It kicks-off a go routine to delete expired objects from
// the store and sets exists=false.
// the store and sets exists=false.
func
(
c
*
ExpirationCache
)
getOrExpire
(
key
string
)
(
interface
{},
bool
)
{
func
(
c
*
ExpirationCache
)
getOrExpire
(
key
string
)
(
interface
{},
bool
)
{
...
...
pkg/client/cache/listers.go
View file @
4df68f03
...
@@ -249,7 +249,8 @@ func (s *StoreToDaemonSetLister) List() (dss []experimental.DaemonSet, err error
...
@@ -249,7 +249,8 @@ func (s *StoreToDaemonSetLister) List() (dss []experimental.DaemonSet, err error
return
dss
,
nil
return
dss
,
nil
}
}
// GetPodDaemonSets returns a list of daemon sets managing a pod. Returns an error iff no matching daemon sets are found.
// GetPodDaemonSets returns a list of daemon sets managing a pod.
// Returns an error if and only if no matching daemon sets are found.
func
(
s
*
StoreToDaemonSetLister
)
GetPodDaemonSets
(
pod
*
api
.
Pod
)
(
daemonSets
[]
experimental
.
DaemonSet
,
err
error
)
{
func
(
s
*
StoreToDaemonSetLister
)
GetPodDaemonSets
(
pod
*
api
.
Pod
)
(
daemonSets
[]
experimental
.
DaemonSet
,
err
error
)
{
var
selector
labels
.
Selector
var
selector
labels
.
Selector
var
daemonSet
experimental
.
DaemonSet
var
daemonSet
experimental
.
DaemonSet
...
...
pkg/client/unversioned/conditions.go
View file @
4df68f03
...
@@ -21,8 +21,8 @@ import (
...
@@ -21,8 +21,8 @@ import (
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
)
)
// ControllerHasDesiredReplicas returns a condition that will be true if
f the desired replica count
// ControllerHasDesiredReplicas returns a condition that will be true if
and only if
// for a controller's ReplicaSelector equals the Replicas count.
//
the desired replica count
for a controller's ReplicaSelector equals the Replicas count.
func
ControllerHasDesiredReplicas
(
c
Interface
,
controller
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
func
ControllerHasDesiredReplicas
(
c
Interface
,
controller
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
// If we're given a controller where the status lags the spec, it either means that the controller is stale,
// If we're given a controller where the status lags the spec, it either means that the controller is stale,
...
...
pkg/client/unversioned/helper.go
View file @
4df68f03
...
@@ -508,7 +508,7 @@ func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL,
...
@@ -508,7 +508,7 @@ func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL,
return
hostURL
,
nil
return
hostURL
,
nil
}
}
// IsConfigTransportTLS returns true iff the provided config will result in a protected
// IsConfigTransportTLS returns true if
and only i
f the provided config will result in a protected
// connection to the server when it is passed to client.New() or client.RESTClientFor().
// connection to the server when it is passed to client.New() or client.RESTClientFor().
// Use to determine when to send credentials over the wire.
// Use to determine when to send credentials over the wire.
//
//
...
...
pkg/cloudprovider/providers/aws/aws.go
View file @
4df68f03
...
@@ -1413,7 +1413,7 @@ func isEqualIPPermission(l, r *ec2.IPPermission, compareGroupUserIDs bool) bool
...
@@ -1413,7 +1413,7 @@ func isEqualIPPermission(l, r *ec2.IPPermission, compareGroupUserIDs bool) bool
}
}
// Makes sure the security group includes the specified permissions
// Makes sure the security group includes the specified permissions
// Returns true iff changes were made
// Returns true if
and only i
f changes were made
// The security group must already exist
// The security group must already exist
func
(
s
*
AWSCloud
)
ensureSecurityGroupIngress
(
securityGroupId
string
,
addPermissions
[]
*
ec2
.
IPPermission
)
(
bool
,
error
)
{
func
(
s
*
AWSCloud
)
ensureSecurityGroupIngress
(
securityGroupId
string
,
addPermissions
[]
*
ec2
.
IPPermission
)
(
bool
,
error
)
{
group
,
err
:=
s
.
findSecurityGroup
(
securityGroupId
)
group
,
err
:=
s
.
findSecurityGroup
(
securityGroupId
)
...
@@ -1467,7 +1467,7 @@ func (s *AWSCloud) ensureSecurityGroupIngress(securityGroupId string, addPermiss
...
@@ -1467,7 +1467,7 @@ func (s *AWSCloud) ensureSecurityGroupIngress(securityGroupId string, addPermiss
}
}
// Makes sure the security group no longer includes the specified permissions
// Makes sure the security group no longer includes the specified permissions
// Returns true iff changes were made
// Returns true if
and only i
f changes were made
// If the security group no longer exists, will return (false, nil)
// If the security group no longer exists, will return (false, nil)
func
(
s
*
AWSCloud
)
removeSecurityGroupIngress
(
securityGroupId
string
,
removePermissions
[]
*
ec2
.
IPPermission
)
(
bool
,
error
)
{
func
(
s
*
AWSCloud
)
removeSecurityGroupIngress
(
securityGroupId
string
,
removePermissions
[]
*
ec2
.
IPPermission
)
(
bool
,
error
)
{
group
,
err
:=
s
.
findSecurityGroup
(
securityGroupId
)
group
,
err
:=
s
.
findSecurityGroup
(
securityGroupId
)
...
...
pkg/conversion/scheme.go
View file @
4df68f03
...
@@ -44,7 +44,8 @@ type Scheme struct {
...
@@ -44,7 +44,8 @@ type Scheme struct {
// deep copy behavior.
// deep copy behavior.
cloner
*
Cloner
cloner
*
Cloner
// Indent will cause the JSON output from Encode to be indented, iff it is true.
// Indent will cause the JSON output from Encode to be indented,
// if and only if it is true.
Indent
bool
Indent
bool
// InternalVersion is the default internal version. It is recommended that
// InternalVersion is the default internal version. It is recommended that
...
...
pkg/kubelet/config/file.go
View file @
4df68f03
...
@@ -92,8 +92,8 @@ func (s *sourceFile) extractFromPath() error {
...
@@ -92,8 +92,8 @@ func (s *sourceFile) extractFromPath() error {
return
nil
return
nil
}
}
// Get as many pod configs as we can from a directory.
Return an error if
f something
// Get as many pod configs as we can from a directory.
Return an error if and only i
f something
// prevented us from reading anything at all.
Do not return an error if only some files
// prevented us from reading anything at all. Do not return an error if only some files
// were problematic.
// were problematic.
func
(
s
*
sourceFile
)
extractFromDir
(
name
string
)
([]
*
api
.
Pod
,
error
)
{
func
(
s
*
sourceFile
)
extractFromDir
(
name
string
)
([]
*
api
.
Pod
,
error
)
{
dirents
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
name
,
"[^.]*"
))
dirents
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
name
,
"[^.]*"
))
...
...
pkg/kubelet/dockertools/manager.go
View file @
4df68f03
...
@@ -1532,7 +1532,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
...
@@ -1532,7 +1532,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
// Structure keeping information on changes that need to happen for a pod. The semantics is as follows:
// Structure keeping information on changes that need to happen for a pod. The semantics is as follows:
// - startInfraContainer is true if new Infra Containers have to be started and old one (if running) killed.
// - startInfraContainer is true if new Infra Containers have to be started and old one (if running) killed.
// Additionally if it is true then containersToKeep have to be empty
// Additionally if it is true then containersToKeep have to be empty
// - infraContainerId have to be set iff startInfraContainer is false. It stores dockerID of running Infra Container
// - infraContainerId have to be set if
and only i
f startInfraContainer is false. It stores dockerID of running Infra Container
// - containersToStart keeps indices of Specs of containers that have to be started.
// - containersToStart keeps indices of Specs of containers that have to be started.
// - containersToKeep stores mapping from dockerIDs of running containers to indices of their Specs for containers that
// - containersToKeep stores mapping from dockerIDs of running containers to indices of their Specs for containers that
// should be kept running. If startInfraContainer is false then it contains an entry for infraContainerId (mapped to -1).
// should be kept running. If startInfraContainer is false then it contains an entry for infraContainerId (mapped to -1).
...
...
pkg/registry/generic/matcher.go
View file @
4df68f03
...
@@ -47,7 +47,7 @@ func (s *SelectionPredicate) Matches(obj runtime.Object) (bool, error) {
...
@@ -47,7 +47,7 @@ func (s *SelectionPredicate) Matches(obj runtime.Object) (bool, error) {
return
s
.
Label
.
Matches
(
labels
)
&&
s
.
Field
.
Matches
(
fields
),
nil
return
s
.
Label
.
Matches
(
labels
)
&&
s
.
Field
.
Matches
(
fields
),
nil
}
}
// MatchesSingle will return (name, true) iff s.Field matches on the object's
// MatchesSingle will return (name, true) if
and only i
f s.Field matches on the object's
// name.
// name.
func
(
s
*
SelectionPredicate
)
MatchesSingle
()
(
string
,
bool
)
{
func
(
s
*
SelectionPredicate
)
MatchesSingle
()
(
string
,
bool
)
{
// TODO: should be namespace.name
// TODO: should be namespace.name
...
...
pkg/registry/pod/etcd/etcd.go
View file @
4df68f03
...
@@ -150,8 +150,8 @@ func (r *BindingREST) Create(ctx api.Context, obj runtime.Object) (out runtime.O
...
@@ -150,8 +150,8 @@ func (r *BindingREST) Create(ctx api.Context, obj runtime.Object) (out runtime.O
return
return
}
}
// setPodHostAndAnnotations sets the given pod's host to 'machine' if
f it was previously 'oldMachine' and merge
s
// setPodHostAndAnnotations sets the given pod's host to 'machine' if
and only if it wa
s
// the provided annotations with those of the pod.
//
previously 'oldMachine' and merges
the provided annotations with those of the pod.
// Returns the current state of the pod, or an error.
// Returns the current state of the pod, or an error.
func
(
r
*
BindingREST
)
setPodHostAndAnnotations
(
ctx
api
.
Context
,
podID
,
oldMachine
,
machine
string
,
annotations
map
[
string
]
string
)
(
finalPod
*
api
.
Pod
,
err
error
)
{
func
(
r
*
BindingREST
)
setPodHostAndAnnotations
(
ctx
api
.
Context
,
podID
,
oldMachine
,
machine
string
,
annotations
map
[
string
]
string
)
(
finalPod
*
api
.
Pod
,
err
error
)
{
podKey
,
err
:=
r
.
store
.
KeyFunc
(
ctx
,
podID
)
podKey
,
err
:=
r
.
store
.
KeyFunc
(
ctx
,
podID
)
...
...
pkg/storage/etcd/etcd_util.go
View file @
4df68f03
...
@@ -29,27 +29,27 @@ import (
...
@@ -29,27 +29,27 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
// IsEtcdNotFound returns true iff err is an etcd not found error.
// IsEtcdNotFound returns true if
and only i
f err is an etcd not found error.
func
IsEtcdNotFound
(
err
error
)
bool
{
func
IsEtcdNotFound
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeNotFound
)
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeNotFound
)
}
}
// IsEtcdNodeExist returns true iff err is an etcd node already exist error.
// IsEtcdNodeExist returns true if
and only i
f err is an etcd node already exist error.
func
IsEtcdNodeExist
(
err
error
)
bool
{
func
IsEtcdNodeExist
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeNodeExist
)
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeNodeExist
)
}
}
// IsEtcdTestFailed returns true iff err is an etcd write conflict.
// IsEtcdTestFailed returns true if
and only i
f err is an etcd write conflict.
func
IsEtcdTestFailed
(
err
error
)
bool
{
func
IsEtcdTestFailed
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeTestFailed
)
return
isEtcdErrorNum
(
err
,
tools
.
EtcdErrorCodeTestFailed
)
}
}
// IsEtcdWatchStoppedByUser returns true iff err is a client triggered stop.
// IsEtcdWatchStoppedByUser returns true if
and only i
f err is a client triggered stop.
func
IsEtcdWatchStoppedByUser
(
err
error
)
bool
{
func
IsEtcdWatchStoppedByUser
(
err
error
)
bool
{
return
goetcd
.
ErrWatchStoppedByUser
==
err
return
goetcd
.
ErrWatchStoppedByUser
==
err
}
}
// isEtcdErrorNum returns true iff err is an etcd error, whose errorCode matches errorCode
// isEtcdErrorNum returns true if
and only i
f err is an etcd error, whose errorCode matches errorCode
func
isEtcdErrorNum
(
err
error
,
errorCode
int
)
bool
{
func
isEtcdErrorNum
(
err
error
,
errorCode
int
)
bool
{
etcdError
,
ok
:=
err
.
(
*
goetcd
.
EtcdError
)
etcdError
,
ok
:=
err
.
(
*
goetcd
.
EtcdError
)
return
ok
&&
etcdError
!=
nil
&&
etcdError
.
ErrorCode
==
errorCode
return
ok
&&
etcdError
!=
nil
&&
etcdError
.
ErrorCode
==
errorCode
...
...
pkg/storage/interfaces.go
View file @
4df68f03
...
@@ -55,7 +55,7 @@ type ResponseMeta struct {
...
@@ -55,7 +55,7 @@ type ResponseMeta struct {
}
}
// FilterFunc is a predicate which takes an API object and returns true
// FilterFunc is a predicate which takes an API object and returns true
// iff the object should remain in the set.
// if
and only i
f the object should remain in the set.
type
FilterFunc
func
(
obj
runtime
.
Object
)
bool
type
FilterFunc
func
(
obj
runtime
.
Object
)
bool
// Everything is a FilterFunc which accepts all objects.
// Everything is a FilterFunc which accepts all objects.
...
...
pkg/util/atomic_value.go
View file @
4df68f03
...
@@ -46,7 +46,7 @@ func (at *AtomicValue) Load() interface{} {
...
@@ -46,7 +46,7 @@ func (at *AtomicValue) Load() interface{} {
// for some quantity.
// for some quantity.
type
HighWaterMark
int64
type
HighWaterMark
int64
// Check returns true iff 'current' is the highest value ever seen.
// Check returns true if
and only i
f 'current' is the highest value ever seen.
func
(
hwm
*
HighWaterMark
)
Check
(
current
int64
)
bool
{
func
(
hwm
*
HighWaterMark
)
Check
(
current
int64
)
bool
{
for
{
for
{
old
:=
atomic
.
LoadInt64
((
*
int64
)(
hwm
))
old
:=
atomic
.
LoadInt64
((
*
int64
)(
hwm
))
...
...
pkg/util/sets/set.go
View file @
4df68f03
...
@@ -61,13 +61,13 @@ func (s String) Delete(items ...string) {
...
@@ -61,13 +61,13 @@ func (s String) Delete(items ...string) {
}
}
}
}
// Has returns true iff item is contained in the set.
// Has returns true if
and only i
f item is contained in the set.
func
(
s
String
)
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 if
and only i
f all items are contained in the set.
func
(
s
String
)
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
)
{
...
@@ -121,7 +121,7 @@ func (s1 String) Union(s2 String) String {
...
@@ -121,7 +121,7 @@ func (s1 String) Union(s2 String) String {
return
result
return
result
}
}
// IsSuperset returns true iff s1 is a superset of s2.
// IsSuperset returns true if
and only i
f s1 is a superset of s2.
func
(
s1
String
)
IsSuperset
(
s2
String
)
bool
{
func
(
s1
String
)
IsSuperset
(
s2
String
)
bool
{
for
item
:=
range
s2
{
for
item
:=
range
s2
{
if
!
s1
.
Has
(
item
)
{
if
!
s1
.
Has
(
item
)
{
...
@@ -131,7 +131,7 @@ func (s1 String) IsSuperset(s2 String) bool {
...
@@ -131,7 +131,7 @@ func (s1 String) IsSuperset(s2 String) bool {
return
true
return
true
}
}
// Equal returns true iff s1 is equal (as a set) to s2.
// Equal returns true if
and only i
f 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
)
Equal
(
s2
String
)
bool
{
func
(
s1
String
)
Equal
(
s2
String
)
bool
{
...
...
plugin/pkg/scheduler/scheduler.go
View file @
4df68f03
...
@@ -56,7 +56,7 @@ type SystemModeler interface {
...
@@ -56,7 +56,7 @@ type SystemModeler interface {
ForgetPodByKey
(
key
string
)
ForgetPodByKey
(
key
string
)
// For serializing calls to Assume/ForgetPod: imagine you want to add
// For serializing calls to Assume/ForgetPod: imagine you want to add
// a pod iff a bind succeeds, but also remove a pod if it is deleted.
// a pod if
and only i
f a bind succeeds, but also remove a pod if it is deleted.
// TODO: if SystemModeler begins modeling things other than pods, this
// TODO: if SystemModeler begins modeling things other than pods, this
// should probably be parameterized or specialized for pods.
// should probably be parameterized or specialized for pods.
LockedAction
(
f
func
())
LockedAction
(
f
func
())
...
@@ -137,8 +137,8 @@ func (s *Scheduler) scheduleOne() {
...
@@ -137,8 +137,8 @@ func (s *Scheduler) scheduleOne() {
},
},
}
}
// We want to add the pod to the model if
f the bind succeeds, but we don't want to race
// We want to add the pod to the model if
and only if the bind succeeds,
// with any deletions, which happen asynchronously.
//
but we don't want to race
with any deletions, which happen asynchronously.
s
.
config
.
Modeler
.
LockedAction
(
func
()
{
s
.
config
.
Modeler
.
LockedAction
(
func
()
{
bindingStart
:=
time
.
Now
()
bindingStart
:=
time
.
Now
()
err
:=
s
.
config
.
Binder
.
Bind
(
b
)
err
:=
s
.
config
.
Binder
.
Bind
(
b
)
...
...
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