88
99 s3 "github.com/aws/aws-sdk-go/service/s3"
1010 "github.com/deis/builder/pkg/gitreceive/log"
11+ "github.com/deis/builder/pkg/sshd"
1112 "k8s.io/kubernetes/pkg/fields"
1213 "k8s.io/kubernetes/pkg/labels"
1314)
@@ -25,12 +26,21 @@ func convertBucket(b *s3.Bucket) healthZRespBucket {
2526}
2627
2728type healthZResp struct {
28- Namespaces []string `json:"k8s_namespaces"`
29- S3Buckets []healthZRespBucket `json:"s3_buckets"`
29+ Namespaces []string `json:"k8s_namespaces"`
30+ S3Buckets []healthZRespBucket `json:"s3_buckets"`
31+ SSHServerStarted bool `json:"ssh_server_started"`
3032}
3133
32- func healthZHandler (nsLister NamespaceLister , bLister BucketLister ) http.Handler {
34+ func healthZHandler (nsLister NamespaceLister , bLister BucketLister , serverCircuit * sshd. Circuit ) http.Handler {
3335 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
36+ // there's a race between the boolean eval and the HTTP error returned, but k8s will repeat the health probe request
37+ // and effectively re-evaluate the boolean.
38+ if serverCircuit .State () != sshd .ClosedState {
39+ str := fmt .Sprintf ("SSH Server is not yet started" )
40+ log .Err (str )
41+ http .Error (w , str , http .StatusAccepted )
42+ return
43+ }
3444 lbOut , err := bLister .ListBuckets (& s3.ListBucketsInput {})
3545 if err != nil {
3646 str := fmt .Sprintf ("Error listing buckets (%s)" , err )
@@ -53,7 +63,7 @@ func healthZHandler(nsLister NamespaceLister, bLister BucketLister) http.Handler
5363 for _ , ns := range nsList .Items {
5464 rsp .Namespaces = append (rsp .Namespaces , ns .Name )
5565 }
56-
66+ rsp . SSHServerStarted = true
5767 if err := json .NewEncoder (w ).Encode (rsp ); err != nil {
5868 str := fmt .Sprintf ("Error encoding JSON (%s)" , err )
5969 http .Error (w , str , http .StatusInternalServerError )
0 commit comments