Skip to content

Commit

Permalink
fix checking for replica controller
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Jul 16, 2024
1 parent 3d95b37 commit a90d01c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
34 changes: 0 additions & 34 deletions pkg/kapi/kapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit a90d01c

Please sign in to comment.