@@ -49,8 +49,7 @@ var addRemoveBackoff = wait.Backoff{
49
49
50
50
// ClusterInterrogator is an interface to get etcd cluster related information
51
51
type ClusterInterrogator interface {
52
- ClusterAvailable () (bool , error )
53
- GetClusterStatus () (map [string ]* clientv3.StatusResponse , error )
52
+ CheckClusterHealth () error
54
53
GetClusterVersions () (map [string ]string , error )
55
54
GetVersion () (string , error )
56
55
WaitForClusterAvailable (retries int , retryInterval time.Duration ) (bool , error )
@@ -314,7 +313,7 @@ func (c *Client) GetVersion() (string, error) {
314
313
// GetClusterVersions returns a map of the endpoints and their associated versions
315
314
func (c * Client ) GetClusterVersions () (map [string ]string , error ) {
316
315
versions := make (map [string ]string )
317
- statuses , err := c .GetClusterStatus ()
316
+ statuses , err := c .getClusterStatus ()
318
317
if err != nil {
319
318
return versions , err
320
319
}
@@ -325,17 +324,14 @@ func (c *Client) GetClusterVersions() (map[string]string, error) {
325
324
return versions , nil
326
325
}
327
326
328
- // ClusterAvailable returns true if the cluster status indicates the cluster is available.
329
- func (c * Client ) ClusterAvailable () (bool , error ) {
330
- _ , err := c .GetClusterStatus ()
331
- if err != nil {
332
- return false , err
333
- }
334
- return true , nil
327
+ // CheckClusterHealth returns nil for status Up or error for status Down
328
+ func (c * Client ) CheckClusterHealth () error {
329
+ _ , err := c .getClusterStatus ()
330
+ return err
335
331
}
336
332
337
- // GetClusterStatus returns nil for status Up or error for status Down
338
- func (c * Client ) GetClusterStatus () (map [string ]* clientv3.StatusResponse , error ) {
333
+ // getClusterStatus returns nil for status Up (along with endpoint status response map) or error for status Down
334
+ func (c * Client ) getClusterStatus () (map [string ]* clientv3.StatusResponse , error ) {
339
335
cli , err := clientv3 .New (clientv3.Config {
340
336
Endpoints : c .Endpoints ,
341
337
DialTimeout : dialTimeout ,
@@ -370,7 +366,7 @@ func (c *Client) WaitForClusterAvailable(retries int, retryInterval time.Duratio
370
366
time .Sleep (retryInterval )
371
367
}
372
368
klog .V (2 ).Infof ("[etcd] attempting to see if all cluster endpoints (%s) are available %d/%d" , c .Endpoints , i + 1 , retries )
373
- resp , err := c .ClusterAvailable ()
369
+ _ , err := c .getClusterStatus ()
374
370
if err != nil {
375
371
switch err {
376
372
case context .DeadlineExceeded :
@@ -380,7 +376,7 @@ func (c *Client) WaitForClusterAvailable(retries int, retryInterval time.Duratio
380
376
}
381
377
continue
382
378
}
383
- return resp , nil
379
+ return true , nil
384
380
}
385
381
return false , errors .New ("timeout waiting for etcd cluster to be available" )
386
382
}
0 commit comments