diff --git a/go.mod b/go.mod index c123e607..fdbd0598 100644 --- a/go.mod +++ b/go.mod @@ -103,6 +103,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/sirupsen/logrus v1.9.3 // indirect + github.com/splode/fname v0.4.1 // indirect github.com/vektah/gqlparser/v2 v2.5.6 // indirect github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 // indirect github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect diff --git a/go.sum b/go.sum index 6afa4410..587083d4 100644 --- a/go.sum +++ b/go.sum @@ -403,6 +403,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/splode/fname v0.4.1 h1:tRBvCEoNMKMI9veue+LZ7psUFWHWRRX+rmWhqUjzmog= +github.com/splode/fname v0.4.1/go.mod h1:73RiaoonLZF/9E7lvIoxj/y2ZVfq7Gq2tNvPwADQx/8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/internal/node/config.go b/internal/node/config.go index 8bb0265c..e850cd76 100644 --- a/internal/node/config.go +++ b/internal/node/config.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + "github.com/splode/fname" agentapi "github.com/synadia-io/nex/internal/agent-api" ) @@ -109,6 +110,13 @@ func DefaultNodeConfiguration() NodeConfiguration { defaultVcpuCount := defaultNodeVcpuCount defaultMemSizeMib := defaultNodeMemSizeMib + tags := make(map[string]string) + rng := fname.NewGenerator() + nodeName, err := rng.Generate() + if err == nil { + tags["node_name"] = nodeName + } + return NodeConfiguration{ BinPath: defaultBinPath, CNI: CNIDefinition{ @@ -125,7 +133,7 @@ func DefaultNodeConfiguration() NodeConfiguration { VcpuCount: &defaultVcpuCount, MemSizeMib: &defaultMemSizeMib, }, - Tags: make(map[string]string), + Tags: tags, RateLimiters: nil, WorkloadTypes: defaultWorkloadTypes, } diff --git a/nex/nodes.go b/nex/nodes.go index 4b06afe6..aeefc62f 100644 --- a/nex/nodes.go +++ b/nex/nodes.go @@ -101,14 +101,14 @@ func renderNodeList(nodes []controlapi.PingResponse) { } table := newTableWriter("NATS Execution Nodes") - table.AddHeaders("ID", "Hostname", "Version", "Uptime", "Workloads") + table.AddHeaders("ID", "Name", "Version", "Uptime", "Workloads") for _, node := range nodes { - hostName, ok := node.Tags["hostname"] + nodeName, ok := node.Tags["node_name"] if !ok { - hostName = "" + nodeName = "no-name-provided" } - table.AddRow(node.NodeId, hostName, node.Version, node.Uptime, node.RunningMachines) + table.AddRow(node.NodeId, nodeName, node.Version, node.Uptime, node.RunningMachines) } fmt.Println(table.Render())