|
|
|
@@ -98,7 +98,7 @@ func (dc *DeploymentController) checkPausedConditions(d *apps.Deployment) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
d, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d)
|
|
|
|
|
d, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d, metav1.UpdateOptions{})
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -155,7 +155,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
minReadySecondsNeedsUpdate := rsCopy.Spec.MinReadySeconds != d.Spec.MinReadySeconds
|
|
|
|
|
if annotationsUpdated || minReadySecondsNeedsUpdate {
|
|
|
|
|
rsCopy.Spec.MinReadySeconds = d.Spec.MinReadySeconds
|
|
|
|
|
return dc.client.AppsV1().ReplicaSets(rsCopy.ObjectMeta.Namespace).Update(context.TODO(), rsCopy)
|
|
|
|
|
return dc.client.AppsV1().ReplicaSets(rsCopy.ObjectMeta.Namespace).Update(context.TODO(), rsCopy, metav1.UpdateOptions{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Should use the revision in existingNewRS's annotation, since it set by before
|
|
|
|
@@ -173,7 +173,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
|
|
|
|
|
if needsUpdate {
|
|
|
|
|
var err error
|
|
|
|
|
if d, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d); err != nil {
|
|
|
|
|
if d, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d, metav1.UpdateOptions{}); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -220,7 +220,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
// hash collisions. If there is any other error, we need to report it in the status of
|
|
|
|
|
// the Deployment.
|
|
|
|
|
alreadyExists := false
|
|
|
|
|
createdRS, err := dc.client.AppsV1().ReplicaSets(d.Namespace).Create(context.TODO(), &newRS)
|
|
|
|
|
createdRS, err := dc.client.AppsV1().ReplicaSets(d.Namespace).Create(context.TODO(), &newRS, metav1.CreateOptions{})
|
|
|
|
|
switch {
|
|
|
|
|
// We may end up hitting this due to a slow cache or a fast resync of the Deployment.
|
|
|
|
|
case errors.IsAlreadyExists(err):
|
|
|
|
@@ -252,7 +252,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
*d.Status.CollisionCount++
|
|
|
|
|
// Update the collisionCount for the Deployment and let it requeue by returning the original
|
|
|
|
|
// error.
|
|
|
|
|
_, dErr := dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d)
|
|
|
|
|
_, dErr := dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d, metav1.UpdateOptions{})
|
|
|
|
|
if dErr == nil {
|
|
|
|
|
klog.V(2).Infof("Found a hash collision for deployment %q - bumping collisionCount (%d->%d) to resolve it", d.Name, preCollisionCount, *d.Status.CollisionCount)
|
|
|
|
|
}
|
|
|
|
@@ -268,7 +268,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
// We don't really care about this error at this point, since we have a bigger issue to report.
|
|
|
|
|
// TODO: Identify which errors are permanent and switch DeploymentIsFailed to take into account
|
|
|
|
|
// these reasons as well. Related issue: https://github.com/kubernetes/kubernetes/issues/18568
|
|
|
|
|
_, _ = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d)
|
|
|
|
|
_, _ = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d, metav1.UpdateOptions{})
|
|
|
|
|
}
|
|
|
|
|
dc.eventRecorder.Eventf(d, v1.EventTypeWarning, deploymentutil.FailedRSCreateReason, msg)
|
|
|
|
|
return nil, err
|
|
|
|
@@ -285,7 +285,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
|
|
|
|
|
needsUpdate = true
|
|
|
|
|
}
|
|
|
|
|
if needsUpdate {
|
|
|
|
|
_, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d)
|
|
|
|
|
_, err = dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(context.TODO(), d, metav1.UpdateOptions{})
|
|
|
|
|
}
|
|
|
|
|
return createdRS, err
|
|
|
|
|
}
|
|
|
|
@@ -420,7 +420,7 @@ func (dc *DeploymentController) scaleReplicaSet(rs *apps.ReplicaSet, newScale in
|
|
|
|
|
rsCopy := rs.DeepCopy()
|
|
|
|
|
*(rsCopy.Spec.Replicas) = newScale
|
|
|
|
|
deploymentutil.SetReplicasAnnotations(rsCopy, *(deployment.Spec.Replicas), *(deployment.Spec.Replicas)+deploymentutil.MaxSurge(*deployment))
|
|
|
|
|
rs, err = dc.client.AppsV1().ReplicaSets(rsCopy.Namespace).Update(context.TODO(), rsCopy)
|
|
|
|
|
rs, err = dc.client.AppsV1().ReplicaSets(rsCopy.Namespace).Update(context.TODO(), rsCopy, metav1.UpdateOptions{})
|
|
|
|
|
if err == nil && sizeNeedsUpdate {
|
|
|
|
|
scaled = true
|
|
|
|
|
dc.eventRecorder.Eventf(deployment, v1.EventTypeNormal, "ScalingReplicaSet", "Scaled %s replica set %s to %d", scalingOperation, rs.Name, newScale)
|
|
|
|
@@ -478,7 +478,7 @@ func (dc *DeploymentController) syncDeploymentStatus(allRSs []*apps.ReplicaSet,
|
|
|
|
|
|
|
|
|
|
newDeployment := d
|
|
|
|
|
newDeployment.Status = newStatus
|
|
|
|
|
_, err := dc.client.AppsV1().Deployments(newDeployment.Namespace).UpdateStatus(context.TODO(), newDeployment)
|
|
|
|
|
_, err := dc.client.AppsV1().Deployments(newDeployment.Namespace).UpdateStatus(context.TODO(), newDeployment, metav1.UpdateOptions{})
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|