Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-1497:set node lastcheckin after reboot #3102

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions logic/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func GetNetworkByNode(node *models.Node) (models.Network, error) {
}

// SetNodeDefaults - sets the defaults of a node to avoid empty fields
func SetNodeDefaults(node *models.Node) {
func SetNodeDefaults(node *models.Node, resetConnected bool) {

parentNetwork, _ := GetNetworkByNode(node)
_, cidr, err := net.ParseCIDR(parentNetwork.AddressRange)
Expand All @@ -413,8 +413,12 @@ func SetNodeDefaults(node *models.Node) {
}

node.SetLastModified()
node.SetLastCheckIn()
node.SetDefaultConnected()
if node.LastCheckIn.IsZero() {
node.SetLastCheckIn()
}
if resetConnected {
node.SetDefaultConnected()
}
node.SetExpirationDateTime()
}

Expand Down Expand Up @@ -461,7 +465,7 @@ func GetDeletedNodeByID(uuid string) (models.Node, error) {
return models.Node{}, err
}

SetNodeDefaults(&node)
SetNodeDefaults(&node, true)

return node, nil
}
Expand Down Expand Up @@ -531,7 +535,7 @@ func createNode(node *models.Node) error {
}
}

SetNodeDefaults(node)
SetNodeDefaults(node, true)

defaultACLVal := acls.Allowed
parentNetwork, err := GetNetwork(node.Network)
Expand Down
2 changes: 1 addition & 1 deletion serverctl/serverctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func setNodeDefaults() error {
return err
}
for i := range nodes {
logic.SetNodeDefaults(&nodes[i])
logic.SetNodeDefaults(&nodes[i], false)
logic.UpdateNode(&nodes[i], &nodes[i])
currentNodeACL, err := nodeacls.FetchNodeACL(nodeacls.NetworkID(nodes[i].Network), nodeacls.NodeID(nodes[i].ID.String()))
if (err != nil && (database.IsEmptyRecord(err) || strings.Contains(err.Error(), "no node ACL present"))) || currentNodeACL == nil {
Expand Down
Loading