mirror of
https://github.com/containers/skopeo.git
synced 2025-09-19 17:15:32 +00:00
Merge pull request #1390 from mtrmac/start-timeouts
Add timeouts when waiting on OpenShift or the registry to start
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -9,6 +10,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/homedir"
|
"github.com/docker/docker/pkg/homedir"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
@@ -109,6 +111,8 @@ func (cluster *openshiftCluster) startMaster(c *check.C) {
|
|||||||
|
|
||||||
gotPortCheck := false
|
gotPortCheck := false
|
||||||
gotLogCheck := false
|
gotLogCheck := false
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||||
|
defer cancel()
|
||||||
for !gotPortCheck || !gotLogCheck {
|
for !gotPortCheck || !gotLogCheck {
|
||||||
c.Logf("Waiting for master")
|
c.Logf("Waiting for master")
|
||||||
select {
|
select {
|
||||||
@@ -121,6 +125,8 @@ func (cluster *openshiftCluster) startMaster(c *check.C) {
|
|||||||
c.Fatal("log check done, success message not found")
|
c.Fatal("log check done, success message not found")
|
||||||
}
|
}
|
||||||
gotLogCheck = true
|
gotLogCheck = true
|
||||||
|
case <-ctx.Done():
|
||||||
|
c.Fatalf("Timed out waiting for master: %v", ctx.Err())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Logf("OK, master started!")
|
c.Logf("OK, master started!")
|
||||||
@@ -166,8 +172,14 @@ func (cluster *openshiftCluster) startRegistryProcess(c *check.C, port int, conf
|
|||||||
terminatePortCheck <- true
|
terminatePortCheck <- true
|
||||||
}()
|
}()
|
||||||
c.Logf("Waiting for registry to start")
|
c.Logf("Waiting for registry to start")
|
||||||
<-portOpen
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
||||||
c.Logf("OK, Registry port open")
|
defer cancel()
|
||||||
|
select {
|
||||||
|
case <-portOpen:
|
||||||
|
c.Logf("OK, Registry port open")
|
||||||
|
case <-ctx.Done():
|
||||||
|
c.Fatalf("Timed out waiting for registry to start: %v", ctx.Err())
|
||||||
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user