mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #19382 from janetkuo/deployment-status
Auto commit by PR queue bot
This commit is contained in:
commit
a14d0fd641
File diff suppressed because it is too large
Load Diff
@ -298,6 +298,12 @@ type DeploymentStatus struct {
|
|||||||
|
|
||||||
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
|
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
|
||||||
UpdatedReplicas int `json:"updatedReplicas,omitempty"`
|
UpdatedReplicas int `json:"updatedReplicas,omitempty"`
|
||||||
|
|
||||||
|
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
|
||||||
|
AvailableReplicas int `json:"availableReplicas,omitempty"`
|
||||||
|
|
||||||
|
// Total number of unavailable pods targeted by this deployment.
|
||||||
|
UnavailableReplicas int `json:"unavailableReplicas,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeploymentList struct {
|
type DeploymentList struct {
|
||||||
|
@ -2769,6 +2769,8 @@ func autoConvert_extensions_DeploymentStatus_To_v1beta1_DeploymentStatus(in *ext
|
|||||||
}
|
}
|
||||||
out.Replicas = int32(in.Replicas)
|
out.Replicas = int32(in.Replicas)
|
||||||
out.UpdatedReplicas = int32(in.UpdatedReplicas)
|
out.UpdatedReplicas = int32(in.UpdatedReplicas)
|
||||||
|
out.AvailableReplicas = int32(in.AvailableReplicas)
|
||||||
|
out.UnavailableReplicas = int32(in.UnavailableReplicas)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3942,6 +3944,8 @@ func autoConvert_v1beta1_DeploymentStatus_To_extensions_DeploymentStatus(in *Dep
|
|||||||
}
|
}
|
||||||
out.Replicas = int(in.Replicas)
|
out.Replicas = int(in.Replicas)
|
||||||
out.UpdatedReplicas = int(in.UpdatedReplicas)
|
out.UpdatedReplicas = int(in.UpdatedReplicas)
|
||||||
|
out.AvailableReplicas = int(in.AvailableReplicas)
|
||||||
|
out.UnavailableReplicas = int(in.UnavailableReplicas)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,6 +1202,8 @@ func deepCopy_v1beta1_DeploymentSpec(in DeploymentSpec, out *DeploymentSpec, c *
|
|||||||
func deepCopy_v1beta1_DeploymentStatus(in DeploymentStatus, out *DeploymentStatus, c *conversion.Cloner) error {
|
func deepCopy_v1beta1_DeploymentStatus(in DeploymentStatus, out *DeploymentStatus, c *conversion.Cloner) error {
|
||||||
out.Replicas = in.Replicas
|
out.Replicas = in.Replicas
|
||||||
out.UpdatedReplicas = in.UpdatedReplicas
|
out.UpdatedReplicas = in.UpdatedReplicas
|
||||||
|
out.AvailableReplicas = in.AvailableReplicas
|
||||||
|
out.UnavailableReplicas = in.UnavailableReplicas
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -286,6 +286,12 @@ type DeploymentStatus struct {
|
|||||||
|
|
||||||
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
|
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
|
||||||
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
|
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
|
||||||
|
|
||||||
|
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
|
||||||
|
AvailableReplicas int32 `json:"availableReplicas,omitempty"`
|
||||||
|
|
||||||
|
// Total number of unavailable pods targeted by this deployment.
|
||||||
|
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeploymentList is a list of Deployments.
|
// DeploymentList is a list of Deployments.
|
||||||
|
@ -182,9 +182,11 @@ func (DeploymentSpec) SwaggerDoc() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var map_DeploymentStatus = map[string]string{
|
var map_DeploymentStatus = map[string]string{
|
||||||
"": "DeploymentStatus is the most recently observed status of the Deployment.",
|
"": "DeploymentStatus is the most recently observed status of the Deployment.",
|
||||||
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
|
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
|
||||||
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
|
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
|
||||||
|
"availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
|
||||||
|
"unavailableReplicas": "Total number of unavailable pods targeted by this deployment.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DeploymentStatus) SwaggerDoc() map[string]string {
|
func (DeploymentStatus) SwaggerDoc() map[string]string {
|
||||||
|
@ -501,7 +501,11 @@ func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extension
|
|||||||
func (dc *DeploymentController) syncDeploymentStatus(allRCs []*api.ReplicationController, newRC *api.ReplicationController, deployment extensions.Deployment) error {
|
func (dc *DeploymentController) syncDeploymentStatus(allRCs []*api.ReplicationController, newRC *api.ReplicationController, deployment extensions.Deployment) error {
|
||||||
totalReplicas := deploymentutil.GetReplicaCountForRCs(allRCs)
|
totalReplicas := deploymentutil.GetReplicaCountForRCs(allRCs)
|
||||||
updatedReplicas := deploymentutil.GetReplicaCountForRCs([]*api.ReplicationController{newRC})
|
updatedReplicas := deploymentutil.GetReplicaCountForRCs([]*api.ReplicationController{newRC})
|
||||||
if deployment.Status.Replicas != totalReplicas || deployment.Status.UpdatedReplicas != updatedReplicas {
|
availablePods, err := deploymentutil.GetAvailablePodsForRCs(dc.client, allRCs, deployment.Spec.Strategy.RollingUpdate.MinReadySeconds)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to count ready pods: %v", err)
|
||||||
|
}
|
||||||
|
if deployment.Status.Replicas != totalReplicas || deployment.Status.UpdatedReplicas != updatedReplicas || deployment.Status.AvailableReplicas != availablePods {
|
||||||
return dc.updateDeploymentStatus(allRCs, newRC, deployment)
|
return dc.updateDeploymentStatus(allRCs, newRC, deployment)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -702,13 +706,19 @@ func (dc *DeploymentController) scaleUpNewRCForRecreate(newRC *api.ReplicationCo
|
|||||||
func (dc *DeploymentController) updateDeploymentStatus(allRCs []*api.ReplicationController, newRC *api.ReplicationController, deployment extensions.Deployment) error {
|
func (dc *DeploymentController) updateDeploymentStatus(allRCs []*api.ReplicationController, newRC *api.ReplicationController, deployment extensions.Deployment) error {
|
||||||
totalReplicas := deploymentutil.GetReplicaCountForRCs(allRCs)
|
totalReplicas := deploymentutil.GetReplicaCountForRCs(allRCs)
|
||||||
updatedReplicas := deploymentutil.GetReplicaCountForRCs([]*api.ReplicationController{newRC})
|
updatedReplicas := deploymentutil.GetReplicaCountForRCs([]*api.ReplicationController{newRC})
|
||||||
|
availablePods, err := deploymentutil.GetAvailablePodsForRCs(dc.client, allRCs, deployment.Spec.Strategy.RollingUpdate.MinReadySeconds)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to count ready pods: %v", err)
|
||||||
|
}
|
||||||
newDeployment := deployment
|
newDeployment := deployment
|
||||||
// TODO: Reconcile this with API definition. API definition talks about ready pods, while this just computes created pods.
|
// TODO: Reconcile this with API definition. API definition talks about ready pods, while this just computes created pods.
|
||||||
newDeployment.Status = extensions.DeploymentStatus{
|
newDeployment.Status = extensions.DeploymentStatus{
|
||||||
Replicas: totalReplicas,
|
Replicas: totalReplicas,
|
||||||
UpdatedReplicas: updatedReplicas,
|
UpdatedReplicas: updatedReplicas,
|
||||||
|
AvailableReplicas: availablePods,
|
||||||
|
UnavailableReplicas: totalReplicas - availablePods,
|
||||||
}
|
}
|
||||||
_, err := dc.expClient.Deployments(deployment.ObjectMeta.Namespace).UpdateStatus(&newDeployment)
|
_, err = dc.expClient.Deployments(deployment.ObjectMeta.Namespace).UpdateStatus(&newDeployment)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,10 @@ func newReplicationController(d *exp.Deployment, name string, replicas int) *api
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newListOptions() api.ListOptions {
|
||||||
|
return api.ListOptions{}
|
||||||
|
}
|
||||||
|
|
||||||
type fixture struct {
|
type fixture struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
|
||||||
@ -355,6 +359,10 @@ func (f *fixture) expectUpdateRCAction(rc *api.ReplicationController) {
|
|||||||
f.objects.Items = append(f.objects.Items, rc)
|
f.objects.Items = append(f.objects.Items, rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *fixture) expectListPodAction(namespace string, opt api.ListOptions) {
|
||||||
|
f.actions = append(f.actions, testclient.NewListAction("pods", namespace, opt))
|
||||||
|
}
|
||||||
|
|
||||||
func newFixture(t *testing.T) *fixture {
|
func newFixture(t *testing.T) *fixture {
|
||||||
f := &fixture{}
|
f := &fixture{}
|
||||||
f.t = t
|
f.t = t
|
||||||
@ -412,9 +420,11 @@ func TestSyncDeploymentCreatesRC(t *testing.T) {
|
|||||||
// then is updated to 1 replica
|
// then is updated to 1 replica
|
||||||
rc := newReplicationController(d, "deploymentrc-4186632231", 0)
|
rc := newReplicationController(d, "deploymentrc-4186632231", 0)
|
||||||
updatedRC := newReplicationController(d, "deploymentrc-4186632231", 1)
|
updatedRC := newReplicationController(d, "deploymentrc-4186632231", 1)
|
||||||
|
opt := newListOptions()
|
||||||
|
|
||||||
f.expectCreateRCAction(rc)
|
f.expectCreateRCAction(rc)
|
||||||
f.expectUpdateRCAction(updatedRC)
|
f.expectUpdateRCAction(updatedRC)
|
||||||
|
f.expectListPodAction(rc.Namespace, opt)
|
||||||
f.expectUpdateDeploymentAction(d)
|
f.expectUpdateDeploymentAction(d)
|
||||||
|
|
||||||
f.run(getKey(d, t))
|
f.run(getKey(d, t))
|
||||||
|
@ -1591,7 +1591,7 @@ func (dd *DeploymentDescriber) Describe(namespace, name string) (string, error)
|
|||||||
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", d.CreationTimestamp.Time.Format(time.RFC1123Z))
|
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, "Labels:\t%s\n", labels.FormatLabels(d.Labels))
|
||||||
fmt.Fprintf(out, "Selector:\t%s\n", labels.FormatLabels(d.Spec.Selector))
|
fmt.Fprintf(out, "Selector:\t%s\n", labels.FormatLabels(d.Spec.Selector))
|
||||||
fmt.Fprintf(out, "Replicas:\t%d updated / %d total\n", d.Status.UpdatedReplicas, d.Spec.Replicas)
|
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, "StrategyType:\t%s\n", d.Spec.Strategy.Type)
|
||||||
if d.Spec.Strategy.RollingUpdate != nil {
|
if d.Spec.Strategy.RollingUpdate != nil {
|
||||||
ru := d.Spec.Strategy.RollingUpdate
|
ru := d.Spec.Strategy.RollingUpdate
|
||||||
|
Loading…
Reference in New Issue
Block a user