Skip to content

Commit

Permalink
Merge pull request openshift#822 from csrwng/clusterup_rhel74_backport
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Aug 2, 2017
2 parents 07d2d84 + c1f66d4 commit a539f79
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
43 changes: 27 additions & 16 deletions pkg/bootstrap/docker/openshift/cnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,39 @@ import (
"fmt"
)

const podNetworkTestCmd = `#!/bin/bash
set -e
echo 'Testing connectivity to master API'
failed=0
for i in {1..40}; do
if curl -s -S -k -m 1 https://${MASTER_IP}:8443; then
failed=0
break
else
failed=1
fi
done
if [[ failed -eq 1 ]]; then
exit 1
fi
echo 'Testing connectivity to master DNS server'
for i in {1..40}; do
if curl -s -S -k -m 1 https://kubernetes.default.svc.cluster.local; then
exit 0
fi
done
exit 1
`

// TestContainerNetworking launches a container that will check whether the container
// can communicate with the master API and DNS endpoints.
func (h *Helper) TestContainerNetworking(ip string) error {
// Skip check if the server ip is the localhost
if ip == "127.0.0.1" {
return nil
}
testCmd := fmt.Sprintf("echo 'Testing connectivity to master API' && "+
"curl -s -S -k https://%s:8443 && "+
"echo 'Testing connectivity to master DNS server' && "+
"for i in {1..10}; do "+
" if curl -s -S -k https://kubernetes.default.svc.cluster.local; then "+
" exit 0;"+
" fi; "+
" sleep 1; "+
"done; "+
"exit 1", ip)
_, err := h.runHelper.New().Image(h.image).
DiscardContainer().
DNS(ip).
Env(fmt.Sprintf("MASTER_IP=%s", ip)).
DNS("172.30.0.1").
Entrypoint("/bin/bash").
Command("-c", testCmd).
Command("-c", podNetworkTestCmd).
Run()
return err
}
12 changes: 11 additions & 1 deletion pkg/bootstrap/docker/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,20 @@ func (c *ClientStartConfig) StartOpenShift(out io.Writer) error {
return err
}

serverIP, err := c.OpenShiftHelper().ServerIP()
if err != nil {
return err
}

// Start a container networking test
c.containerNetworkErr = make(chan error)
go func() {
c.containerNetworkErr <- c.OpenShiftHelper().TestContainerNetworking(c.ServerIP)
// serverIP is the ip obtained by running 'openshift start --print-ip' on the
// origin container. This will return the primary IP for the host, which is what
// we need to test connectivity with. c.ServerIP is the IP that the client uses
// to access the openshift server and is not always useful in determining whether
// containers can communicate with the master (it could be 127.0.0.1 for example).
c.containerNetworkErr <- c.OpenShiftHelper().TestContainerNetworking(serverIP)
}()

// Setup persistent storage
Expand Down

0 comments on commit a539f79

Please sign in to comment.