1
1
package docker
2
2
3
3
import (
4
+ "crypto/tls"
4
5
"fmt"
5
6
"io"
7
+ "net/http"
6
8
"os"
7
9
"strings"
8
10
"time"
@@ -13,6 +15,7 @@ import (
13
15
14
16
"github.com/openshift/origin/pkg/bootstrap/docker/dockerhelper"
15
17
"github.com/openshift/origin/pkg/bootstrap/docker/errors"
18
+ "github.com/openshift/origin/pkg/bootstrap/docker/exec"
16
19
"github.com/openshift/origin/pkg/bootstrap/docker/openshift"
17
20
"github.com/openshift/origin/pkg/cmd/server/api"
18
21
"github.com/openshift/origin/pkg/cmd/templates"
@@ -48,7 +51,9 @@ func NewCmdStatus(name, fullName string, f *clientcmd.Factory, out io.Writer) *c
48
51
Run : func (c * cobra.Command , args []string ) {
49
52
err := config .Status (f , out )
50
53
if err != nil {
51
- PrintError (err , out )
54
+ if err .Error () != "" {
55
+ PrintError (err , out )
56
+ }
52
57
os .Exit (1 )
53
58
}
54
59
},
@@ -92,7 +97,80 @@ func (c *ClientStatusConfig) Status(f *clientcmd.Factory, out io.Writer) error {
92
97
return err
93
98
}
94
99
95
- fmt .Print (status (container , config ))
100
+ fmt .Fprint (out , status (container , config ))
101
+
102
+ notReady := 0
103
+
104
+ eh := exec .NewExecHelper (dockerClient , openshift .OpenShiftContainer )
105
+
106
+ stdout , _ , _ := eh .Command ("oc" , "get" , "dc" , "docker-registry" , "-n" , "default" , "-o" , "template" , "--template" , "{{.status.availableReplicas}}" ).Output ()
107
+ if stdout != "1" {
108
+ fmt .Fprintln (out , "Notice: Docker registry is not yet ready" )
109
+ notReady ++
110
+ }
111
+
112
+ stdout , _ , _ = eh .Command ("oc" , "get" , "dc" , "router" , "-n" , "default" , "-o" , "template" , "--template" , "{{.status.availableReplicas}}" ).Output ()
113
+ if stdout != "1" {
114
+ fmt .Fprintln (out , "Notice: Router is not yet ready" )
115
+ notReady ++
116
+ }
117
+
118
+ stdout , _ , _ = eh .Command ("oc" , "get" , "job" , "persistent-volume-setup" , "-n" , "default" , "-o" , "template" , "--template" , "{{.status.succeeded}}" ).Output ()
119
+ if stdout != "1" {
120
+ fmt .Fprintln (out , "Notice: Persistent volumes are not yet ready" )
121
+ notReady ++
122
+ }
123
+
124
+ stdout , _ , _ = eh .Command ("oc" , "get" , "is" , "-n" , "openshift" , "-o" , "template" , "--template" , `{{range .items}}{{if not .status.tags}}notready{{end}}{{end}}` ).Output ()
125
+ if len (stdout ) > 0 {
126
+ fmt .Fprintln (out , "Notice: Imagestreams are not yet ready" )
127
+ notReady ++
128
+ }
129
+
130
+ insecureCli := http.Client {
131
+ Transport : & http.Transport {
132
+ TLSClientConfig : & tls.Config {
133
+ InsecureSkipVerify : true ,
134
+ },
135
+ },
136
+ Timeout : 10 * time .Second ,
137
+ }
138
+
139
+ ch := make (chan string )
140
+ go func () {
141
+ notice := ""
142
+ if config .AssetConfig .LoggingPublicURL != "" {
143
+ resp , _ := insecureCli .Get (config .AssetConfig .LoggingPublicURL )
144
+ if resp == nil || resp .StatusCode != http .StatusFound {
145
+ notice = "Notice: Logging component is not yet ready"
146
+ }
147
+ }
148
+ ch <- notice
149
+ }()
150
+
151
+ go func () {
152
+ notice := ""
153
+ if config .AssetConfig .MetricsPublicURL != "" {
154
+ resp , _ := insecureCli .Get (config .AssetConfig .MetricsPublicURL + "/status" )
155
+ if resp == nil || resp .StatusCode != http .StatusOK {
156
+ notice = "Notice: Metrics component is not yet ready"
157
+ }
158
+ }
159
+ ch <- notice
160
+ }()
161
+
162
+ for i := 0 ; i < 2 ; i ++ {
163
+ notice := <- ch
164
+ if notice != "" {
165
+ fmt .Fprintln (out , notice )
166
+ notReady ++
167
+ }
168
+ }
169
+
170
+ if notReady > 0 {
171
+ fmt .Fprintf (out , "\n Notice: %d OpenShift component(s) are not yet ready (see above)\n " , notReady )
172
+ return fmt .Errorf ("" )
173
+ }
96
174
97
175
return nil
98
176
}
@@ -145,6 +223,7 @@ func status(container *docker.Container, config *api.MasterConfig) string {
145
223
} else {
146
224
status = status + fmt .Sprintf ("Data will be discarded when cluster is destroyed\n " )
147
225
}
226
+ status = status + fmt .Sprintf ("\n " )
148
227
149
228
return status
150
229
}
0 commit comments