Skip to content

Commit

Permalink
Merge pull request #14436 from jim-minter/issue12224
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Jun 13, 2017
2 parents 1284263 + fc526b7 commit a014711
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
5 changes: 4 additions & 1 deletion hack/test-end-to-end-docker.sh
Expand Up @@ -11,6 +11,7 @@ unset KUBECONFIG
os::util::environment::use_sudo
os::cleanup::tmpdir
os::util::environment::setup_all_server_vars
os::util::environment::setup_time_vars
export HOME="${FAKE_HOME_DIR}"

# Allow setting $JUNIT_REPORT to toggle output behavior
Expand Down Expand Up @@ -61,7 +62,9 @@ oc cluster up --server-loglevel=4 --version="${TAG}" \
--host-data-dir="${VOLUME_DIR}/etcd" \
--host-volumes-dir="${VOLUME_DIR}"

oc cluster status
os::test::junit::declare_suite_start "setup/start-oc_cluster_up"
os::cmd::try_until_success "oc cluster status" "$((5*TIME_MIN))" "10"
os::test::junit::declare_suite_end

IMAGE_WORKING_DIR=/var/lib/origin
docker cp origin:${IMAGE_WORKING_DIR}/openshift.local.config ${BASETMPDIR}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bootstrap/docker/openshift/metrics.go
Expand Up @@ -211,7 +211,7 @@ func metricsDeployerJob(hostName, imagePrefix, imageVersion string) *kbatch.Job

func MetricsHost(routingSuffix, serverIP string) string {
if len(routingSuffix) > 0 {
return fmt.Sprintf("metrics-openshift-infra.%s", routingSuffix)
return fmt.Sprintf("hawkular-metrics-openshift-infra.%s", routingSuffix)
}
return fmt.Sprintf("metrics-openshift-infra.%s.nip.io", serverIP)
return fmt.Sprintf("hawkular-metrics-openshift-infra.%s.nip.io", serverIP)
}
83 changes: 81 additions & 2 deletions pkg/bootstrap/docker/status.go
@@ -1,8 +1,10 @@
package docker

import (
"crypto/tls"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
Expand All @@ -13,6 +15,7 @@ import (

"github.com/openshift/origin/pkg/bootstrap/docker/dockerhelper"
"github.com/openshift/origin/pkg/bootstrap/docker/errors"
"github.com/openshift/origin/pkg/bootstrap/docker/exec"
"github.com/openshift/origin/pkg/bootstrap/docker/openshift"
"github.com/openshift/origin/pkg/cmd/server/api"
"github.com/openshift/origin/pkg/cmd/templates"
Expand Down Expand Up @@ -48,7 +51,9 @@ func NewCmdStatus(name, fullName string, f *clientcmd.Factory, out io.Writer) *c
Run: func(c *cobra.Command, args []string) {
err := config.Status(f, out)
if err != nil {
PrintError(err, out)
if err.Error() != "" {
PrintError(err, out)
}
os.Exit(1)
}
},
Expand Down Expand Up @@ -92,7 +97,80 @@ func (c *ClientStatusConfig) Status(f *clientcmd.Factory, out io.Writer) error {
return err
}

fmt.Print(status(container, config))
fmt.Fprint(out, status(container, config))

notReady := 0

eh := exec.NewExecHelper(dockerClient, openshift.OpenShiftContainer)

stdout, _, _ := eh.Command("oc", "get", "dc", "docker-registry", "-n", "default", "-o", "template", "--template", "{{.status.availableReplicas}}").Output()
if stdout != "1" {
fmt.Fprintln(out, "Notice: Docker registry is not yet ready")
notReady++
}

stdout, _, _ = eh.Command("oc", "get", "dc", "router", "-n", "default", "-o", "template", "--template", "{{.status.availableReplicas}}").Output()
if stdout != "1" {
fmt.Fprintln(out, "Notice: Router is not yet ready")
notReady++
}

stdout, _, _ = eh.Command("oc", "get", "job", "persistent-volume-setup", "-n", "default", "-o", "template", "--template", "{{.status.succeeded}}").Output()
if stdout != "1" {
fmt.Fprintln(out, "Notice: Persistent volumes are not yet ready")
notReady++
}

stdout, _, _ = eh.Command("oc", "get", "is", "-n", "openshift", "-o", "template", "--template", `{{range .items}}{{if not .status.tags}}notready{{end}}{{end}}`).Output()
if len(stdout) > 0 {
fmt.Fprintln(out, "Notice: Imagestreams are not yet ready")
notReady++
}

insecureCli := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
Timeout: 10 * time.Second,
}

ch := make(chan string)
go func() {
notice := ""
if config.AssetConfig.LoggingPublicURL != "" {
resp, _ := insecureCli.Get(config.AssetConfig.LoggingPublicURL)
if resp == nil || resp.StatusCode != http.StatusFound {
notice = "Notice: Logging component is not yet ready"
}
}
ch <- notice
}()

go func() {
notice := ""
if config.AssetConfig.MetricsPublicURL != "" {
resp, _ := insecureCli.Get(config.AssetConfig.MetricsPublicURL + "/status")
if resp == nil || resp.StatusCode != http.StatusOK {
notice = "Notice: Metrics component is not yet ready"
}
}
ch <- notice
}()

for i := 0; i < 2; i++ {
notice := <-ch
if notice != "" {
fmt.Fprintln(out, notice)
notReady++
}
}

if notReady > 0 {
fmt.Fprintf(out, "\nNotice: %d OpenShift component(s) are not yet ready (see above)\n", notReady)
return fmt.Errorf("")
}

return nil
}
Expand Down Expand Up @@ -145,6 +223,7 @@ func status(container *docker.Container, config *api.MasterConfig) string {
} else {
status = status + fmt.Sprintf("Data will be discarded when cluster is destroyed\n")
}
status = status + fmt.Sprintf("\n")

return status
}
2 changes: 1 addition & 1 deletion pkg/bootstrap/docker/up.go
Expand Up @@ -980,7 +980,7 @@ func (c *ClientStartConfig) ServerInfo(out io.Writer) error {
metricsInfo := ""
if c.ShouldInstallMetrics && c.ShouldInitializeData() {
metricsInfo = fmt.Sprintf("The metrics service is available at:\n"+
" https://%s\n\n", openshift.MetricsHost(c.RoutingSuffix, c.ServerIP))
" https://%s/hawkular/metrics\n\n", openshift.MetricsHost(c.RoutingSuffix, c.ServerIP))
}
loggingInfo := ""
if c.ShouldInstallLogging && c.ShouldInitializeData() {
Expand Down

0 comments on commit a014711

Please sign in to comment.