SIGN IN SIGN UP

NM-293: Nodes Schema Migration (#3982)

* feat(go): add schema for pending users table;

1. Schema Definition for Pending Users table.
2. Use the newer table everywhere.
3. Migration stubs for v1.5.2.
4. Migration code for Pending Users table;

* feat(go): add schema for user invites table;

1. Schema Definition for User Invites table.
2. Use the newer table everywhere.
3. Migration code for User Invites table;

* feat(go): add schema definitions for nodes, gateways and posture check violations table;

* feat(go): remove legacy node usages;

* fix(go): address code review comments;

1. remove column names in primary key for PostureCheckViolation struct.
2. use correct column name for network_id.
3. handle rollback error.

* feat(go): check ip uniqueness using db query;

* feat(go): remove nodes and network nodes cache; remove unused functions and consts;

* feat(go): delete unused function GetExtClientHAConf;

* feat(go): optimize DoesHostExistInTheNetworkAlready;

* feat(go): remove legacy node and migration;

* feat(go): implement network orchestrator;

1. Implements IP Allocation for Nodes and Extclients;

* feat(go): implement gateway orchestrator and extensions;

1. Implements CreateGateway;
2. Pro and CE Gateway Extensions to ConfigureAutoRelay;

* feat(go): implement node orchestrator and extensions;

1. Implements CreateNode;
2. Pro and CE Node Extensions to ConfigureAutoAssignGateway;

* feat(go): implement orchestrator repository and extensions factory;

* feat(go): add repository initialization with correct factory;

* feat(go): remove persistent keep alive and mtu from gateway;

* feat(go): add auto relayed peers to node;

* feat(go): rename relay gateway to relaying node; use null string instead of string pointer;

* fix(go): merge errors;

* feat(go): add update node last checkin function;

* feat(go): wire orchestrator create node;

1. Enrollment Key Join.
2. API: Add Host to Network.
3. API: Approve Pending Host.
4. API: Update Host (Make Host Default).
5. API: Create Network (Add Default Hosts to Network).

* feat(go): inline create extclient;

Remove cyclic dependency between logic and orchestrator;

* feat(go): remove old create node functions;

* feat(go): optimize bulk update node connected status;

* feat(go): mark pending delete directly; move constants;

* feat(go): remove unused validations;

* feat(go): remove allocated ip map cache;

* feat(go): use host persistent keep alive and mtu for extclient config;

* feat(go): remove (almost) all failover "unused" code;

* feat(go): guard address allocation with mtx;

* feat(go): validate node ip uniqueness with network orchestrator;

* feat(go): convert schema node to models node for host update;

* feat(go): remove nodes cache initialization;

* feat(go): use mark for deletion for node soft delete and delete for hard delete; add preload options for node get;

* feat(go): removed unused code;

1. No calls for GetRelays and commented GetRelayedNodes.
2. GetNodeEgressInfo populates egress details for node but they aren't validated here.

* feat(go): convert duration to seconds;

* feat(go): remove gateway schema, extensions and orchestrator; move gateway management to nodes extension and orchestrator;

* feat(go): remove self-referential foreign key;

* feat(go): add converters for schema node; use net tables for getting a node and listing all nodes;

* feat(go): remove unused code;

* feat(go): use models.Node for delete channel;

* feat(go): optimize node telemetry gen;

* feat(go): pass schema.Node to check zombies;

* feat(go): add model.Node to schema.Node conversion;

* feat(go): upsert violations on node upsert;

* feat(go): remove all SetDNS usage;

* feat(go): use fetchAll instead of database.FetchRecords;

* feat(go): add nodes migration;

* feat(go): remove unused node methods;

* refactor(go): improve field names;

* feat(go): remove unused network methods;

* feat(go): move type NodeStatus and status constants to scheme package;

* feat(go): add list network nodes paginated api;

* feat(go): add filters to list nodes paginated api;

* feat(go): improve logs; manage tx outside of schema pkg;

* feat(go): ensure address empty for nil ips;

* feat(go): add json tags;

* feat(go): add json tags;

* feat(go): use string ptr instead of NullString;

* feat(go): use api host in list response;

* feat(go): optimize list posture check violations api;

* feat(go): list only current violations;

* feat(go): scope table field on join;

* NM-293: fix static checks

* NM-293: fix static checks

* NM-293: fix static checks

* Update orchestrator/network.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* NM-293: fix invalid gorm struct tags

* NM-293: Only set RelayingNodeID when the node is actually relayed.

* NM-293: use RelayedByNodeID for clarity

* feat(go): add pkg for json expressions; add node methods to do json operations in db;

* feat(go): make options common for all orchestrators; use orchestrator create gateway in api;

* feat(go): add delete all methods; add set internet gateway in db;

* feat(go): set is ingress gateway to is gateway;

* feat(go): restore igws handlers;

* feat(go): use network name in tag;

* feat(go): add skip mq host and node update options;

* feat(go): add node orchestrator test suite;

* feat(go): set network addr range on conversion;

* feat(go): upsert node instead of update node;

* feat(go): remove old todos;

* feat(go): use only is_gw to determine whether gateway;

* feat(go): add create node with default host test case;

* feat(go): add create node with enrollment key test case;

* feat(go): add pro node orchestrator test suite;

* feat(go): update node and client status on update metrics;

* feat(go): add node status filters;

* feat(go): update node status on bulk update as well;

* feat(go): prevent reset of host password on upsert;

* feat(go): disable platform/service user device join;

* feat(go): disable platform/service user device join;

* feat(go): add search across fields for list network nodes api;

* feat(go): add field for additional gateway endpoints;

* feat(go): configure tags only if they belong to the node network;

* feat(go): optimize tag assignments and unassignments;

* feat(go): add posture check violations check before create node;

Check not added for default host on network create;

* feat(go): copy key before editing key networks to prevent changes in the cache;

* feat(go): construct another network slice instead of in-place delete;

* feat(go): error only when no networks left to join;

* feat(go): move set defaults to schema migration;

* feat(go): load server settings in cache before migration;

* feat(go): migrate gateway nameserver and egress along with nodes;

* feat(go): disable netclient auto update if disabled globally;

* refactor(go): move network nameserver migration to separate function;

* feat(go): calculate node status on migrate (skipping metrics check);

Previously, we weren't setting the node status in db, just recalculating on the fly. With this version, we expect the node status to be in the db and recalculated when metrics are pushed from netclient. So we have to recalculate the node status to initialize the status value.

* feat(go): update only if nodeIDs is non-empty;

WithFilter adds the where clause only if atleast one value is passed. To prevent updating status of all nodes, add a check for nodeIDs.

* fix(go): remove tag;

Execute assign tag only when at least one node has to be tagged;

* feat(go): add egress nat mode migration;

* fix(go): use correct network id;

* fix(go): make is_auto_relay string;

* fix(go): create tag before use to pass test;

* fix(go): move delete to testutils package;

---------

Co-authored-by: abhishek9686 <abhi281342@gmail.com>
Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>
V
Vishal Dalwadi committed
fdcf11e0dbbb332d0daefbd170a7981bc8b8fd04
Parent: 8404b7a
Committed by GitHub <noreply@github.com> on 5/15/2026, 3:05:53 PM