mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #27713 from kargakis/wait-for-synced-rs-in-recreate
Automatic merge from submit-queue controller: wait for synced old replica sets on Recreate Partially fixes https://github.com/kubernetes/kubernetes/issues/27362 Any other work on it should be handled in the replica set level (and/or kubelet if it's required) @kubernetes/deployment PTAL
This commit is contained in:
@@ -108,3 +108,25 @@ func MatchingPodsFunc(rs *extensions.ReplicaSet) (func(api.Pod) bool, error) {
|
||||
return selector.Matches(podLabelsSelector)
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ReplicaSetIsInactive returns a condition that will be true when a replica set is inactive ie.
|
||||
// it has zero running replicas.
|
||||
func ReplicaSetIsInactive(c unversionedextensions.ExtensionsInterface, replicaSet *extensions.ReplicaSet) wait.ConditionFunc {
|
||||
|
||||
// If we're given a ReplicaSet where the status lags the spec, it either means that the
|
||||
// ReplicaSet is stale, or that the ReplicaSet manager hasn't noticed the update yet.
|
||||
// Polling status.Replicas is not safe in the latter case.
|
||||
desiredGeneration := replicaSet.Generation
|
||||
|
||||
return func() (bool, error) {
|
||||
rs, err := c.ReplicaSets(replicaSet.Namespace).Get(replicaSet.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return rs.Status.ObservedGeneration >= desiredGeneration &&
|
||||
rs.Spec.Replicas == 0 &&
|
||||
rs.Status.Replicas == 0 &&
|
||||
rs.Status.FullyLabeledReplicas == 0, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user