-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reconnect to the logs stream in dashboard after reboot
The log stream displayed in the dashboard was stopping to work when a node was rebooted. Rework the log data source to establish a per-node connection and use a retry loop to always reconnect until the dashboard is terminated. Print the connection errors in the log stream in red color. Closes #8388. Signed-off-by: Utku Ozdemir <[email protected]> (cherry picked from commit 3735add)
- Loading branch information
1 parent
5019c9f
commit 028a5b4
Showing
6 changed files
with
132 additions
and
71 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package util provides utility functions for the dashboard. | ||
package util | ||
|
||
import ( | ||
"context" | ||
|
||
"google.golang.org/grpc/metadata" | ||
|
||
"github.com/siderolabs/talos/pkg/machinery/client" | ||
) | ||
|
||
// NodeContext contains the context.Context for a single node and the node name. | ||
type NodeContext struct { | ||
Ctx context.Context //nolint:containedctx | ||
Node string | ||
} | ||
|
||
// NodeContexts returns a list of NodeContexts from the given context. | ||
// | ||
// It extracts the node names from the outgoing GRPC context metadata. | ||
// If the node name is not present in the metadata, context will be returned as-is with an empty node name. | ||
func NodeContexts(ctx context.Context) []NodeContext { | ||
md, mdOk := metadata.FromOutgoingContext(ctx) | ||
if !mdOk { | ||
return []NodeContext{{Ctx: ctx}} | ||
} | ||
|
||
nodeVal := md.Get("node") | ||
if len(nodeVal) > 0 { | ||
return []NodeContext{{Ctx: ctx, Node: nodeVal[0]}} | ||
} | ||
|
||
nodesVal := md.Get("nodes") | ||
if len(nodesVal) == 0 { | ||
return []NodeContext{{Ctx: ctx}} | ||
} | ||
|
||
nodeContexts := make([]NodeContext, 0, len(nodesVal)) | ||
|
||
for _, node := range nodesVal { | ||
nodeContexts = append(nodeContexts, NodeContext{Ctx: client.WithNode(ctx, node), Node: node}) | ||
} | ||
|
||
return nodeContexts | ||
} |