diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh index 89dbdb9768f..06c78e07d34 100755 --- a/hack/test-cmd.sh +++ b/hack/test-cmd.sh @@ -964,6 +964,7 @@ __EOF__ kube::test::get_object_assert 'job pi' "{{$job_parallelism_field}}" '2' # Clean-up kubectl delete job/pi "${kube_flags[@]}" + # TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). # ### Scale a deployment # kubectl create -f examples/extensions/deployment.yaml "${kube_flags[@]}" # # Command diff --git a/pkg/apis/extensions/helpers.go b/pkg/apis/extensions/helpers.go index 8196a921c5d..0e6d309e59a 100644 --- a/pkg/apis/extensions/helpers.go +++ b/pkg/apis/extensions/helpers.go @@ -16,7 +16,7 @@ limitations under the License. package extensions -// TODO(madhusudancs): Fix this when Scale group issues are resolved. +// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // import ( // "fmt" diff --git a/pkg/apis/extensions/types.go b/pkg/apis/extensions/types.go index c70baf82971..f6c0c0cafad 100644 --- a/pkg/apis/extensions/types.go +++ b/pkg/apis/extensions/types.go @@ -248,7 +248,7 @@ type DeploymentSpec struct { // Defaults to 0 (pod will be considered available as soon as it is ready) MinReadySeconds int `json:"minReadySeconds,omitempty"` - // The number of old ReplicationControllers to retain to allow rollback. + // The number of old ReplicaSets to retain to allow rollback. // This is a pointer to distinguish between explicit zero and not specified. RevisionHistoryLimit *int `json:"revisionHistoryLimit,omitempty"` diff --git a/pkg/apis/extensions/v1beta1/types.go b/pkg/apis/extensions/v1beta1/types.go index 52bed45cb9c..e47de475e7b 100644 --- a/pkg/apis/extensions/v1beta1/types.go +++ b/pkg/apis/extensions/v1beta1/types.go @@ -199,7 +199,7 @@ type ThirdPartyResourceData struct { Data []byte `json:"data,omitempty"` } -// Deployment enables declarative updates for Pods and ReplicationControllers. +// Deployment enables declarative updates for Pods and ReplicaSets. type Deployment struct { unversioned.TypeMeta `json:",inline"` // Standard object metadata. @@ -218,7 +218,7 @@ type DeploymentSpec struct { // zero and not specified. Defaults to 1. Replicas *int32 `json:"replicas,omitempty"` - // Label selector for pods. Existing ReplicationControllers whose pods are + // Label selector for pods. Existing ReplicaSets whose pods are // selected by this will be the ones affected by this deployment. Selector *LabelSelector `json:"selector,omitempty"` @@ -233,7 +233,7 @@ type DeploymentSpec struct { // Defaults to 0 (pod will be considered available as soon as it is ready) MinReadySeconds int32 `json:"minReadySeconds,omitempty"` - // The number of old ReplicationControllers to retain to allow rollback. + // The number of old ReplicaSets to retain to allow rollback. // This is a pointer to distinguish between explicit zero and not specified. RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"` diff --git a/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go b/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go index 336dc1e67c7..7ae091b6013 100644 --- a/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go +++ b/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go @@ -147,7 +147,7 @@ func (DaemonSetUpdateStrategy) SwaggerDoc() map[string]string { } var map_Deployment = map[string]string{ - "": "Deployment enables declarative updates for Pods and ReplicationControllers.", + "": "Deployment enables declarative updates for Pods and ReplicaSets.", "metadata": "Standard object metadata.", "spec": "Specification of the desired behavior of the Deployment.", "status": "Most recently observed status of the Deployment.", @@ -181,11 +181,11 @@ func (DeploymentRollback) SwaggerDoc() map[string]string { var map_DeploymentSpec = map[string]string{ "": "DeploymentSpec is the specification of the desired behavior of the Deployment.", "replicas": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.", - "selector": "Label selector for pods. Existing ReplicationControllers whose pods are selected by this will be the ones affected by this deployment.", + "selector": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.", "template": "Template describes the pods that will be created.", "strategy": "The deployment strategy to use to replace existing pods with new ones.", "minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", - "revisionHistoryLimit": "The number of old ReplicationControllers to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified.", + "revisionHistoryLimit": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified.", "paused": "Indicates that the deployment is paused and will not be processed by the deployment controller.", "rollbackTo": "The config this deployment is rolling back to. Will be cleared after rollback is done.", } diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index 84f9d54647b..2abffaf3766 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -125,6 +125,7 @@ __custom_func() { * persistentvolumeclaims (aka 'pvc') * quota * resourcequotas (aka 'quota') + * replicasets (aka 'rs') * replicationcontrollers (aka 'rc') * secrets * serviceaccounts diff --git a/pkg/kubectl/describe.go b/pkg/kubectl/describe.go index 1c82fb7fa21..d24bfeb2ed2 100644 --- a/pkg/kubectl/describe.go +++ b/pkg/kubectl/describe.go @@ -1607,12 +1607,16 @@ func (dd *DeploymentDescriber) Describe(namespace, name string) (string, error) if err != nil { return "", err } + selector, err := unversioned.LabelSelectorAsSelector(d.Spec.Selector) + if err != nil { + return "", err + } return tabbedString(func(out io.Writer) error { fmt.Fprintf(out, "Name:\t%s\n", d.ObjectMeta.Name) fmt.Fprintf(out, "Namespace:\t%s\n", d.ObjectMeta.Namespace) fmt.Fprintf(out, "CreationTimestamp:\t%s\n", d.CreationTimestamp.Time.Format(time.RFC1123Z)) fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(d.Labels)) - fmt.Fprintf(out, "Selector:\t%s\n", d.Spec.Selector) + fmt.Fprintf(out, "Selector:\t%s\n", selector) fmt.Fprintf(out, "Replicas:\t%d updated | %d total | %d available | %d unavailable\n", d.Status.UpdatedReplicas, d.Spec.Replicas, d.Status.AvailableReplicas, d.Status.UnavailableReplicas) fmt.Fprintf(out, "StrategyType:\t%s\n", d.Spec.Strategy.Type) fmt.Fprintf(out, "MinReadySeconds:\t%s\n", d.Spec.MinReadySeconds) diff --git a/pkg/kubectl/history.go b/pkg/kubectl/history.go index 501e9dd9916..01995f37674 100644 --- a/pkg/kubectl/history.go +++ b/pkg/kubectl/history.go @@ -58,7 +58,7 @@ type DeploymentHistoryViewer struct { c clientset.Interface } -// History returns a revision-to-RC map as the revision history of a deployment +// History returns a revision-to-replicaset map as the revision history of a deployment func (h *DeploymentHistoryViewer) History(namespace, name string) (HistoryInfo, error) { historyInfo := HistoryInfo{ RevisionToTemplate: make(map[int64]*api.PodTemplateSpec), @@ -67,22 +67,22 @@ func (h *DeploymentHistoryViewer) History(namespace, name string) (HistoryInfo, if err != nil { return historyInfo, fmt.Errorf("failed to retrieve deployment %s: %v", name, err) } - _, allOldRCs, err := deploymentutil.GetOldReplicaSets(*deployment, h.c) + _, allOldRSs, err := deploymentutil.GetOldReplicaSets(*deployment, h.c) if err != nil { - return historyInfo, fmt.Errorf("failed to retrieve old RCs from deployment %s: %v", name, err) + return historyInfo, fmt.Errorf("failed to retrieve old replica sets from deployment %s: %v", name, err) } - newRC, err := deploymentutil.GetNewReplicaSet(*deployment, h.c) + newRS, err := deploymentutil.GetNewReplicaSet(*deployment, h.c) if err != nil { - return historyInfo, fmt.Errorf("failed to retrieve new RC from deployment %s: %v", name, err) + return historyInfo, fmt.Errorf("failed to retrieve new replica set from deployment %s: %v", name, err) } - allRCs := append(allOldRCs, newRC) - for _, rc := range allRCs { - v, err := deploymentutil.Revision(rc) + allRSs := append(allOldRSs, newRS) + for _, rs := range allRSs { + v, err := deploymentutil.Revision(rs) if err != nil { continue } - historyInfo.RevisionToTemplate[v] = rc.Spec.Template - changeCause := getChangeCause(rc) + historyInfo.RevisionToTemplate[v] = rs.Spec.Template + changeCause := getChangeCause(rs) if historyInfo.RevisionToTemplate[v].Annotations == nil { historyInfo.RevisionToTemplate[v].Annotations = make(map[string]string) } diff --git a/pkg/kubectl/scale.go b/pkg/kubectl/scale.go index be603563634..74fe84a6bcb 100644 --- a/pkg/kubectl/scale.go +++ b/pkg/kubectl/scale.go @@ -48,7 +48,7 @@ func ScalerFor(kind unversioned.GroupKind, c client.Interface) (Scaler, error) { return &ReplicaSetScaler{c.Extensions()}, nil case extensions.Kind("Job"): return &JobScaler{c.Extensions()}, nil - // TODO(madhusudancs): Fix this when Scale group issues are resolved. + // TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // case extensions.Kind("Deployment"): // return &DeploymentScaler{c.Extensions()}, nil } @@ -328,7 +328,7 @@ func (precondition *ScalePrecondition) ValidateDeployment(deployment *extensions return nil } -// TODO(madhusudancs): Fix this when Scale group issues are resolved. +// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // type DeploymentScaler struct { // c client.ExtensionsInterface // } diff --git a/pkg/kubectl/scale_test.go b/pkg/kubectl/scale_test.go index 18893353bc1..ceff36021ae 100644 --- a/pkg/kubectl/scale_test.go +++ b/pkg/kubectl/scale_test.go @@ -488,7 +488,7 @@ func TestValidateJob(t *testing.T) { } } -// TODO(madhusudancs): Fix this when Scale group issues are resolved. +// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // type ErrorScales struct { // testclient.FakeScales diff --git a/pkg/master/master.go b/pkg/master/master.go index 089231a74b1..315b25fe655 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -624,7 +624,7 @@ func (m *Master) getExtensionResources(c *Config) map[string]rest.Storage { deploymentStorage := deploymentetcd.NewStorage(dbClient("deployments"), storageDecorator) storage["deployments"] = deploymentStorage.Deployment storage["deployments/status"] = deploymentStorage.Status - // TODO(madhusudancs): Install scale when Scale group issues are fixed. + // TODO(madhusudancs): Install scale when Scale group issues are fixed (see issue #18528). // storage["deployments/scale"] = deploymentStorage.Scale storage["deployments/rollback"] = deploymentStorage.Rollback } diff --git a/pkg/registry/deployment/etcd/etcd.go b/pkg/registry/deployment/etcd/etcd.go index f71f7a7a7ec..5c2ae3fee73 100644 --- a/pkg/registry/deployment/etcd/etcd.go +++ b/pkg/registry/deployment/etcd/etcd.go @@ -183,7 +183,7 @@ type ScaleREST struct { registry *deployment.Registry } -// TODO(madhusudancs): Fix this when Scale group issues are resolved. +// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // // ScaleREST implements Patcher // var _ = rest.Patcher(&ScaleREST{}) diff --git a/pkg/registry/deployment/etcd/etcd_test.go b/pkg/registry/deployment/etcd/etcd_test.go index cdd022d7221..66520862d7f 100644 --- a/pkg/registry/deployment/etcd/etcd_test.go +++ b/pkg/registry/deployment/etcd/etcd_test.go @@ -179,7 +179,7 @@ func TestWatch(t *testing.T) { ) } -// TODO(madhusudancs): Fix this when Scale group issues are resolved. +// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // func validNewScale() *extensions.Scale { // return &extensions.Scale{ diff --git a/pkg/util/deployment/deployment.go b/pkg/util/deployment/deployment.go index 158d844ef5d..27ef7aabe37 100644 --- a/pkg/util/deployment/deployment.go +++ b/pkg/util/deployment/deployment.go @@ -55,7 +55,7 @@ func GetOldReplicaSets(deployment extensions.Deployment, c clientset.Interface) // GetOldReplicaSetsFromLists returns two sets of old replica sets targeted by the given Deployment; get PodList and ReplicaSetList with input functions. // Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets. -func GetOldReplicaSetsFromLists(deployment extensions.Deployment, c clientset.Interface, getPodList func(string, api.ListOptions) (*api.PodList, error), getRcList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { +func GetOldReplicaSetsFromLists(deployment extensions.Deployment, c clientset.Interface, getPodList func(string, api.ListOptions) (*api.PodList, error), getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { @@ -72,7 +72,7 @@ func GetOldReplicaSetsFromLists(deployment extensions.Deployment, c clientset.In // TODO: Right now we list all replica sets and then filter. We should add an API for this. oldRSs := map[string]extensions.ReplicaSet{} allOldRSs := map[string]extensions.ReplicaSet{} - rsList, err := getRcList(namespace, options) + rsList, err := getRSList(namespace, options) if err != nil { return nil, nil, fmt.Errorf("error listing replica sets: %v", err) } @@ -119,14 +119,14 @@ func GetNewReplicaSet(deployment extensions.Deployment, c clientset.Interface) ( // GetNewReplicaSetFromList returns a replica set that matches the intent of the given deployment; get ReplicaSetList with the input function. // Returns nil if the new replica set doesnt exist yet. -func GetNewReplicaSetFromList(deployment extensions.Deployment, c clientset.Interface, getRcList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) (*extensions.ReplicaSet, error) { +func GetNewReplicaSetFromList(deployment extensions.Deployment, c clientset.Interface, getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) (*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { return nil, fmt.Errorf("failed to convert LabelSelector to Selector: %v", err) } - rsList, err := getRcList(namespace, api.ListOptions{LabelSelector: selector}) + rsList, err := getRSList(namespace, api.ListOptions{LabelSelector: selector}) if err != nil { return nil, fmt.Errorf("error listing ReplicaSets: %v", err) } diff --git a/pkg/util/labels/labels.go b/pkg/util/labels/labels.go index 3960165afe3..f7f034bc27c 100644 --- a/pkg/util/labels/labels.go +++ b/pkg/util/labels/labels.go @@ -81,9 +81,7 @@ func CloneSelectorAndAddLabel(selector *unversioned.LabelSelector, labelKey stri newMExps[i].Operator = me.Operator if me.Values != nil { newMExps[i].Values = make([]string, len(me.Values)) - for j, val := range me.Values { - newMExps[i].Values[j] = val - } + copy(newMExps[i].Values, me.Values) } else { newMExps[i].Values = nil } diff --git a/test/e2e/horizontal_pod_autoscaling.go b/test/e2e/horizontal_pod_autoscaling.go index fe5568a3212..57a5569e20a 100644 --- a/test/e2e/horizontal_pod_autoscaling.go +++ b/test/e2e/horizontal_pod_autoscaling.go @@ -41,7 +41,7 @@ var _ = Describe("Horizontal pod autoscaling (scale resource: CPU) [Serial] [Slo titleUp := "Should scale from 1 pod to 3 pods and from 3 to 5" titleDown := "Should scale from 5 pods to 3 pods and from 3 to 1" - // TODO(madhusudancs): Fix this when Scale group issues are resolved. + // TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528). // Describe("Deployment [Feature:Deployment]", func() { // // CPU tests via deployments // It(titleUp, func() {