-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: fix health status with tls enabled #969
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0486fde
fix health status with tls enabled
Connor1996 ac20347
fix data race
Connor1996 f4bec29
reuse dialClient in redriector
Connor1996 37a0f86
unexport
Connor1996 a9a8b88
disable keep alive
Connor1996 48b7dc1
fix test
Connor1996 8c8c3c8
address comment
Connor1996 2059a45
Merge branch 'master' into fix-https-health
Connor1996 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,14 @@ import ( | |
"github.com/unrolled/render" | ||
) | ||
|
||
type metaStore struct { | ||
// MetaStore contains meta information about a store. | ||
type MetaStore struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why public heere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tidb_exporter need these structs to unmarshal |
||
*metapb.Store | ||
StateName string `json:"state_name"` | ||
} | ||
|
||
type storeStatus struct { | ||
// StoreStatus contains status about a store. | ||
type StoreStatus struct { | ||
Capacity typeutil.ByteSize `json:"capacity,omitempty"` | ||
Available typeutil.ByteSize `json:"available,omitempty"` | ||
LeaderCount int `json:"leader_count,omitempty"` | ||
|
@@ -53,23 +55,24 @@ type storeStatus struct { | |
Uptime *typeutil.Duration `json:"uptime,omitempty"` | ||
} | ||
|
||
type storeInfo struct { | ||
Store *metaStore `json:"store"` | ||
Status *storeStatus `json:"status"` | ||
// StoreInfo contains information about a store. | ||
type StoreInfo struct { | ||
Store *MetaStore `json:"store"` | ||
Status *StoreStatus `json:"status"` | ||
} | ||
|
||
const ( | ||
disconnectedName = "Disconnected" | ||
downStateName = "Down" | ||
) | ||
|
||
func newStoreInfo(store *core.StoreInfo, maxStoreDownTime time.Duration) *storeInfo { | ||
s := &storeInfo{ | ||
Store: &metaStore{ | ||
func newStoreInfo(store *core.StoreInfo, maxStoreDownTime time.Duration) *StoreInfo { | ||
s := &StoreInfo{ | ||
Store: &MetaStore{ | ||
Store: store.Store, | ||
StateName: store.State.String(), | ||
}, | ||
Status: &storeStatus{ | ||
Status: &StoreStatus{ | ||
Capacity: typeutil.ByteSize(store.Stats.GetCapacity()), | ||
Available: typeutil.ByteSize(store.Stats.GetAvailable()), | ||
LeaderCount: store.LeaderCount, | ||
|
@@ -111,7 +114,7 @@ func newStoreInfo(store *core.StoreInfo, maxStoreDownTime time.Duration) *storeI | |
|
||
type storesInfo struct { | ||
Count int `json:"count"` | ||
Stores []*storeInfo `json:"stores"` | ||
Stores []*StoreInfo `json:"stores"` | ||
} | ||
|
||
type storeHandler struct { | ||
|
@@ -324,7 +327,7 @@ func (h *storesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
|
||
stores := cluster.GetStores() | ||
storesInfo := &storesInfo{ | ||
Stores: make([]*storeInfo, 0, len(stores)), | ||
Stores: make([]*StoreInfo, 0, len(stores)), | ||
} | ||
|
||
urlFilter, err := newStoreStateFilter(r.URL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore error?