-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add HealthCheck's healthy
map to the VTGate UI
#14521
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,14 @@ var ( | |
|
||
// How much to sleep between each check. | ||
waitAvailableTabletInterval = 100 * time.Millisecond | ||
|
||
// HealthCheckCacheTemplate uses healthCheckTemplate with the `HealthCheck Tablet - Cache` title to create the | ||
// HTML code required to render the cache of the HealthCheck. | ||
HealthCheckCacheTemplate = fmt.Sprintf(healthCheckTemplate, "HealthCheck Tablet - Cache") | ||
|
||
// HealthCheckHealthyTemplate uses healthCheckTemplate with the `HealthCheck Tablet - Healthy Tablets` title to | ||
// create the HTML code required to render the list of healthy tablets from the HealthCheck. | ||
HealthCheckHealthyTemplate = fmt.Sprintf(healthCheckTemplate, "HealthCheck Tablet - Healthy Tablets") | ||
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. Can possibly drop "Tablet", so that the headers show up as "HealthCheck - Cache" and "HealthCheck - Healthy Tablets" 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. Fixed via f6d526e |
||
) | ||
|
||
// See the documentation for NewHealthCheck below for an explanation of these parameters. | ||
|
@@ -104,8 +112,9 @@ const ( | |
// DefaultTopologyWatcherRefreshInterval is used as the default value for | ||
// the refresh interval of a topology watcher. | ||
DefaultTopologyWatcherRefreshInterval = 1 * time.Minute | ||
// HealthCheckTemplate is the HTML code to display a TabletsCacheStatusList | ||
HealthCheckTemplate = ` | ||
// healthCheckTemplate is the HTML code to display a TabletsCacheStatusList, it takes a parameter for the title | ||
// as the template can be used for both HealthCheck's cache and healthy tablets list. | ||
healthCheckTemplate = ` | ||
<style> | ||
table { | ||
border-collapse: collapse; | ||
|
@@ -117,7 +126,7 @@ const ( | |
</style> | ||
<table class="refreshRequired"> | ||
<tr> | ||
<th colspan="5">HealthCheck Tablet Cache</th> | ||
<th colspan="5">%s</th> | ||
</tr> | ||
<tr> | ||
<th>Cell</th> | ||
|
@@ -193,6 +202,9 @@ type HealthCheck interface { | |
// CacheStatus returns a displayable version of the health check cache. | ||
CacheStatus() TabletsCacheStatusList | ||
|
||
// HealthyStatus returns a displayable version of the health check healthy list. | ||
HealthyStatus() TabletsCacheStatusList | ||
|
||
// CacheStatusMap returns a map of the health check cache. | ||
CacheStatusMap() map[string]*TabletsCacheStatus | ||
|
||
|
@@ -622,28 +634,55 @@ func (hc *HealthCheckImpl) CacheStatus() TabletsCacheStatusList { | |
return tcsl | ||
} | ||
|
||
// HealthyStatus returns a displayable version of the cache. | ||
func (hc *HealthCheckImpl) HealthyStatus() TabletsCacheStatusList { | ||
tcsMap := hc.HealthyStatusMap() | ||
tcsl := make(TabletsCacheStatusList, 0, len(tcsMap)) | ||
for _, tcs := range tcsMap { | ||
tcsl = append(tcsl, tcs) | ||
} | ||
sort.Sort(tcsl) | ||
return tcsl | ||
} | ||
|
||
func (hc *HealthCheckImpl) CacheStatusMap() map[string]*TabletsCacheStatus { | ||
tcsMap := make(map[string]*TabletsCacheStatus) | ||
hc.mu.Lock() | ||
defer hc.mu.Unlock() | ||
for _, ths := range hc.healthData { | ||
for _, th := range ths { | ||
key := fmt.Sprintf("%v.%v.%v.%v", th.Tablet.Alias.Cell, th.Target.Keyspace, th.Target.Shard, th.Target.TabletType.String()) | ||
var tcs *TabletsCacheStatus | ||
var ok bool | ||
if tcs, ok = tcsMap[key]; !ok { | ||
tcs = &TabletsCacheStatus{ | ||
Cell: th.Tablet.Alias.Cell, | ||
Target: th.Target, | ||
} | ||
tcsMap[key] = tcs | ||
} | ||
tcs.TabletsStats = append(tcs.TabletsStats, th) | ||
tabletHealthToTabletCacheStatus(th, tcsMap) | ||
} | ||
} | ||
return tcsMap | ||
} | ||
|
||
func (hc *HealthCheckImpl) HealthyStatusMap() map[string]*TabletsCacheStatus { | ||
tcsMap := make(map[string]*TabletsCacheStatus) | ||
hc.mu.Lock() | ||
defer hc.mu.Unlock() | ||
for _, ths := range hc.healthy { | ||
for _, th := range ths { | ||
tabletHealthToTabletCacheStatus(th, tcsMap) | ||
} | ||
} | ||
return tcsMap | ||
} | ||
|
||
func tabletHealthToTabletCacheStatus(th *TabletHealth, tcsMap map[string]*TabletsCacheStatus) { | ||
frouioui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key := fmt.Sprintf("%v.%v.%v.%v", th.Tablet.Alias.Cell, th.Target.Keyspace, th.Target.Shard, th.Target.TabletType.String()) | ||
var tcs *TabletsCacheStatus | ||
var ok bool | ||
if tcs, ok = tcsMap[key]; !ok { | ||
tcs = &TabletsCacheStatus{ | ||
Cell: th.Tablet.Alias.Cell, | ||
Target: th.Target, | ||
} | ||
tcsMap[key] = tcs | ||
} | ||
tcs.TabletsStats = append(tcs.TabletsStats, th) | ||
} | ||
|
||
// Close stops the healthcheck. | ||
func (hc *HealthCheckImpl) Close() error { | ||
hc.mu.Lock() | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
here we have "Healthy Tablets" but in the vtcombo version it is just "Healthy". i think we should be consistent between the two, but i have no preference which one you standardize on
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.
I would even suggest dropping "Tablet" from the table headers. Hope no one is depending on the header values though :)
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.
Good catch thank you!
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.
Fixed via f6d526e