mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-08 18:47:01 +02:00
Any insecure `talosctl` commands now work with Omni per-instance `talosconfig`. User should have at least `Operator` Omni role to be able to use the insecure `talosctl` mode. DNS resolver was updated to react on the `MachineStatus` resource creation, not only the `ClusterMachineConfigStatus` resource. That makes the DNS record for UUID appear as soon as machine joins Omni, not when the machine gets allocated into a cluster. Machines list now has maintenance Talos version update button. The UI will issue `talosctl upgrade` when another Talos version is picked. `MachineStatus` controller was updated a bit: version poller wasn't marked as dirty after maintenance upgrades. Now we mark it as dirty every time we get Talos `MachineStatus` resource update. Also fixed UI issues here and there. Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
// Copyright (c) 2024 Sidero Labs, Inc.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the LICENSE file.
|
|
|
|
package router
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/siderolabs/gen/xslices"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
"github.com/siderolabs/omni/internal/backend/dns"
|
|
)
|
|
|
|
// ResolvedNodesHeaderKey is used to propagate the node IP information from the node/nodes headers to the backend.
|
|
const ResolvedNodesHeaderKey = "resolved-nodes"
|
|
|
|
// OmniBackend implements a backend (proxying one2one to a Talos node).
|
|
type OmniBackend struct {
|
|
conn *grpc.ClientConn
|
|
nodeResolver NodeResolver
|
|
name string
|
|
}
|
|
|
|
// NewOmniBackend builds new backend.
|
|
func NewOmniBackend(name string, nodeResolver NodeResolver, conn *grpc.ClientConn) *OmniBackend {
|
|
backend := &OmniBackend{
|
|
name: name,
|
|
nodeResolver: nodeResolver,
|
|
conn: conn,
|
|
}
|
|
|
|
return backend
|
|
}
|
|
|
|
func (l *OmniBackend) String() string {
|
|
return l.name
|
|
}
|
|
|
|
// GetConnection returns a grpc connection to the backend.
|
|
func (l *OmniBackend) GetConnection(ctx context.Context, _ string) (context.Context, *grpc.ClientConn, error) {
|
|
md, _ := metadata.FromIncomingContext(ctx)
|
|
|
|
// Set resolved nodes as a header to be used by the ResourceServer.
|
|
// Use a new header to avoid signature mismatch.
|
|
resolved := resolveNodes(l.nodeResolver, md)
|
|
|
|
var allNodes []dns.Info
|
|
|
|
if resolved.nodeOk {
|
|
allNodes = append(allNodes, resolved.node)
|
|
}
|
|
|
|
allNodes = append(allNodes, resolved.nodes...)
|
|
|
|
if len(allNodes) > 0 {
|
|
md.Set(ResolvedNodesHeaderKey, xslices.Map(allNodes, func(info dns.Info) string {
|
|
return info.GetAddress()
|
|
})...)
|
|
}
|
|
|
|
outCtx := metadata.NewOutgoingContext(ctx, md)
|
|
|
|
return outCtx, l.conn, nil
|
|
}
|
|
|
|
// AppendInfo is called to enhance response from the backend with additional data.
|
|
func (l *OmniBackend) AppendInfo(_ bool, resp []byte) ([]byte, error) {
|
|
return resp, nil
|
|
}
|
|
|
|
// BuildError is called to convert error from upstream into response field.
|
|
func (l *OmniBackend) BuildError(bool, error) ([]byte, error) {
|
|
return nil, nil
|
|
}
|