Skip to content

Commit

Permalink
Merge pull request #641 from rgooch/for-upstream
Browse files Browse the repository at this point in the history
imaginator: make missing directories even when streams config not present.
  • Loading branch information
cviecco authored Sep 9, 2019
2 parents 2a6bc60 + ad1f45e commit 653c286
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions imagebuilder/builder/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ func masterConfiguration(url string) (*masterConfigurationType, error) {
return &configuration, nil
}

func (b *Builder) delayMakeRequiredDirectories(abortNotifier <-chan struct{}) {
timer := time.NewTimer(time.Second * 5)
select {
case <-abortNotifier:
if !timer.Stop() {
<-timer.C
}
case <-timer.C:
b.makeRequiredDirectories()
}
}

func (b *Builder) makeRequiredDirectories() error {
imageServer, err := srpc.DialHTTP("tcp", b.imageServerAddress, 0)
if err != nil {
Expand Down Expand Up @@ -192,12 +204,19 @@ func (b *Builder) updateImageStreams(
}

func (b *Builder) watchConfigLoop(configChannel <-chan interface{}) {
firstLoadNotifier := make(chan struct{})
go b.delayMakeRequiredDirectories(firstLoadNotifier)
for rawConfig := range configChannel {
imageStreamsConfig, ok := rawConfig.(*imageStreamsConfigurationType)
if !ok {
b.logger.Printf("received unknown type over config channel")
continue
}
if firstLoadNotifier != nil {
firstLoadNotifier <- struct{}{}
close(firstLoadNotifier)
firstLoadNotifier = nil
}
b.logger.Println("received new image streams configuration")
b.updateImageStreams(imageStreamsConfig)
}
Expand Down

0 comments on commit 653c286

Please sign in to comment.