Skip to content

Commit

Permalink
revert pipeline create changes (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakoush authored Nov 28, 2022
1 parent 6f9eb81 commit 21ea9f9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scheduler/pkg/kafka/pipeline/kafkamanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ func (km *KafkaManager) loadOrStorePipeline(resourceName string, isModel bool) (
return nil, err
}
pipeline.wg.Add(1) // wait set to allow consumer to say when started
km.pipelines.Store(key, pipeline)

go func() {
err := km.consume(pipeline)
if err != nil {
km.logger.WithError(err).Errorf("Failed running consumer for resource %s", resourceName)
}
}()

val, loaded := km.pipelines.LoadOrStore(key, pipeline)
if loaded { // we can still have a race condition where multiple "create" are happening, we have to store the first one
pipeline = val.(*Pipeline)
} else {
go func() {
err := km.consume(pipeline)
if err != nil {
km.logger.WithError(err).Errorf("Failed running consumer for resource %s", resourceName)
}
}()
}

logger.Debugf("Waiting for consumer to be ready for %s", resourceName)
pipeline.wg.Wait() // wait (maybe) for consumer start
Expand Down

0 comments on commit 21ea9f9

Please sign in to comment.