Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
cmd/init, cmd/join: Explain why some API errors still indicate a heal…
Browse files Browse the repository at this point in the history
…thy endpoint
  • Loading branch information
Daniel Lipovetsky authored and dlipovetsky committed Sep 4, 2018
1 parent 0a37c60 commit 8f229f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ var initCmd = &cobra.Command{
log.Printf("[health] Error checking health: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), constants.DefaultEtcdRequestTimeout)
_, err = client.Get(ctx, "health")
_, err = client.Get(ctx, constants.EtcdHealthCheckKey)
cancel()
// Healthy because the cluster reaches consensus for the get request,
// even if permission (to get the key) is denied.
if err == nil || err == rpctypes.ErrPermissionDenied {
log.Println("[health] Local etcd endpoint is healthy")
} else {
Expand Down
4 changes: 3 additions & 1 deletion cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ var joinCmd = &cobra.Command{
log.Printf("[health] Error checking health: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), constants.DefaultEtcdRequestTimeout)
_, err = client.Get(ctx, "health")
_, err = client.Get(ctx, constants.EtcdHealthCheckKey)
cancel()
// Healthy because the cluster reaches consensus for the get request,
// even if permission (to get the key) is denied.
if err == nil || err == rpctypes.ErrPermissionDenied {
log.Println("[health] Local etcd endpoint is healthy")
} else {
Expand Down
2 changes: 2 additions & 0 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const (
DefaultDownloadConnectTimeout = 10 * time.Second
DefaultEtcdRequestTimeout = 5 * time.Second

EtcdHealthCheckKey = "health"

// EtcdCACertAndKeyBaseName defines etcd's CA certificate and key base name
EtcdCACertAndKeyBaseName = "ca"
// EtcdCACertName defines etcd's CA certificate name
Expand Down

0 comments on commit 8f229f4

Please sign in to comment.