Address review comments.

This commit is contained in:
Madhusudan.C.S 2016-02-08 15:13:48 -08:00
parent f358402623
commit e7a9f30936
16 changed files with 37 additions and 33 deletions

View File

@ -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

View File

@ -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"

View File

@ -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"`

View File

@ -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"`

View File

@ -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.",
}

View File

@ -125,6 +125,7 @@ __custom_func() {
* persistentvolumeclaims (aka 'pvc')
* quota
* resourcequotas (aka 'quota')
* replicasets (aka 'rs')
* replicationcontrollers (aka 'rc')
* secrets
* serviceaccounts

View File

@ -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)

View File

@ -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)
}

View File

@ -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
// }

View File

@ -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

View File

@ -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
}

View File

@ -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{})

View File

@ -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{

View File

@ -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)
}

View File

@ -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
}

View File

@ -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() {