|
6 | 6 | "errors" |
7 | 7 | "fmt" |
8 | 8 | "io/ioutil" |
9 | | - "net/http" |
10 | 9 | "time" |
11 | 10 |
|
12 | 11 | "github.com/kubernetes-incubator/bootkube/pkg/asset" |
@@ -102,34 +101,22 @@ func waitEtcdTPRReady(restClient restclient.Interface, ns string) error { |
102 | 101 |
|
103 | 102 | func createBootstrapEtcdService(kubecli kubernetes.Interface, svcPath string) error { |
104 | 103 | // Create the service. |
105 | | - svc, err := ioutil.ReadFile(svcPath) |
| 104 | + svcb, err := ioutil.ReadFile(svcPath) |
106 | 105 | if err != nil { |
107 | 106 | return err |
108 | 107 | } |
109 | | - if err := kubecli.CoreV1().RESTClient().Post().RequestURI(fmt.Sprintf("/api/v1/namespaces/%s/services", api.NamespaceSystem)).SetHeader("Content-Type", "application/json").Body(svc).Do().Error(); err != nil { |
| 108 | + if err := kubecli.CoreV1().RESTClient().Post().RequestURI(fmt.Sprintf("/api/v1/namespaces/%s/services", api.NamespaceSystem)).SetHeader("Content-Type", "application/json").Body(svcb).Do().Error(); err != nil { |
| 109 | + return err |
| 110 | + } |
| 111 | + |
| 112 | + svc, err := kubecli.CoreV1().Services(api.NamespaceSystem).Get(bootstrapEtcdServiceName, v1.GetOptions{}) |
| 113 | + if err != nil { |
| 114 | + glog.Errorf("failed to get bootstrap etcd service: %v", err) |
110 | 115 | return err |
111 | 116 | } |
112 | 117 |
|
113 | 118 | // Wait for the service to be reachable (sometimes this takes a little while). |
114 | | - if err := wait.Poll(pollInterval, pollTimeout, func() (bool, error) { |
115 | | - svc, err := kubecli.CoreV1().Services(api.NamespaceSystem).Get(bootstrapEtcdServiceName, v1.GetOptions{}) |
116 | | - if err != nil { |
117 | | - glog.Errorf("failed to get bootstrap etcd service: %v", err) |
118 | | - return false, nil |
119 | | - } |
120 | | - resp, err := http.Get(fmt.Sprintf("http://%s:12379/version", svc.Spec.ClusterIP)) |
121 | | - if err != nil { |
122 | | - glog.Infof("could not read bootstrap etcd version: %v", err) |
123 | | - return false, nil |
124 | | - } |
125 | | - defer resp.Body.Close() |
126 | | - body, err := ioutil.ReadAll(resp.Body) |
127 | | - if len(body) == 0 || err != nil { |
128 | | - glog.Infof("could not read boot-etcd version: %v", err) |
129 | | - return false, nil |
130 | | - } |
131 | | - return true, nil |
132 | | - }); err != nil { |
| 119 | + if err := WaitClusterReady(svc.Spec.ClusterIP + ":12379"); err != nil { |
133 | 120 | return fmt.Errorf("timed out waiting for bootstrap etcd service: %s", err) |
134 | 121 | } |
135 | 122 | return nil |
|
0 commit comments