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
7a7f31ea
Commit
7a7f31ea
authored
Oct 25, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move daemonset to generalized label selector
parent
abbed4f7
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
91 additions
and
64 deletions
+91
-64
types.go
pkg/apis/extensions/types.go
+1
-1
defaults.go
pkg/apis/extensions/v1beta1/defaults.go
+4
-2
types.go
pkg/apis/extensions/v1beta1/types.go
+1
-1
validation.go
pkg/apis/extensions/validation/validation.go
+16
-17
validation_test.go
pkg/apis/extensions/validation/validation_test.go
+26
-26
listers.go
pkg/client/cache/listers.go
+5
-1
listers_test.go
pkg/client/cache/listers_test.go
+3
-3
controller.go
pkg/controller/daemon/controller.go
+5
-1
controller_test.go
pkg/controller/daemon/controller_test.go
+1
-1
describe.go
pkg/kubectl/describe.go
+19
-6
resource_printer.go
pkg/kubectl/resource_printer.go
+6
-1
etcd_test.go
pkg/registry/daemonset/etcd/etcd_test.go
+3
-3
daemon_set.go
test/e2e/daemon_set.go
+1
-1
No files found.
pkg/apis/extensions/types.go
View file @
7a7f31ea
...
@@ -298,7 +298,7 @@ type DaemonSetSpec struct {
...
@@ -298,7 +298,7 @@ type DaemonSetSpec struct {
// Must match in order to be controlled.
// Must match in order to be controlled.
// If empty, defaulted to labels on Pod template.
// If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector
map
[
string
]
string
`json:"selector,omitempty"`
Selector
*
PodSelector
`json:"selector,omitempty"`
// Template is the object that describes the pod that will be created.
// Template is the object that describes the pod that will be created.
// The DaemonSet will create exactly one copy of this pod on every node
// The DaemonSet will create exactly one copy of this pod on every node
...
...
pkg/apis/extensions/v1beta1/defaults.go
View file @
7a7f31ea
...
@@ -35,8 +35,10 @@ func addDefaultingFuncs() {
...
@@ -35,8 +35,10 @@ func addDefaultingFuncs() {
}
}
// TODO: support templates defined elsewhere when we support them in the API
// TODO: support templates defined elsewhere when we support them in the API
if
labels
!=
nil
{
if
labels
!=
nil
{
if
len
(
obj
.
Spec
.
Selector
)
==
0
{
if
obj
.
Spec
.
Selector
==
nil
{
obj
.
Spec
.
Selector
=
labels
obj
.
Spec
.
Selector
=
&
PodSelector
{
MatchLabels
:
labels
,
}
}
}
if
len
(
obj
.
Labels
)
==
0
{
if
len
(
obj
.
Labels
)
==
0
{
obj
.
Labels
=
labels
obj
.
Labels
=
labels
...
...
pkg/apis/extensions/v1beta1/types.go
View file @
7a7f31ea
...
@@ -296,7 +296,7 @@ type DaemonSetSpec struct {
...
@@ -296,7 +296,7 @@ type DaemonSetSpec struct {
// Must match in order to be controlled.
// Must match in order to be controlled.
// If empty, defaulted to labels on Pod template.
// If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector
map
[
string
]
string
`json:"selector,omitempty"`
Selector
*
PodSelector
`json:"selector,omitempty"`
// Template is the object that describes the pod that will be created.
// Template is the object that describes the pod that will be created.
// The DaemonSet will create exactly one copy of this pod on every node
// The DaemonSet will create exactly one copy of this pod on every node
...
...
pkg/apis/extensions/validation/validation.go
View file @
7a7f31ea
...
@@ -185,26 +185,26 @@ func ValidateDaemonSetTemplateUpdate(podTemplate, oldPodTemplate *api.PodTemplat
...
@@ -185,26 +185,26 @@ func ValidateDaemonSetTemplateUpdate(podTemplate, oldPodTemplate *api.PodTemplat
func
ValidateDaemonSetSpec
(
spec
*
extensions
.
DaemonSetSpec
)
errs
.
ValidationErrorList
{
func
ValidateDaemonSetSpec
(
spec
*
extensions
.
DaemonSetSpec
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
selector
:=
labels
.
Set
(
spec
.
Selector
)
.
AsSelector
()
allErrs
=
append
(
allErrs
,
ValidatePodSelector
(
spec
.
Selector
)
...
)
if
selector
.
Empty
()
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"selector"
))
}
if
spec
.
Template
==
nil
{
if
spec
.
Template
==
nil
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"template"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"template"
))
}
else
{
return
allErrs
labels
:=
labels
.
Set
(
spec
.
Template
.
Labels
)
}
if
!
selector
.
Matches
(
labels
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"template.metadata.labels"
,
spec
.
Template
.
Labels
,
"selector does not match template"
))
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
spec
.
Selector
)
}
if
err
==
nil
&&
!
selector
.
Matches
(
labels
.
Set
(
spec
.
Template
.
Labels
))
{
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidatePodTemplateSpec
(
spec
.
Template
)
.
Prefix
(
"template"
)
...
)
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"template.metadata.labels"
,
spec
.
Template
.
Labels
,
"selector does not match template"
))
// Daemons typically run on more than one node, so mark Read-Write persistent disks as invalid.
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateReadOnlyPersistentDisks
(
spec
.
Template
.
Spec
.
Volumes
)
.
Prefix
(
"template.spec.volumes"
)
...
)
// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
if
spec
.
Template
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyAlways
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldValueNotSupported
(
"template.spec.restartPolicy"
,
spec
.
Template
.
Spec
.
RestartPolicy
,
[]
string
{
string
(
api
.
RestartPolicyAlways
)}))
}
}
}
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidatePodTemplateSpec
(
spec
.
Template
)
.
Prefix
(
"template"
)
...
)
// Daemons typically run on more than one node, so mark Read-Write persistent disks as invalid.
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateReadOnlyPersistentDisks
(
spec
.
Template
.
Spec
.
Volumes
)
.
Prefix
(
"template.spec.volumes"
)
...
)
// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
if
spec
.
Template
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyAlways
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldValueNotSupported
(
"template.spec.restartPolicy"
,
spec
.
Template
.
Spec
.
RestartPolicy
,
[]
string
{
string
(
api
.
RestartPolicyAlways
)}))
}
return
allErrs
return
allErrs
}
}
...
@@ -226,7 +226,6 @@ func ValidatePositiveIntOrPercent(intOrPercent util.IntOrString, fieldName strin
...
@@ -226,7 +226,6 @@ func ValidatePositiveIntOrPercent(intOrPercent util.IntOrString, fieldName strin
if
!
validation
.
IsValidPercent
(
intOrPercent
.
StrVal
)
{
if
!
validation
.
IsValidPercent
(
intOrPercent
.
StrVal
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
fieldName
,
intOrPercent
,
"value should be int(5) or percentage(5%)"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
fieldName
,
intOrPercent
,
"value should be int(5) or percentage(5%)"
))
}
}
}
else
if
intOrPercent
.
Kind
==
util
.
IntstrInt
{
}
else
if
intOrPercent
.
Kind
==
util
.
IntstrInt
{
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidatePositiveField
(
int64
(
intOrPercent
.
IntVal
),
fieldName
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidatePositiveField
(
int64
(
intOrPercent
.
IntVal
),
fieldName
)
...
)
}
}
...
...
pkg/apis/extensions/validation/validation_test.go
View file @
7a7f31ea
...
@@ -369,14 +369,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -369,14 +369,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
...
@@ -385,14 +385,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -385,14 +385,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector2
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector2
}
,
Template
:
&
validPodTemplateAbc2
.
Template
,
Template
:
&
validPodTemplateAbc2
.
Template
,
},
},
},
},
...
@@ -401,14 +401,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -401,14 +401,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateNodeSelector
.
Template
,
Template
:
&
validPodTemplateNodeSelector
.
Template
,
},
},
},
},
...
@@ -426,14 +426,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -426,14 +426,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
...
@@ -442,14 +442,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -442,14 +442,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
invalidSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
invalidSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
...
@@ -458,14 +458,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -458,14 +458,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
invalidPodTemplate
.
Template
,
Template
:
&
invalidPodTemplate
.
Template
,
},
},
},
},
...
@@ -474,14 +474,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -474,14 +474,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateDef
.
Template
,
Template
:
&
validPodTemplateDef
.
Template
,
},
},
},
},
...
@@ -490,14 +490,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
...
@@ -490,14 +490,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old
:
extensions
.
DaemonSet
{
old
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplateAbc
.
Template
,
Template
:
&
validPodTemplateAbc
.
Template
,
},
},
},
},
update
:
extensions
.
DaemonSet
{
update
:
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
readWriteVolumePodTemplate
.
Template
,
Template
:
&
readWriteVolumePodTemplate
.
Template
,
},
},
},
},
...
@@ -540,14 +540,14 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -540,14 +540,14 @@ func TestValidateDaemonSet(t *testing.T) {
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc-123"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc-123"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
...
@@ -562,14 +562,14 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -562,14 +562,14 @@ func TestValidateDaemonSet(t *testing.T) {
"zero-length ID"
:
{
"zero-length ID"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
""
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
"missing-namespace"
:
{
"missing-namespace"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc-123"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc-123"
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
...
@@ -582,14 +582,14 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -582,14 +582,14 @@ func TestValidateDaemonSet(t *testing.T) {
"selector_doesnt_match"
:
{
"selector_doesnt_match"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}
},
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
"invalid manifest"
:
{
"invalid manifest"
:
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
},
},
},
},
"invalid_label"
:
{
"invalid_label"
:
{
...
@@ -601,7 +601,7 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -601,7 +601,7 @@ func TestValidateDaemonSet(t *testing.T) {
},
},
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
...
@@ -626,7 +626,7 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -626,7 +626,7 @@ func TestValidateDaemonSet(t *testing.T) {
},
},
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
validPodTemplate
.
Template
,
Template
:
&
validPodTemplate
.
Template
,
},
},
},
},
...
@@ -636,7 +636,7 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -636,7 +636,7 @@ func TestValidateDaemonSet(t *testing.T) {
Namespace
:
api
.
NamespaceDefault
,
Namespace
:
api
.
NamespaceDefault
,
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
api
.
PodTemplateSpec
{
Template
:
&
api
.
PodTemplateSpec
{
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
RestartPolicy
:
api
.
RestartPolicyOnFailure
,
RestartPolicy
:
api
.
RestartPolicyOnFailure
,
...
@@ -655,7 +655,7 @@ func TestValidateDaemonSet(t *testing.T) {
...
@@ -655,7 +655,7 @@ func TestValidateDaemonSet(t *testing.T) {
Namespace
:
api
.
NamespaceDefault
,
Namespace
:
api
.
NamespaceDefault
,
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
validSelector
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
validSelector
}
,
Template
:
&
api
.
PodTemplateSpec
{
Template
:
&
api
.
PodTemplateSpec
{
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
RestartPolicy
:
api
.
RestartPolicyNever
,
RestartPolicy
:
api
.
RestartPolicyNever
,
...
...
pkg/client/cache/listers.go
View file @
7a7f31ea
...
@@ -247,7 +247,11 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex
...
@@ -247,7 +247,11 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex
if
daemonSet
.
Namespace
!=
pod
.
Namespace
{
if
daemonSet
.
Namespace
!=
pod
.
Namespace
{
continue
continue
}
}
selector
=
labels
.
Set
(
daemonSet
.
Spec
.
Selector
)
.
AsSelector
()
selector
,
err
=
extensions
.
PodSelectorAsSelector
(
daemonSet
.
Spec
.
Selector
)
if
err
!=
nil
{
// this should not happen if the DaemonSet passed validation
return
nil
,
err
}
// If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything.
// If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything.
if
selector
.
Empty
()
||
!
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
if
selector
.
Empty
()
||
!
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
...
...
pkg/client/cache/listers_test.go
View file @
7a7f31ea
...
@@ -272,7 +272,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -272,7 +272,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
,
Namespace
:
"ns"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
,
Namespace
:
"ns"
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"baz"
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"baz"
}
},
},
},
},
},
},
},
...
@@ -311,13 +311,13 @@ func TestStoreToDaemonSetLister(t *testing.T) {
...
@@ -311,13 +311,13 @@ func TestStoreToDaemonSetLister(t *testing.T) {
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}
},
},
},
},
},
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"ns"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"ns"
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}
},
},
},
},
},
},
},
...
...
pkg/controller/daemon/controller.go
View file @
7a7f31ea
...
@@ -323,7 +323,11 @@ func (dsc *DaemonSetsController) updateNode(old, cur interface{}) {
...
@@ -323,7 +323,11 @@ func (dsc *DaemonSetsController) updateNode(old, cur interface{}) {
// getNodesToDaemonSetPods returns a map from nodes to daemon pods (corresponding to ds) running on the nodes.
// getNodesToDaemonSetPods returns a map from nodes to daemon pods (corresponding to ds) running on the nodes.
func
(
dsc
*
DaemonSetsController
)
getNodesToDaemonPods
(
ds
*
extensions
.
DaemonSet
)
(
map
[
string
][]
*
api
.
Pod
,
error
)
{
func
(
dsc
*
DaemonSetsController
)
getNodesToDaemonPods
(
ds
*
extensions
.
DaemonSet
)
(
map
[
string
][]
*
api
.
Pod
,
error
)
{
nodeToDaemonPods
:=
make
(
map
[
string
][]
*
api
.
Pod
)
nodeToDaemonPods
:=
make
(
map
[
string
][]
*
api
.
Pod
)
daemonPods
,
err
:=
dsc
.
podStore
.
Pods
(
ds
.
Namespace
)
.
List
(
labels
.
Set
(
ds
.
Spec
.
Selector
)
.
AsSelector
())
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
ds
.
Spec
.
Selector
)
if
err
!=
nil
{
return
nil
,
err
}
daemonPods
,
err
:=
dsc
.
podStore
.
Pods
(
ds
.
Namespace
)
.
List
(
selector
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nodeToDaemonPods
,
err
return
nodeToDaemonPods
,
err
}
}
...
...
pkg/controller/daemon/controller_test.go
View file @
7a7f31ea
...
@@ -55,7 +55,7 @@ func newDaemonSet(name string) *extensions.DaemonSet {
...
@@ -55,7 +55,7 @@ func newDaemonSet(name string) *extensions.DaemonSet {
Namespace
:
api
.
NamespaceDefault
,
Namespace
:
api
.
NamespaceDefault
,
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
simpleDaemonSetLabel
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
simpleDaemonSetLabel
}
,
Template
:
&
api
.
PodTemplateSpec
{
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
simpleDaemonSetLabel
,
Labels
:
simpleDaemonSetLabel
,
...
...
pkg/kubectl/describe.go
View file @
7a7f31ea
...
@@ -845,7 +845,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
...
@@ -845,7 +845,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
return
""
,
err
return
""
,
err
}
}
running
,
waiting
,
succeeded
,
failed
,
err
:=
getPodStatusForController
(
pc
,
controller
.
Spec
.
Selector
)
running
,
waiting
,
succeeded
,
failed
,
err
:=
getPodStatusForController
(
pc
,
labels
.
SelectorFromSet
(
controller
.
Spec
.
Selector
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -927,7 +927,11 @@ func (d *DaemonSetDescriber) Describe(namespace, name string) (string, error) {
...
@@ -927,7 +927,11 @@ func (d *DaemonSetDescriber) Describe(namespace, name string) (string, error) {
return
""
,
err
return
""
,
err
}
}
running
,
waiting
,
succeeded
,
failed
,
err
:=
getPodStatusForController
(
pc
,
daemon
.
Spec
.
Selector
)
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
daemon
.
Spec
.
Selector
)
if
err
!=
nil
{
return
""
,
err
}
running
,
waiting
,
succeeded
,
failed
,
err
:=
getPodStatusForController
(
pc
,
selector
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -945,7 +949,12 @@ func describeDaemonSet(daemon *extensions.DaemonSet, events *api.EventList, runn
...
@@ -945,7 +949,12 @@ func describeDaemonSet(daemon *extensions.DaemonSet, events *api.EventList, runn
}
else
{
}
else
{
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
"<no template>"
)
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
"<no template>"
)
}
}
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
labels
.
FormatLabels
(
daemon
.
Spec
.
Selector
))
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
daemon
.
Spec
.
Selector
)
if
err
!=
nil
{
// this shouldn't happen if PodSelector passed validation
return
err
}
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
selector
)
fmt
.
Fprintf
(
out
,
"Node-Selector:
\t
%s
\n
"
,
labels
.
FormatLabels
(
daemon
.
Spec
.
Template
.
Spec
.
NodeSelector
))
fmt
.
Fprintf
(
out
,
"Node-Selector:
\t
%s
\n
"
,
labels
.
FormatLabels
(
daemon
.
Spec
.
Template
.
Spec
.
NodeSelector
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
daemon
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
daemon
.
Labels
))
fmt
.
Fprintf
(
out
,
"Desired Number of Nodes Scheduled: %d
\n
"
,
daemon
.
Status
.
DesiredNumberScheduled
)
fmt
.
Fprintf
(
out
,
"Desired Number of Nodes Scheduled: %d
\n
"
,
daemon
.
Status
.
DesiredNumberScheduled
)
...
@@ -1575,7 +1584,11 @@ func getDaemonSetsForLabels(c client.DaemonSetInterface, labelsToMatch labels.La
...
@@ -1575,7 +1584,11 @@ func getDaemonSetsForLabels(c client.DaemonSetInterface, labelsToMatch labels.La
// Find the ones that match labelsToMatch.
// Find the ones that match labelsToMatch.
var
matchingDaemonSets
[]
extensions
.
DaemonSet
var
matchingDaemonSets
[]
extensions
.
DaemonSet
for
_
,
ds
:=
range
dss
.
Items
{
for
_
,
ds
:=
range
dss
.
Items
{
selector
:=
labels
.
SelectorFromSet
(
ds
.
Spec
.
Selector
)
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
ds
.
Spec
.
Selector
)
if
err
!=
nil
{
// this should never happen if the DaemonSet passed validation
return
nil
,
err
}
if
selector
.
Matches
(
labelsToMatch
)
{
if
selector
.
Matches
(
labelsToMatch
)
{
matchingDaemonSets
=
append
(
matchingDaemonSets
,
ds
)
matchingDaemonSets
=
append
(
matchingDaemonSets
,
ds
)
}
}
...
@@ -1620,8 +1633,8 @@ func printReplicationControllersByLabels(matchingRCs []*api.ReplicationControlle
...
@@ -1620,8 +1633,8 @@ func printReplicationControllersByLabels(matchingRCs []*api.ReplicationControlle
return
list
return
list
}
}
func
getPodStatusForController
(
c
client
.
PodInterface
,
selector
map
[
string
]
string
)
(
running
,
waiting
,
succeeded
,
failed
int
,
err
error
)
{
func
getPodStatusForController
(
c
client
.
PodInterface
,
selector
labels
.
Selector
)
(
running
,
waiting
,
succeeded
,
failed
int
,
err
error
)
{
rcPods
,
err
:=
c
.
List
(
labels
.
SelectorFromSet
(
selector
)
,
fields
.
Everything
())
rcPods
,
err
:=
c
.
List
(
selector
,
fields
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
...
pkg/kubectl/resource_printer.go
View file @
7a7f31ea
...
@@ -931,11 +931,16 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, withNamespace bool, w
...
@@ -931,11 +931,16 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, withNamespace bool, w
return
err
return
err
}
}
}
}
selector
,
err
:=
extensions
.
PodSelectorAsSelector
(
ds
.
Spec
.
Selector
)
if
err
!=
nil
{
// this shouldn't happen if PodSelector passed validation
return
err
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s"
,
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s"
,
name
,
name
,
firstContainer
.
Name
,
firstContainer
.
Name
,
firstContainer
.
Image
,
firstContainer
.
Image
,
labels
.
FormatLabels
(
ds
.
Spec
.
Selector
)
,
selector
,
labels
.
FormatLabels
(
ds
.
Spec
.
Template
.
Spec
.
NodeSelector
),
labels
.
FormatLabels
(
ds
.
Spec
.
Template
.
Spec
.
NodeSelector
),
);
err
!=
nil
{
);
err
!=
nil
{
return
err
return
err
...
...
pkg/registry/daemonset/etcd/etcd_test.go
View file @
7a7f31ea
...
@@ -42,7 +42,7 @@ func newValidDaemonSet() *extensions.DaemonSet {
...
@@ -42,7 +42,7 @@ func newValidDaemonSet() *extensions.DaemonSet {
Namespace
:
api
.
NamespaceDefault
,
Namespace
:
api
.
NamespaceDefault
,
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
"a"
:
"b"
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{
"a"
:
"b"
}
},
Template
:
&
api
.
PodTemplateSpec
{
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
...
@@ -76,7 +76,7 @@ func TestCreate(t *testing.T) {
...
@@ -76,7 +76,7 @@ func TestCreate(t *testing.T) {
// invalid (invalid selector)
// invalid (invalid selector)
&
extensions
.
DaemonSet
{
&
extensions
.
DaemonSet
{
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
map
[
string
]
string
{
},
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{}
},
Template
:
validDaemonSet
.
Spec
.
Template
,
Template
:
validDaemonSet
.
Spec
.
Template
,
},
},
},
},
...
@@ -113,7 +113,7 @@ func TestUpdate(t *testing.T) {
...
@@ -113,7 +113,7 @@ func TestUpdate(t *testing.T) {
},
},
func
(
obj
runtime
.
Object
)
runtime
.
Object
{
func
(
obj
runtime
.
Object
)
runtime
.
Object
{
object
:=
obj
.
(
*
extensions
.
DaemonSet
)
object
:=
obj
.
(
*
extensions
.
DaemonSet
)
object
.
Spec
.
Selector
=
map
[
string
]
string
{
}
object
.
Spec
.
Selector
=
&
extensions
.
PodSelector
{
MatchLabels
:
map
[
string
]
string
{}
}
return
object
return
object
},
},
)
)
...
...
test/e2e/daemon_set.go
View file @
7a7f31ea
...
@@ -134,7 +134,7 @@ var _ = Describe("Daemon set", func() {
...
@@ -134,7 +134,7 @@ var _ = Describe("Daemon set", func() {
Name
:
dsName
,
Name
:
dsName
,
},
},
Spec
:
extensions
.
DaemonSetSpec
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
complexLabel
,
Selector
:
&
extensions
.
PodSelector
{
MatchLabels
:
complexLabel
}
,
Template
:
&
api
.
PodTemplateSpec
{
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
complexLabel
,
Labels
:
complexLabel
,
...
...
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