Skip to content
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

Test loop #937

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions controllers/btpoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,28 +616,19 @@ func (r *BtpOperatorReconciler) applyOrUpdateResources(ctx context.Context, us [
func (r *BtpOperatorReconciler) waitForResourcesReadiness(ctx context.Context, us []*unstructured.Unstructured) error {
numOfResources := len(us)
resourcesReadinessInformer := make(chan bool, numOfResources)
allReadyInformer := make(chan bool, 1)
for _, u := range us {
go r.checkResourceReadiness(ctx, u, resourcesReadinessInformer)
}
go func(c chan bool) {
timeout := time.After(ReadyTimeout)
for i := 0; i < numOfResources; i++ {
select {
case <-resourcesReadinessInformer:
continue
case <-timeout:
return
}
timeout := time.After(ReadyTimeout)
for i := 0; i < numOfResources; i++ {
select {
case <-resourcesReadinessInformer:
continue
case <-timeout:
return errors.New("resources readiness timeout reached")
}
allReadyInformer <- true
}(resourcesReadinessInformer)
select {
case <-allReadyInformer:
return nil
case <-time.After(ReadyTimeout):
return errors.New("resources readiness timeout reached")
}
return nil
}

func (r *BtpOperatorReconciler) checkResourceReadiness(ctx context.Context, u *unstructured.Unstructured, c chan<- bool) {
Expand Down
Loading