mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-08 10:37:00 +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>
82 lines
1.4 KiB
Go
82 lines
1.4 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 (
|
|
"strings"
|
|
|
|
"github.com/siderolabs/gen/xslices"
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
"github.com/siderolabs/omni/internal/backend/dns"
|
|
)
|
|
|
|
const (
|
|
nodeHeaderKey = "node"
|
|
nodesHeaderKey = "nodes"
|
|
)
|
|
|
|
// NodeResolver resolves a given cluster and a node name to an IP address.
|
|
type NodeResolver interface {
|
|
Resolve(cluster, node string) dns.Info
|
|
}
|
|
|
|
type resolvedNodeInfo struct {
|
|
node dns.Info
|
|
nodes []dns.Info
|
|
|
|
nodeOk bool
|
|
}
|
|
|
|
func resolveNodes(dnsService NodeResolver, md metadata.MD) resolvedNodeInfo {
|
|
var (
|
|
node string
|
|
nodes []string
|
|
|
|
nodeOK bool
|
|
)
|
|
|
|
if nodeVal := md.Get(nodeHeaderKey); len(nodeVal) > 0 {
|
|
nodeOK = true
|
|
|
|
node = nodeVal[0]
|
|
}
|
|
|
|
if nodesVal := md.Get(nodesHeaderKey); len(nodesVal) > 0 {
|
|
nodes = make([]string, 0, len(nodesVal)*2)
|
|
for _, n := range nodesVal {
|
|
nodes = append(nodes, strings.Split(n, ",")...)
|
|
}
|
|
}
|
|
|
|
cluster := getClusterName(md)
|
|
|
|
resolveNode := func(val string) dns.Info {
|
|
var resolved dns.Info
|
|
|
|
if val != "" {
|
|
resolved = dnsService.Resolve(cluster, val)
|
|
}
|
|
|
|
if resolved.GetAddress() == "" {
|
|
return dns.NewInfo(
|
|
cluster,
|
|
val,
|
|
val,
|
|
val,
|
|
)
|
|
}
|
|
|
|
return resolved
|
|
}
|
|
|
|
return resolvedNodeInfo{
|
|
node: resolveNode(node),
|
|
nodes: xslices.Map(nodes, resolveNode),
|
|
nodeOk: nodeOK,
|
|
}
|
|
}
|