Skip to content

Commit

Permalink
Check other approach
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekMichali committed Dec 19, 2024
1 parent 5d737dd commit b4aec35
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions controllers/btpoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,16 @@ func (r *BtpOperatorReconciler) waitForResourcesReadiness(ctx context.Context, u
resourcesReadinessInformer := make(chan bool, numOfResources-1)
deploymentReadinessInformer := make(chan bool, 1)
allReadyInformer := make(chan bool, 1)
deploymentOk := true
for _, u := range us {
if u.GetKind() == deploymentKind {
go r.checkResourceReadiness(ctx, u, deploymentReadinessInformer)
continue
}
go r.checkResourceReadiness(ctx, u, resourcesReadinessInformer)
}
go func(resourcesReadinessInformer, deploymentReadinessInformer chan bool) {
timeout := time.After(ReadyTimeout)
go func(c, c2 chan bool, c3 bool) {
timeout := time.After(ReadyTimeout + time.Minute)
for i := 0; i < numOfResources; i++ {
select {
case <-resourcesReadinessInformer:
Expand All @@ -635,23 +636,25 @@ func (r *BtpOperatorReconciler) waitForResourcesReadiness(ctx context.Context, u
if ready {
continue
} else {
allReadyInformer <- false
return
deploymentOk = false
continue
}
case <-timeout:
return
}
}
allReadyInformer <- true
}(resourcesReadinessInformer, deploymentReadinessInformer)
}(resourcesReadinessInformer, deploymentReadinessInformer, deploymentOk)
select {
case <-allReadyInformer:
ready := <-deploymentReadinessInformer
if !ready {
if !deploymentOk {
return errors.New("deployment readiness timeout reached")
}
return nil
case <-time.After(ReadyTimeout):
case <-time.After(ReadyTimeout + time.Minute):
if !deploymentOk {
return errors.New("deployment readiness timeout reached")
}
return errors.New("resources readiness timeout reached")
}
}
Expand Down

0 comments on commit b4aec35

Please sign in to comment.