Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c321922
feat(go): add schema definitions for nodes, gateways and posture chec…
VishalDalwadi Apr 22, 2026
953d066
feat(go): remove legacy node usages;
VishalDalwadi Apr 22, 2026
43dbc86
fix(go): address code review comments;
VishalDalwadi Apr 22, 2026
fd635f0
feat(go): check ip uniqueness using db query;
VishalDalwadi Apr 22, 2026
11e281a
feat(go): remove nodes and network nodes cache; remove unused functio…
VishalDalwadi Apr 24, 2026
ea39616
feat(go): delete unused function GetExtClientHAConf;
VishalDalwadi Apr 24, 2026
849daae
feat(go): optimize DoesHostExistInTheNetworkAlready;
VishalDalwadi Apr 27, 2026
db71be7
feat(go): remove legacy node and migration;
VishalDalwadi Apr 27, 2026
3906a59
feat(go): implement network orchestrator;
VishalDalwadi Apr 30, 2026
57fa9bb
feat(go): implement gateway orchestrator and extensions;
VishalDalwadi Apr 30, 2026
53380d4
feat(go): implement node orchestrator and extensions;
VishalDalwadi Apr 30, 2026
fe83027
feat(go): implement orchestrator repository and extensions factory;
VishalDalwadi Apr 30, 2026
df6038c
feat(go): add repository initialization with correct factory;
VishalDalwadi Apr 30, 2026
bc2d0a8
feat(go): remove persistent keep alive and mtu from gateway;
VishalDalwadi Apr 30, 2026
0ecf9a5
feat(go): add auto relayed peers to node;
VishalDalwadi Apr 30, 2026
ba253f7
feat(go): rename relay gateway to relaying node; use null string inst…
VishalDalwadi Apr 30, 2026
76f7996
Merge branch 'NM-272' of https://github.com/gravitl/netmaker into NM-293
VishalDalwadi Apr 30, 2026
392ac38
feat(go): add update node last checkin function;
VishalDalwadi Apr 30, 2026
1ab3485
feat(go): wire orchestrator create node;
VishalDalwadi Apr 30, 2026
d0ec631
feat(go): inline create extclient;
VishalDalwadi Apr 30, 2026
13b129a
feat(go): remove old create node functions;
VishalDalwadi Apr 30, 2026
c7f72d8
feat(go): optimize bulk update node connected status;
VishalDalwadi May 1, 2026
776e210
feat(go): mark pending delete directly; move constants;
VishalDalwadi May 1, 2026
6ed43d5
feat(go): remove unused validations;
VishalDalwadi May 1, 2026
9c13c60
feat(go): remove allocated ip map cache;
VishalDalwadi May 1, 2026
a953f41
feat(go): use host persistent keep alive and mtu for extclient config;
VishalDalwadi May 1, 2026
481ebef
feat(go): remove (almost) all failover "unused" code;
VishalDalwadi May 1, 2026
ac76d96
feat(go): guard address allocation with mtx;
VishalDalwadi May 3, 2026
fd9a540
feat(go): validate node ip uniqueness with network orchestrator;
VishalDalwadi May 3, 2026
08e73a7
feat(go): convert schema node to models node for host update;
VishalDalwadi May 3, 2026
b422bf1
feat(go): remove nodes cache initialization;
VishalDalwadi May 3, 2026
75d827c
feat(go): use mark for deletion for node soft delete and delete for h…
VishalDalwadi May 3, 2026
a4c3660
feat(go): removed unused code;
VishalDalwadi May 3, 2026
113f27f
feat(go): convert duration to seconds;
VishalDalwadi May 3, 2026
6741965
feat(go): remove gateway schema, extensions and orchestrator; move ga…
VishalDalwadi May 3, 2026
ac47be2
feat(go): remove self-referential foreign key;
VishalDalwadi May 3, 2026
b6823a7
feat(go): add converters for schema node; use net tables for getting …
VishalDalwadi May 3, 2026
0d8d24a
feat(go): remove unused code;
VishalDalwadi May 4, 2026
d4067c9
feat(go): use models.Node for delete channel;
VishalDalwadi May 4, 2026
5926ae0
feat(go): optimize node telemetry gen;
VishalDalwadi May 4, 2026
c9855ba
feat(go): pass schema.Node to check zombies;
VishalDalwadi May 4, 2026
3fcd27e
feat(go): add model.Node to schema.Node conversion;
VishalDalwadi May 4, 2026
4821818
feat(go): upsert violations on node upsert;
VishalDalwadi May 4, 2026
63c1a62
feat(go): remove all SetDNS usage;
VishalDalwadi May 4, 2026
b788f47
Merge branch 'NM-272' of https://github.com/gravitl/netmaker into NM-293
VishalDalwadi May 5, 2026
cd091c1
feat(go): add nodes migration;
VishalDalwadi May 5, 2026
f74ac07
feat(go): remove unused node methods;
VishalDalwadi May 5, 2026
3f842f4
refactor(go): improve field names;
VishalDalwadi May 5, 2026
cac4a65
feat(go): remove unused network methods;
VishalDalwadi May 5, 2026
201af0b
feat(go): move type NodeStatus and status constants to scheme package;
VishalDalwadi May 5, 2026
93e8f18
feat(go): add list network nodes paginated api;
VishalDalwadi May 5, 2026
7485951
feat(go): add filters to list nodes paginated api;
VishalDalwadi May 5, 2026
b24a709
feat(go): improve logs; manage tx outside of schema pkg;
VishalDalwadi May 6, 2026
d10600d
feat(go): ensure address empty for nil ips;
VishalDalwadi May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 54 additions & 100 deletions auth/host_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import (
"context"
"encoding/json"
"fmt"
"log/slog"
"strings"
"time"

"github.com/google/uuid"
"github.com/gorilla/websocket"
"github.com/gravitl/netmaker/db"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/logic/hostactions"
"github.com/gravitl/netmaker/logic/pro/netcache"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/mq"
"github.com/gravitl/netmaker/orchestrator"
"github.com/gravitl/netmaker/schema"
"github.com/gravitl/netmaker/servercfg"
)
Expand Down Expand Up @@ -236,18 +234,18 @@ func SessionHandler(conn *websocket.Conn) {
}

