fix checking for replica controller

pull/19254/head
Steven Powell 2024-07-16 18:02:49 -05:00
parent 3d95b37fdf
commit a90d01cfe6
2 changed files with 2 additions and 36 deletions

View File

@ -108,40 +108,6 @@ func WaitForPods(c kubernetes.Interface, ns string, selector string, timeOut ...
return err
}
// WaitForRCToStabilize waits till the RC has a matching generation/replica count between spec and status. used by integration tests
func WaitForRCToStabilize(c kubernetes.Interface, ns, name string, timeout time.Duration) error {
options := meta.ListOptions{FieldSelector: fields.Set{
"metadata.name": name,
"metadata.namespace": ns,
}.AsSelector().String()}
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout)
defer cancel()
w, err := c.CoreV1().ReplicationControllers(ns).Watch(ctx, options)
if err != nil {
return err
}
_, err = watchtools.UntilWithoutRetry(ctx, w, func(event watch.Event) (bool, error) {
if event.Type == watch.Deleted {
return false, apierr.NewNotFound(schema.GroupResource{Resource: "replicationcontrollers"}, "")
}
rc, ok := event.Object.(*core.ReplicationController)
if ok {
if rc.Name == name && rc.Namespace == ns &&
rc.Generation <= rc.Status.ObservedGeneration &&
*(rc.Spec.Replicas) == rc.Status.Replicas {
return true, nil
}
klog.Infof("Waiting for rc %s to stabilize, generation %v observed generation %v spec.replicas %d status.replicas %d",
name, rc.Generation, rc.Status.ObservedGeneration, *(rc.Spec.Replicas), rc.Status.Replicas)
}
return false, nil
})
return err
}
// WaitForDeploymentToStabilize waits till the Deployment has a matching generation/replica count between spec and status. used by integration tests
func WaitForDeploymentToStabilize(c kubernetes.Interface, ns, name string, timeout time.Duration) error {
options := meta.ListOptions{FieldSelector: fields.Set{

View File

@ -326,8 +326,8 @@ func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) {
}
start := time.Now()
if err := kapi.WaitForRCToStabilize(client, "kube-system", "registry", Minutes(6)); err != nil {
t.Errorf("failed waiting for registry replicacontroller to stabilize: %v", err)
if err := kapi.WaitForDeploymentToStabilize(client, "kube-system", "registry", Minutes(6)); err != nil {
t.Errorf("failed waiting for registry deployment to stabilize: %v", err)
}
t.Logf("registry stabilized in %s", time.Since(start))