Skip to content

Commit 8460e39

Browse files
committed
move daemon controller to the experimental api
1 parent 650bf71 commit 8460e39

30 files changed

+840
-792
lines changed

pkg/api/helpers.go

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ var standardResources = util.NewStringSet(
8383
string(ResourceQuotas),
8484
string(ResourceServices),
8585
string(ResourceReplicationControllers),
86-
string(ResourceDaemon),
8786
string(ResourceSecrets),
8887
string(ResourcePersistentVolumeClaims),
8988
string(ResourceStorage))

pkg/api/latest/latest.go

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func init() {
9595
"PodExecOptions",
9696
"PodAttachOptions",
9797
"PodProxyOptions",
98-
"Daemon",
9998
"ThirdPartyResource",
10099
"ThirdPartyResourceData",
101100
"ThirdPartyResourceList")

pkg/api/register.go

-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ func init() {
3232
&PodTemplateList{},
3333
&ReplicationControllerList{},
3434
&ReplicationController{},
35-
&DaemonList{},
36-
&Daemon{},
3735
&ServiceList{},
3836
&Service{},
3937
&NodeList{},
@@ -85,8 +83,6 @@ func (*PodTemplate) IsAnAPIObject() {}
8583
func (*PodTemplateList) IsAnAPIObject() {}
8684
func (*ReplicationController) IsAnAPIObject() {}
8785
func (*ReplicationControllerList) IsAnAPIObject() {}
88-
func (*Daemon) IsAnAPIObject() {}
89-
func (*DaemonList) IsAnAPIObject() {}
9086
func (*Service) IsAnAPIObject() {}
9187
func (*ServiceList) IsAnAPIObject() {}
9288
func (*Endpoints) IsAnAPIObject() {}

pkg/api/testing/fuzzer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
120120
c.FuzzNoCustom(j) // fuzz self without calling this function again
121121
//j.TemplateRef = nil // this is required for round trip
122122
},
123-
func(j *api.DaemonSpec, c fuzz.Continue) {
123+
func(j *expapi.DaemonSpec, c fuzz.Continue) {
124124
c.FuzzNoCustom(j) // fuzz self without calling this function again
125125
},
126126
func(j *api.List, c fuzz.Continue) {

pkg/api/types.go

-50
Original file line numberDiff line numberDiff line change
@@ -1058,54 +1058,6 @@ type ReplicationControllerList struct {
10581058
Items []ReplicationController `json:"items"`
10591059
}
10601060

1061-
// DaemonSpec is the specification of a daemon.
1062-
type DaemonSpec struct {
1063-
// Selector is a label query over pods that are managed by the daemon.
1064-
Selector map[string]string `json:"selector"`
1065-
1066-
// Template is the object that describes the pod that will be created.
1067-
// The Daemon will create exactly one copy of this pod on every node
1068-
// that matches the template's node selector (or on every node if no node
1069-
// selector is specified).
1070-
Template *PodTemplateSpec `json:"template,omitempty"`
1071-
}
1072-
1073-
// DaemonStatus represents the current status of a daemon.
1074-
type DaemonStatus struct {
1075-
// CurrentNumberScheduled is the number of nodes that are running exactly 1 copy of the
1076-
// daemon and are supposed to run the daemon.
1077-
CurrentNumberScheduled int `json:"currentNumberScheduled"`
1078-
1079-
// NumberMisscheduled is the number of nodes that are running the daemon, but are
1080-
// not supposed to run the daemon.
1081-
NumberMisscheduled int `json:"numberMisscheduled"`
1082-
1083-
// DesiredNumberScheduled is the total number of nodes that should be running the daemon
1084-
// (including nodes correctly running the daemon).
1085-
DesiredNumberScheduled int `json:"desiredNumberScheduled"`
1086-
}
1087-
1088-
// Daemon represents the configuration of a daemon.
1089-
type Daemon struct {
1090-
TypeMeta `json:",inline"`
1091-
ObjectMeta `json:"metadata,omitempty"`
1092-
1093-
// Spec defines the desired behavior of this daemon.
1094-
Spec DaemonSpec `json:"spec,omitempty"`
1095-
1096-
// Status is the current status of this daemon. This data may be
1097-
// out of date by some window of time.
1098-
Status DaemonStatus `json:"status,omitempty"`
1099-
}
1100-
1101-
// DaemonList is a collection of daemon.
1102-
type DaemonList struct {
1103-
TypeMeta `json:",inline"`
1104-
ListMeta `json:"metadata,omitempty"`
1105-
1106-
Items []Daemon `json:"items"`
1107-
}
1108-
11091061
const (
11101062
// ClusterIPNone - do not assign a cluster IP
11111063
// no proxying required and no environment variables should be created for pods
@@ -1978,8 +1930,6 @@ const (
19781930
ResourceServices ResourceName = "services"
19791931
// ReplicationControllers, number
19801932
ResourceReplicationControllers ResourceName = "replicationcontrollers"
1981-
// Daemon, number
1982-
ResourceDaemon ResourceName = "daemon"
19831933
// ResourceQuotas, number
19841934
ResourceQuotas ResourceName = "resourcequotas"
19851935
// ResourceSecrets, number

pkg/api/v1/defaults.go

-15
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,6 @@ func addDefaultingFuncs() {
4444
*obj.Spec.Replicas = 1
4545
}
4646
},
47-
func(obj *Daemon) {
48-
var labels map[string]string
49-
if obj.Spec.Template != nil {
50-
labels = obj.Spec.Template.Labels
51-
}
52-
// TODO: support templates defined elsewhere when we support them in the API
53-
if labels != nil {
54-
if len(obj.Spec.Selector) == 0 {
55-
obj.Spec.Selector = labels
56-
}
57-
if len(obj.Labels) == 0 {
58-
obj.Labels = labels
59-
}
60-
}
61-
},
6247
func(obj *Volume) {
6348
if util.AllPtrFieldsNil(&obj.VolumeSource) {
6449
obj.VolumeSource = VolumeSource{

pkg/api/v1/defaults_test.go

-58
Original file line numberDiff line numberDiff line change
@@ -155,64 +155,6 @@ func TestSetDefaultReplicationController(t *testing.T) {
155155
}
156156
}
157157

158-
func TestSetDefaultDaemon(t *testing.T) {
159-
tests := []struct {
160-
dc *versioned.Daemon
161-
expectLabelsChange bool
162-
}{
163-
{
164-
dc: &versioned.Daemon{
165-
Spec: versioned.DaemonSpec{
166-
Template: &versioned.PodTemplateSpec{
167-
ObjectMeta: versioned.ObjectMeta{
168-
Labels: map[string]string{
169-
"foo": "bar",
170-
},
171-
},
172-
},
173-
},
174-
},
175-
expectLabelsChange: true,
176-
},
177-
{
178-
dc: &versioned.Daemon{
179-
ObjectMeta: versioned.ObjectMeta{
180-
Labels: map[string]string{
181-
"bar": "foo",
182-
},
183-
},
184-
Spec: versioned.DaemonSpec{
185-
Template: &versioned.PodTemplateSpec{
186-
ObjectMeta: versioned.ObjectMeta{
187-
Labels: map[string]string{
188-
"foo": "bar",
189-
},
190-
},
191-
},
192-
},
193-
},
194-
expectLabelsChange: false,
195-
},
196-
}
197-
198-
for _, test := range tests {
199-
dc := test.dc
200-
obj2 := roundTrip(t, runtime.Object(dc))
201-
dc2, ok := obj2.(*versioned.Daemon)
202-
if !ok {
203-
t.Errorf("unexpected object: %v", dc2)
204-
t.FailNow()
205-
}
206-
if test.expectLabelsChange != reflect.DeepEqual(dc2.Labels, dc2.Spec.Template.Labels) {
207-
if test.expectLabelsChange {
208-
t.Errorf("expected: %v, got: %v", dc2.Spec.Template.Labels, dc2.Labels)
209-
} else {
210-
t.Errorf("unexpected equality: %v", dc.Labels)
211-
}
212-
}
213-
}
214-
}
215-
216158
func newInt(val int) *int {
217159
p := new(int)
218160
*p = val

pkg/api/v1/register.go

-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ func addKnownTypes() {
4747
&PodTemplateList{},
4848
&ReplicationController{},
4949
&ReplicationControllerList{},
50-
&DaemonList{},
51-
&Daemon{},
5250
&Service{},
5351
&ServiceList{},
5452
&Endpoints{},
@@ -100,8 +98,6 @@ func (*PodTemplate) IsAnAPIObject() {}
10098
func (*PodTemplateList) IsAnAPIObject() {}
10199
func (*ReplicationController) IsAnAPIObject() {}
102100
func (*ReplicationControllerList) IsAnAPIObject() {}
103-
func (*Daemon) IsAnAPIObject() {}
104-
func (*DaemonList) IsAnAPIObject() {}
105101
func (*Service) IsAnAPIObject() {}
106102
func (*ServiceList) IsAnAPIObject() {}
107103
func (*Endpoints) IsAnAPIObject() {}

pkg/api/v1/types.go

-63
Original file line numberDiff line numberDiff line change
@@ -1365,67 +1365,6 @@ type ReplicationControllerList struct {
13651365
Items []ReplicationController `json:"items"`
13661366
}
13671367

1368-
// DaemonSpec is the specification of a daemon.
1369-
type DaemonSpec struct {
1370-
// Selector is a label query over pods that are managed by the daemon.
1371-
// Must match in order to be controlled.
1372-
// If empty, defaulted to labels on Pod template.
1373-
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
1374-
Selector map[string]string `json:"selector,omitempty"`
1375-
1376-
// Template is the object that describes the pod that will be created.
1377-
// The Daemon will create exactly one copy of this pod on every node
1378-
// that matches the template's node selector (or on every node if no node
1379-
// selector is specified).
1380-
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template
1381-
Template *PodTemplateSpec `json:"template,omitempty"`
1382-
}
1383-
1384-
// DaemonStatus represents the current status of a daemon.
1385-
type DaemonStatus struct {
1386-
// CurrentNumberScheduled is the number of nodes that are running exactly 1 copy of the
1387-
// daemon and are supposed to run the daemon.
1388-
CurrentNumberScheduled int `json:"currentNumberScheduled"`
1389-
1390-
// NumberMisscheduled is the number of nodes that are running the daemon, but are
1391-
// not supposed to run the daemon.
1392-
NumberMisscheduled int `json:"numberMisscheduled"`
1393-
1394-
// DesiredNumberScheduled is the total number of nodes that should be running the daemon
1395-
// (including nodes correctly running the daemon).
1396-
DesiredNumberScheduled int `json:"desiredNumberScheduled"`
1397-
}
1398-
1399-
// Daemon represents the configuration of a daemon.
1400-
type Daemon struct {
1401-
TypeMeta `json:",inline"`
1402-
// Standard object's metadata.
1403-
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
1404-
ObjectMeta `json:"metadata,omitempty"`
1405-
1406-
// Spec defines the specification of the desired behavior of this daemon.
1407-
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
1408-
Spec DaemonSpec `json:"spec,omitempty"`
1409-
1410-
// Status is the current status of this daemon. This data may be
1411-
// out of date by some window of time.
1412-
// Populated by the system.
1413-
// Read-only.
1414-
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
1415-
Status DaemonStatus `json:"status,omitempty"`
1416-
}
1417-
1418-
// DaemonList is a collection of daemon.
1419-
type DaemonList struct {
1420-
TypeMeta `json:",inline"`
1421-
// Standard list metadata.
1422-
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
1423-
ListMeta `json:"metadata,omitempty"`
1424-
1425-
// Items is a list of daemons.
1426-
Items []Daemon `json:"items"`
1427-
}
1428-
14291368
// Session Affinity Type string
14301369
type ServiceAffinity string
14311370

@@ -2370,8 +2309,6 @@ const (
23702309
ResourceServices ResourceName = "services"
23712310
// ReplicationControllers, number
23722311
ResourceReplicationControllers ResourceName = "replicationcontrollers"
2373-
// Daemon, number
2374-
ResourceDaemon ResourceName = "daemon"
23752312
// ResourceQuotas, number
23762313
ResourceQuotas ResourceName = "resourcequotas"
23772314
// ResourceSecrets, number

pkg/api/validation/validation.go

-66
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ func ValidateReplicationControllerName(name string, prefix bool) (bool, string)
112112
return NameIsDNSSubdomain(name, prefix)
113113
}
114114

115-
// ValidateDaemonName can be used to check whether the given daemon name is valid.
116-
// Prefix indicates this name will be used as part of generation, in which case
117-
// trailing dashes are allowed.
118-
func ValidateDaemonName(name string, prefix bool) (bool, string) {
119-
return NameIsDNSSubdomain(name, prefix)
120-
}
121-
122115
// ValidateServiceName can be used to check whether the given service name is valid.
123116
// Prefix indicates this name will be used as part of generation, in which case
124117
// trailing dashes are allowed.
@@ -1244,65 +1237,6 @@ func ValidateReplicationControllerSpec(spec *api.ReplicationControllerSpec) errs
12441237
return allErrs
12451238
}
12461239

1247-
// ValidateDaemon tests if required fields in the daemon are set.
1248-
func ValidateDaemon(controller *api.Daemon) errs.ValidationErrorList {
1249-
allErrs := errs.ValidationErrorList{}
1250-
allErrs = append(allErrs, ValidateObjectMeta(&controller.ObjectMeta, true, ValidateReplicationControllerName).Prefix("metadata")...)
1251-
allErrs = append(allErrs, ValidateDaemonSpec(&controller.Spec).Prefix("spec")...)
1252-
return allErrs
1253-
}
1254-
1255-
// ValidateDaemonUpdate tests if required fields in the daemon are set.
1256-
func ValidateDaemonUpdate(oldController, controller *api.Daemon) errs.ValidationErrorList {
1257-
allErrs := errs.ValidationErrorList{}
1258-
allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
1259-
allErrs = append(allErrs, ValidateDaemonSpec(&controller.Spec).Prefix("spec")...)
1260-
allErrs = append(allErrs, ValidateDaemonTemplateUpdate(oldController.Spec.Template, controller.Spec.Template).Prefix("spec.template")...)
1261-
return allErrs
1262-
}
1263-
1264-
// ValidateDaemonTemplateUpdate tests that certain fields in the daemon's pod template are not updated.
1265-
func ValidateDaemonTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplateSpec) errs.ValidationErrorList {
1266-
allErrs := errs.ValidationErrorList{}
1267-
podSpec := podTemplate.Spec
1268-
// podTemplate.Spec is not a pointer, so we can modify NodeSelector and NodeName directly.
1269-
podSpec.NodeSelector = oldPodTemplate.Spec.NodeSelector
1270-
podSpec.NodeName = oldPodTemplate.Spec.NodeName
1271-
// In particular, we do not allow updates to container images at this point.
1272-
if !api.Semantic.DeepEqual(oldPodTemplate.Spec, podSpec) {
1273-
// TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
1274-
allErrs = append(allErrs, errs.NewFieldInvalid("spec", "content of spec is not printed out, please refer to the \"details\"", "may not update fields other than spec.nodeSelector"))
1275-
}
1276-
return allErrs
1277-
}
1278-
1279-
// ValidateDaemonSpec tests if required fields in the daemon spec are set.
1280-
func ValidateDaemonSpec(spec *api.DaemonSpec) errs.ValidationErrorList {
1281-
allErrs := errs.ValidationErrorList{}
1282-
1283-
selector := labels.Set(spec.Selector).AsSelector()
1284-
if selector.Empty() {
1285-
allErrs = append(allErrs, errs.NewFieldRequired("selector"))
1286-
}
1287-
1288-
if spec.Template == nil {
1289-
allErrs = append(allErrs, errs.NewFieldRequired("template"))
1290-
} else {
1291-
labels := labels.Set(spec.Template.Labels)
1292-
if !selector.Matches(labels) {
1293-
allErrs = append(allErrs, errs.NewFieldInvalid("template.metadata.labels", spec.Template.Labels, "selector does not match template"))
1294-
}
1295-
allErrs = append(allErrs, ValidatePodTemplateSpec(spec.Template).Prefix("template")...)
1296-
// Daemons typically run on more than one node, so mark Read-Write persistent disks as invalid.
1297-
allErrs = append(allErrs, ValidateReadOnlyPersistentDisks(spec.Template.Spec.Volumes).Prefix("template.spec.volumes")...)
1298-
// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
1299-
if spec.Template.Spec.RestartPolicy != api.RestartPolicyAlways {
1300-
allErrs = append(allErrs, errs.NewFieldValueNotSupported("template.spec.restartPolicy", spec.Template.Spec.RestartPolicy, []string{string(api.RestartPolicyAlways)}))
1301-
}
1302-
}
1303-
return allErrs
1304-
}
1305-
13061240
// ValidatePodTemplateSpec validates the spec of a pod template
13071241
func ValidatePodTemplateSpec(spec *api.PodTemplateSpec) errs.ValidationErrorList {
13081242
allErrs := errs.ValidationErrorList{}

0 commit comments

Comments
 (0)