// CheckNetRegAndHostUpdate - run through networks and send a host update
func CheckNetRegAndHostUpdate(key models.EnrollmentKey, h *schema.Host, username string) {
func CheckNetRegAndHostUpdate(key models.EnrollmentKey, host *schema.Host, username string) {
// publish host update through MQ
featureFlags := logic.GetFeatureFlags()
for _, netID := range key.Networks {
network := &schema.Network{Name: netID}
if err := network.Get(db.WithContext(context.TODO())); err == nil {
if featureFlags.EnableDeviceApproval && !network.AutoJoin {
if logic.DoesHostExistinTheNetworkAlready(h, schema.NetworkID(netID)) {
if logic.DoesHostExistInTheNetworkAlready(host, schema.NetworkID(netID)) {
continue
}
if err := (&schema.PendingHost{
HostID: h.ID.String(),
HostID: host.ID.String(),
Network: netID,
}).CheckIfPendingHostExists(db.WithContext(context.TODO())); err == nil {
continue
Expand All @@ -256,116 +254,72 @@ func CheckNetRegAndHostUpdate(key models.EnrollmentKey, h *schema.Host, username
// add host to pending host table
p := schema.PendingHost{
ID: uuid.NewString(),
HostID: h.ID.String(),
Hostname: h.Name,
HostID: host.ID.String(),
Hostname: host.Name,
Network: netID,
PublicKey: h.PublicKey.String(),
OS: h.OS,
Location: h.Location,
Version: h.Version,
PublicKey: host.PublicKey.String(),
OS: host.OS,
Location: host.Location,
Version: host.Version,
EnrollmentKey: keyB,
RequestedAt: time.Now().UTC(),
}
p.Create(db.WithContext(context.TODO()))
continue
}

if len(username) > 0 {
logic.LogEvent(&models.Event{
Action: schema.JoinHostToNet,
Source: models.Subject{
ID: username,
Name: username,
Type: schema.UserSub,
},
TriggeredBy: username,
Target: models.Subject{
ID: h.ID.String(),
Name: h.Name,
Type: schema.DeviceSub,
},
NetworkID: schema.NetworkID(netID),
Origin: schema.Dashboard,
})
_, err := orchestrator.GetRepository().NodeOrchestrator().CreateNode(
db.WithContext(context.TODO()),
host,
network,
orchestrator.UseKey(&key),
orchestrator.SkipPublishPeerUpdate(),
)
if err != nil {
logger.Log(0, fmt.Sprintf("failed to add host (%s, %s) to network (%s): %v", host.ID.String(), host.Name, netID, err.Error()))
} else {
logic.LogEvent(&models.Event{
Action: schema.JoinHostToNet,
Source: models.Subject{
ID: key.Value,
Name: key.Tags[0],
Type: schema.EnrollmentKeySub,
},
TriggeredBy: username,
Target: models.Subject{
ID: h.ID.String(),
Name: h.Name,
Type: schema.DeviceSub,
},
NetworkID: schema.NetworkID(netID),
Origin: schema.Dashboard,
})
}

newNode, err := logic.UpdateHostNetwork(h, netID, true)
if servercfg.IsPro && key.AutoAssignGateway {
newNode.AutoAssignGateway = true
logic.UpsertNode(newNode)
}
if err == nil || strings.Contains(err.Error(), "host already part of network") {
if len(key.Groups) > 0 {
newNode.Tags = make(map[models.TagID]struct{})
for _, tagI := range key.Groups {
newNode.Tags[tagI] = struct{}{}
}
logic.UpsertNode(newNode)
}
if key.Relay != uuid.Nil && !newNode.IsRelayed {
// check if relay node exists and acting as relay
relaynode, err := logic.GetNodeByID(key.Relay.String())
if err == nil && relaynode.IsGw && relaynode.Network == newNode.Network {
slog.Error(fmt.Sprintf("adding relayed node %s to relay %s on network %s", newNode.ID.String(), key.Relay.String(), netID))
newNode.IsRelayed = true
newNode.RelayedBy = key.Relay.String()
updatedRelayNode := relaynode
updatedRelayNode.RelayedNodes = append(updatedRelayNode.RelayedNodes, newNode.ID.String())
logic.UpdateRelayed(&relaynode, &updatedRelayNode)
if err := logic.UpsertNode(&updatedRelayNode); err != nil {
slog.Error("failed to update node", "nodeid", key.Relay.String())
}
if err := logic.UpsertNode(newNode); err != nil {
slog.Error("failed to update node", "nodeid", key.Relay.String())
}
} else {
slog.Error("failed to relay node. maybe specified relay node is actually not a relay? Or the relayed node is not in the same network with relay?", "err", err)
}
}
if err != nil && strings.Contains(err.Error(), "host already part of network") {
continue
if len(username) > 0 {
logic.LogEvent(&models.Event{
Action: schema.JoinHostToNet,
Source: models.Subject{
ID: username,
Name: username,
Type: schema.UserSub,
},
TriggeredBy: username,
Target: models.Subject{
ID: host.ID.String(),
Name: host.Name,
Type: schema.DeviceSub,
},
NetworkID: schema.NetworkID(netID),
Origin: schema.Dashboard,
})
} else {
logic.LogEvent(&models.Event{
Action: schema.JoinHostToNet,
Source: models.Subject{
ID: key.Value,
Name: key.Tags[0],
Type: schema.EnrollmentKeySub,
},
TriggeredBy: username,
Target: models.Subject{
ID: host.ID.String(),
Name: host.Name,
Type: schema.DeviceSub,
},
NetworkID: schema.NetworkID(netID),
Origin: schema.Dashboard,
})
}
} else {
logger.Log(0, "failed to add host to network:", h.ID.String(), h.Name, netID, err.Error())
continue
}
logger.Log(1, "added new node", newNode.ID.String(), "to host", h.Name)
hostactions.AddAction(models.HostUpdate{
Action: models.JoinHostToNetwork,
Host: *h,
Node: *newNode,
})
if h.IsDefault {
// make host gateway
logic.CreateIngressGateway(netID, newNode.ID.String(), models.IngressRequest{})
logic.CreateRelay(models.RelayRequest{
NodeID: newNode.ID.String(),
NetID: netID,
})
}
}
}
if servercfg.IsMessageQueueBackend() {
mq.HostUpdate(&models.HostUpdate{
Action: models.RequestAck,
Host: *h,
Host: *host,
})
if err := mq.PublishPeerUpdate(false); err != nil {
logger.Log(0, "failed to publish peer update during registration -", err.Error())
Expand Down
20 changes: 0 additions & 20 deletions cli/cmd/failover/disable.go

This file was deleted.

20 changes: 0 additions & 20 deletions cli/cmd/failover/enable.go

This file was deleted.

28 changes: 0 additions & 28 deletions cli/cmd/failover/root.go

This file was deleted.

3 changes: 1 addition & 2 deletions cli/cmd/node/create_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ var nodeCreateIngressCmd = &cobra.Command{
Deprecated: "in favour of the `gateway` subcommand, in Netmaker v0.90.0.",
Aliases: []string{"create_rag"},
Run: func(cmd *cobra.Command, args []string) {
functions.PrettyPrint(functions.CreateIngress(args[0], args[1], failover))
functions.PrettyPrint(functions.CreateIngress(args[0], args[1]))
},
}

func init() {
nodeCreateIngressCmd.Flags().BoolVar(&failover, "failover", false, "Enable FailOver ?")
rootCmd.AddCommand(nodeCreateIngressCmd)
}
1 change: 0 additions & 1 deletion cli/cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package node

var (
natEnabled bool
failover bool
networkName string
nodeDefinitionFilePath string
address string
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/gravitl/netmaker/cli/cmd/dns"
"github.com/gravitl/netmaker/cli/cmd/enrollment_key"
"github.com/gravitl/netmaker/cli/cmd/ext_client"
"github.com/gravitl/netmaker/cli/cmd/failover"
"github.com/gravitl/netmaker/cli/cmd/gateway"
"github.com/gravitl/netmaker/cli/cmd/host"
"github.com/gravitl/netmaker/cli/cmd/metrics"
Expand Down Expand Up @@ -55,7 +54,6 @@ func init() {
rootCmd.AddCommand(metrics.GetRoot())
rootCmd.AddCommand(host.GetRoot())
rootCmd.AddCommand(enrollment_key.GetRoot())
rootCmd.AddCommand(failover.GetRoot())
rootCmd.AddCommand(gateway.GetRoot())
rootCmd.AddCommand(access_token.GetRoot())
}
18 changes: 0 additions & 18 deletions cli/functions/failover.go

This file was deleted.

4 changes: 2 additions & 2 deletions cli/functions/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func DeleteEgress(networkName, nodeID string) *models.ApiNode {
}

// CreateIngress - turn a node into an ingress
func CreateIngress(networkName, nodeID string, failover bool) *models.ApiNode {
func CreateIngress(networkName, nodeID string) *models.ApiNode {
return request[models.ApiNode](http.MethodPost, fmt.Sprintf("/api/nodes/%s/%s/createingress", networkName, nodeID), &struct {
Failover bool `json:"failover"`
}{Failover: failover})
}{Failover: false})
}

// DeleteIngress - remove ingress role from a node
Expand Down
1 change: 0 additions & 1 deletion controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var HttpHandlers = []interface{}{
enrollmentKeyHandlers,
aclHandlers,
egressHandlers,
legacyHandlers,
}

func HandleRESTRequests(wg *sync.WaitGroup, ctx context.Context) {
Expand Down
Loading
Loading