metropolis: reduce usage of identity.NodeID
Eventually, we want to be able to rotate node keypairs. To allow this,
the node ID needs to become independent of the public key. This change
is a refactoring which starts this work by reducing the usage of
identity.NodeID, the function which derives a node ID from a public key.
Change-Id: I5231ed0a7be37c23327fec93481b00c74374af07
Reviewed-on: https://review.monogon.dev/c/monogon/+/3445
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/cli/metroctl/BUILD.bazel b/metropolis/cli/metroctl/BUILD.bazel
index 50dc1eb..5372cc5 100644
--- a/metropolis/cli/metroctl/BUILD.bazel
+++ b/metropolis/cli/metroctl/BUILD.bazel
@@ -42,7 +42,6 @@
"//metropolis/cli/flagdefs",
"//metropolis/cli/metroctl/core",
"//metropolis/node",
- "//metropolis/node/core/identity",
"//metropolis/node/core/rpc",
"//metropolis/node/core/rpc/resolver",
"//metropolis/proto/api",
diff --git a/metropolis/cli/metroctl/cmd_node.go b/metropolis/cli/metroctl/cmd_node.go
index d7a23ee..30dd965 100644
--- a/metropolis/cli/metroctl/cmd_node.go
+++ b/metropolis/cli/metroctl/cmd_node.go
@@ -17,7 +17,6 @@
"source.monogon.dev/go/clitable"
"source.monogon.dev/metropolis/cli/metroctl/core"
- "source.monogon.dev/metropolis/node/core/identity"
"source.monogon.dev/version"
apb "source.monogon.dev/metropolis/proto/api"
@@ -154,13 +153,12 @@
for _, n := range nodes {
// Filter the information we want client-side.
- nid := identity.NodeID(n.Pubkey)
if len(qids) != 0 {
- if _, e := qids[nid]; !e {
+ if _, e := qids[n.Id]; !e {
continue
}
}
- if excludedNodes[nid] {
+ if excludedNodes[n.Id] {
continue
}
@@ -450,8 +448,7 @@
for _, n := range nodes {
// Filter the information we want client-side.
if len(qids) != 0 {
- nid := identity.NodeID(n.Pubkey)
- if _, e := qids[nid]; !e {
+ if _, e := qids[n.Id]; !e {
continue
}
}
diff --git a/metropolis/cli/metroctl/cmd_node_approve.go b/metropolis/cli/metroctl/cmd_node_approve.go
index 294f8c3..a70f6b3 100644
--- a/metropolis/cli/metroctl/cmd_node_approve.go
+++ b/metropolis/cli/metroctl/cmd_node_approve.go
@@ -10,7 +10,6 @@
"github.com/spf13/cobra"
"source.monogon.dev/metropolis/cli/metroctl/core"
- "source.monogon.dev/metropolis/node/core/identity"
"source.monogon.dev/metropolis/proto/api"
)
@@ -28,7 +27,7 @@
// nodeById returns the node matching id, if it exists within nodes.
func nodeById(nodes []*api.Node, id string) *api.Node {
for _, n := range nodes {
- if identity.NodeID(n.Pubkey) == id {
+ if n.Id == id {
return n
}
}
@@ -52,7 +51,7 @@
// If no id was given, just list the nodes pending approval.
if len(nodes) != 0 {
for _, n := range nodes {
- fmt.Println(identity.NodeID(n.Pubkey))
+ fmt.Println(n.Id)
}
} else {
log.Print("There are no nodes pending approval at this time.")
diff --git a/metropolis/cli/metroctl/table_node.go b/metropolis/cli/metroctl/table_node.go
index 9c79489..2f8317d 100644
--- a/metropolis/cli/metroctl/table_node.go
+++ b/metropolis/cli/metroctl/table_node.go
@@ -6,7 +6,6 @@
"strings"
"source.monogon.dev/go/clitable"
- "source.monogon.dev/metropolis/node/core/identity"
apb "source.monogon.dev/metropolis/proto/api"
cpb "source.monogon.dev/metropolis/proto/common"
"source.monogon.dev/version"
@@ -15,7 +14,7 @@
func nodeEntry(n *apb.Node) clitable.Entry {
res := clitable.Entry{}
- res.Add("node id", identity.NodeID(n.Pubkey))
+ res.Add("node id", n.Id)
state := n.State.String()
state = strings.ReplaceAll(state, "NODE_STATE_", "")
res.Add("state", state)