-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix deployment status propagation when scaling from zero #15550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ var podCondSet = apis.NewLivingConditionSet( | |
PodAutoscalerConditionActive, | ||
PodAutoscalerConditionScaleTargetInitialized, | ||
PodAutoscalerConditionSKSReady, | ||
PodAutoscalerConditionScaleTargetScaled, | ||
) | ||
|
||
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. | ||
|
@@ -215,6 +216,12 @@ func (pas *PodAutoscalerStatus) MarkScaleTargetInitialized() { | |
podCondSet.Manage(pas).MarkTrue(PodAutoscalerConditionScaleTargetInitialized) | ||
} | ||
|
||
// ScaleTargetNotScaled returns true if the PodAutoscaler's scale target has failed | ||
// to scaled. | ||
func (pas *PodAutoscalerStatus) ScaleTargetNotScaled() bool { | ||
return pas.GetCondition(PodAutoscalerConditionScaleTargetScaled).IsFalse() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// MarkSKSReady marks the PA condition denoting that SKS is ready. | ||
func (pas *PodAutoscalerStatus) MarkSKSReady() { | ||
podCondSet.Manage(pas).MarkTrue(PodAutoscalerConditionSKSReady) | ||
|
@@ -250,6 +257,16 @@ func (pas *PodAutoscalerStatus) MarkInactive(reason, message string) { | |
podCondSet.Manage(pas).MarkFalse(PodAutoscalerConditionActive, reason, message) | ||
} | ||
|
||
// MarkWithNoScaleFailures marks the PA as free of scale failures. | ||
func (pas *PodAutoscalerStatus) MarkWithNoScaleFailures() { | ||
podCondSet.Manage(pas).MarkTrue(PodAutoscalerConditionScaleTargetScaled) | ||
} | ||
|
||
// MarkWithScaleFailures marks the PA as failed due to scale failures. | ||
func (pas *PodAutoscalerStatus) MarkWithScaleFailures(reason, message string) { | ||
podCondSet.Manage(pas).MarkFalse(PodAutoscalerConditionScaleTargetScaled, reason, message) | ||
} | ||
|
||
// MarkResourceNotOwned changes the "Active" condition to false to reflect that the | ||
// resource of the given kind and name has already been created, and we do not own it. | ||
func (pas *PodAutoscalerStatus) MarkResourceNotOwned(kind, name string) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,11 @@ const ( | |
PodAutoscalerConditionActive apis.ConditionType = "Active" | ||
// PodAutoscalerConditionSKSReady is set when SKS is ready. | ||
PodAutoscalerConditionSKSReady = "SKSReady" | ||
// PodAutoscalerConditionScaleTargetScaled is set when scaling the revision is successful. | ||
// There are cases where there are pod failures during scaling eg. from zero but | ||
// K8s does not properly propagate the failure to the deployment. In those cases | ||
// progressdeadline is not enough. | ||
PodAutoscalerConditionScaleTargetScaled apis.ConditionType = "ScaleTargetScaled" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can call it |
||
) | ||
|
||
// PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,13 @@ func (rs *RevisionStatus) PropagateAutoscalerStatus(ps *autoscalingv1alpha1.PodA | |
// that implies that |service.endpoints| > 0. | ||
rs.MarkResourcesAvailableTrue() | ||
rs.MarkContainerHealthyTrue() | ||
|
||
// Mark resource unavailable if we are scaling back to zero, but we never achieved the required scale | ||
// and deployment status was not updated properly by K8s. For example due to an image pull error. | ||
if ps.ScaleTargetNotScaled() { | ||
condScaled := ps.GetCondition(autoscalingv1alpha1.PodAutoscalerConditionScaleTargetScaled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could set ContainerHealthyFalse here too but we need #15503 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ContainerHealthy PR merged |
||
rs.MarkResourcesAvailableFalse(condScaled.Reason, condScaled.Message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd prefer to keep ResourcesAvailable condition separate from this one. I associate ResourcesAvailable whether resources can be created and programmed |
||
} | ||
} | ||
|
||
// Mark resource unavailable if we don't have a Service Name and the deployment is ready | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies the revision is
Ready=False
whenScaleTargetScaled
is false.