Skip to content

Commit

Permalink
Explain why memberlist message history is empty (#164)
Browse files Browse the repository at this point in the history
This section is almost always empty, unless the buffer is not zero.
Mention that on the status page to make troubleshooting easier.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
  • Loading branch information
colega committed May 5, 2022
1 parent 68f3058 commit 4d72380
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 76 deletions.
26 changes: 14 additions & 12 deletions kv/memberlist/http_status_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ type HTTPStatusHandler struct {

// StatusPageData represents the data passed to the template rendered by HTTPStatusHandler
type StatusPageData struct {
Now time.Time
Memberlist *memberlist.Memberlist
SortedMembers []*memberlist.Node
Store map[string]ValueDesc
SentMessages []Message
ReceivedMessages []Message
Now time.Time
Memberlist *memberlist.Memberlist
SortedMembers []*memberlist.Node
Store map[string]ValueDesc
MessageHistoryBufferBytes int
SentMessages []Message
ReceivedMessages []Message
}

// NewHTTPStatusHandler creates a new HTTPStatusHandler that will render the provided template using the data from StatusPageData.
Expand Down Expand Up @@ -100,12 +101,13 @@ func (h HTTPStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
sent, received := kv.getSentAndReceivedMessages()

v := StatusPageData{
Now: time.Now(),
Memberlist: kv.memberlist,
SortedMembers: members,
Store: kv.storeCopy(),
SentMessages: sent,
ReceivedMessages: received,
Now: time.Now(),
Memberlist: kv.memberlist,
SortedMembers: members,
Store: kv.storeCopy(),
MessageHistoryBufferBytes: kv.cfg.MessageHistoryBufferBytes,
SentMessages: sent,
ReceivedMessages: received,
}

accept := req.Header.Get("Accept")
Expand Down
135 changes: 71 additions & 64 deletions kv/memberlist/status.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,76 +70,83 @@

<p>State: 0 = Alive, 1 = Suspect, 2 = Dead, 3 = Left</p>

<h2>Received Messages</h2>
<h2>Message History</h2>

<a href="?deleteMessages=true">Delete All Messages (received and sent)</a>
{{ if .MessageHistoryBufferBytes }}

<table width="100%" border="1">
<thead>
<tr>
<th>ID</th>
<th>Time</th>
<th>Key</th>
<th>Value in the Message</th>
<th>Version After Update (0 = no change)</th>
<th>Changes</th>
<th>Actions</th>
</tr>
</thead>
<h3>Received Messages</h3>

<tbody>
{{ range .ReceivedMessages }}
<a href="?deleteMessages=true">Delete All Messages (received and sent)</a>

<table width="100%" border="1">
<thead>
<tr>
<td>{{ .ID }}</td>
<td>{{ .Time.Format "15:04:05.000" }}</td>
<td>{{ .Pair.Key }}</td>
<td>size: {{ .Pair.Value | len }}, codec: {{ .Pair.Codec }}</td>
<td>{{ .Version }}</td>
<td>{{ StringsJoin .Changes ", " }}</td>
<td>
<a href="?viewMsg={{ .ID }}&format=json">json</a>
| <a href="?viewMsg={{ .ID }}&format=json-pretty">json-pretty</a>
| <a href="?viewMsg={{ .ID }}&format=struct">struct</a>
</td>
<th>ID</th>
<th>Time</th>
<th>Key</th>
<th>Value in the Message</th>
<th>Version After Update (0 = no change)</th>
<th>Changes</th>
<th>Actions</th>
</tr>
{{ end }}
</tbody>
</table>

<h2>Sent Messages</h2>

<a href="?deleteMessages=true">Delete All Messages (received and sent)</a>

<table width="100%" border="1">
<thead>
<tr>
<th>ID</th>
<th>Time</th>
<th>Key</th>
<th>Value</th>
<th>Version</th>
<th>Changes</th>
<th>Actions</th>
</tr>
</thead>

<tbody>
{{ range .SentMessages }}
</thead>

<tbody>
{{ range .ReceivedMessages }}
<tr>
<td>{{ .ID }}</td>
<td>{{ .Time.Format "15:04:05.000" }}</td>
<td>{{ .Pair.Key }}</td>
<td>size: {{ .Pair.Value | len }}, codec: {{ .Pair.Codec }}</td>
<td>{{ .Version }}</td>
<td>{{ StringsJoin .Changes ", " }}</td>
<td>
<a href="?viewMsg={{ .ID }}&format=json">json</a>
| <a href="?viewMsg={{ .ID }}&format=json-pretty">json-pretty</a>
| <a href="?viewMsg={{ .ID }}&format=struct">struct</a>
</td>
</tr>
{{ end }}
</tbody>
</table>

<h3>Sent Messages</h3>

<a href="?deleteMessages=true">Delete All Messages (received and sent)</a>

<table width="100%" border="1">
<thead>
<tr>
<td>{{ .ID }}</td>
<td>{{ .Time.Format "15:04:05.000" }}</td>
<td>{{ .Pair.Key }}</td>
<td>size: {{ .Pair.Value | len }}, codec: {{ .Pair.Codec }}</td>
<td>{{ .Version }}</td>
<td>{{ StringsJoin .Changes ", " }}</td>
<td>
<a href="?viewMsg={{ .ID }}&format=json">json</a>
| <a href="?viewMsg={{ .ID }}&format=json-pretty">json-pretty</a>
| <a href="?viewMsg={{ .ID }}&format=struct">struct</a>
</td>
<th>ID</th>
<th>Time</th>
<th>Key</th>
<th>Value</th>
<th>Version</th>
<th>Changes</th>
<th>Actions</th>
</tr>
{{ end }}
</tbody>
</table>
</thead>

<tbody>
{{ range .SentMessages }}
<tr>
<td>{{ .ID }}</td>
<td>{{ .Time.Format "15:04:05.000" }}</td>
<td>{{ .Pair.Key }}</td>
<td>size: {{ .Pair.Value | len }}, codec: {{ .Pair.Codec }}</td>
<td>{{ .Version }}</td>
<td>{{ StringsJoin .Changes ", " }}</td>
<td>
<a href="?viewMsg={{ .ID }}&format=json">json</a>
| <a href="?viewMsg={{ .ID }}&format=json-pretty">json-pretty</a>
| <a href="?viewMsg={{ .ID }}&format=struct">struct</a>
</td>
</tr>
{{ end }}
</tbody>
</table>
{{ else }}
<p><i>Message history buffer is disabled, refer to the configuration to enable it in order to troubleshoot the message history.</i></p>
{{ end }}
</body>
</html>

0 comments on commit 4d72380

Please sign in to comment.