Skip to content

Commit

Permalink
Merge pull request #2976 from gravitl/release-v0.24.2
Browse files Browse the repository at this point in the history
v0.24.2
  • Loading branch information
abhishek9686 authored Jun 18, 2024
2 parents d77abf1 + 595e057 commit 22a00bd
Show file tree
Hide file tree
Showing 33 changed files with 208 additions and 108 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ body:
label: Version
description: What version are you running?
options:
- v0.24.2
- v0.24.1
- v0.24.0
- v0.23.0
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/sendtokitemaker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Send to Kitemaker

on:
issues:
types: opened


jobs:
send-ticket:
uses: gravitl/devops/.github/workflows/makekitemakerticket.yml@master
with:
title: ${{ github.event.issue.title }}
body: ${{ github.event.issue.body }}
repo_name: ${{ github.event.repository.name }}
secrets: inherit
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY . .

RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -w " -tags ${tags} .
# RUN go build -tags=ee . -o netmaker main.go
FROM alpine:3.19.1
FROM alpine:3.20.0

# add a c lib
# set the working directory
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-quick
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#first stage - builder
FROM alpine:3.19.1
FROM alpine:3.20.0
ARG version
WORKDIR /app
COPY ./netmaker /root/netmaker
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<p align="center">
<a href="https://github.com/gravitl/netmaker/releases">
<img src="https://img.shields.io/badge/Version-0.24.1-informational?style=flat-square" />
<img src="https://img.shields.io/badge/Version-0.24.2-informational?style=flat-square" />
</a>
<a href="https://hub.docker.com/r/gravitl/netmaker/tags">
<img src="https://img.shields.io/docker/pulls/gravitl/netmaker?label=downloads" />
Expand Down
5 changes: 4 additions & 1 deletion cli/cmd/host/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
name string
listenPort int
mtu int
isStaticPort bool
isStatic bool
isDefault bool
keepAlive int
Expand Down Expand Up @@ -45,6 +46,7 @@ var hostUpdateCmd = &cobra.Command{
apiHost.Name = name
apiHost.ListenPort = listenPort
apiHost.MTU = mtu
apiHost.IsStaticPort = isStaticPort
apiHost.IsStatic = isStatic
apiHost.IsDefault = isDefault
apiHost.PersistentKeepalive = keepAlive
Expand All @@ -61,7 +63,8 @@ func init() {
hostUpdateCmd.Flags().IntVar(&listenPort, "listen_port", 0, "Listen port of the host")
hostUpdateCmd.Flags().IntVar(&mtu, "mtu", 0, "Host MTU size")
hostUpdateCmd.Flags().IntVar(&keepAlive, "keep_alive", 0, "Interval (seconds) in which packets are sent to keep connections open with peers")
hostUpdateCmd.Flags().BoolVar(&isStatic, "static", false, "Make Host Static ?")
hostUpdateCmd.Flags().BoolVar(&isStaticPort, "static_port", false, "Make Host Static Port?")
hostUpdateCmd.Flags().BoolVar(&isStatic, "static_endpoint", false, "Make Host Static Endpoint?")
hostUpdateCmd.Flags().BoolVar(&isDefault, "default", false, "Make Host Default ?")
rootCmd.AddCommand(hostUpdateCmd)
}
2 changes: 1 addition & 1 deletion compose/docker-compose.netclient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.4"
services:
netclient:
container_name: netclient
image: 'gravitl/netclient:v0.24.1'
image: 'gravitl/netclient:v0.24.2'
hostname: netmaker-1
network_mode: host
restart: on-failure
Expand Down
2 changes: 1 addition & 1 deletion controllers/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// Schemes: https
// BasePath: /
// Version: 0.24.1
// Version: 0.24.2
// Host: api.demo.netmaker.io
//
// Consumes:
Expand Down
10 changes: 5 additions & 5 deletions controllers/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,17 @@ func deleteHost(w http.ResponseWriter, r *http.Request) {
slog.Error("failed to remove host credentials from EMQX", "id", currHost.ID, "error", err)
}
}
if err = logic.RemoveHost(currHost, forceDelete); err != nil {
logger.Log(0, r.Header.Get("user"), "failed to delete a host:", err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
if err = mq.HostUpdate(&models.HostUpdate{
Action: models.DeleteHost,
Host: *currHost,
}); err != nil {
logger.Log(0, r.Header.Get("user"), "failed to send delete host update: ", currHost.ID.String(), err.Error())
}
if err = logic.RemoveHost(currHost, forceDelete); err != nil {
logger.Log(0, r.Header.Get("user"), "failed to delete a host:", err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}

apiHostData := currHost.ConvertNMHostToAPI()
logger.Log(2, r.Header.Get("user"), "removed host", currHost.Name)
Expand Down
1 change: 1 addition & 0 deletions controllers/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func convertLegacyHostNode(legacy models.LegacyNode) (models.Host, models.Node)
host.EndpointIP = net.ParseIP(legacy.Endpoint)
host.IsDocker = models.ParseBool(legacy.IsDocker)
host.IsK8S = models.ParseBool(legacy.IsK8S)
host.IsStaticPort = models.ParseBool(legacy.IsStatic)
host.IsStatic = models.ParseBool(legacy.IsStatic)
host.PersistentKeepalive = time.Duration(legacy.PersistentKeepalive) * time.Second
if host.PersistentKeepalive == 0 {
Expand Down
4 changes: 4 additions & 0 deletions controllers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ func createNetwork(w http.ResponseWriter, r *http.Request) {
// make host remote access gateway
logic.CreateIngressGateway(network.NetID, newNode.ID.String(), models.IngressRequest{})
}
// send peer updates
if err = mq.PublishPeerUpdate(false); err != nil {
logger.Log(1, "failed to publish peer update for default hosts after network is added")
}
}()

logger.Log(1, r.Header.Get("user"), "created network", network.NetID)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/go-version v1.7.0
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/guumaster/tablewriter v0.0.10 h1:A0HD94yMdt4usgxBjoEceNeE0XMJ027euoHAzsPqBQs=
github.com/guumaster/tablewriter v0.0.10/go.mod h1:p4FRFhyfo0UD9ZLmMRbbJooTUsxo6b80qZTERVDWrH8=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
Expand Down
2 changes: 1 addition & 1 deletion k8s/client/netclient-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
hostNetwork: true
containers:
- name: netclient
image: gravitl/netclient:v0.24.1
image: gravitl/netclient:v0.24.2
env:
- name: TOKEN
value: "TOKEN_VALUE"
Expand Down
2 changes: 1 addition & 1 deletion k8s/client/netclient.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
# - "<node label value>"
containers:
- name: netclient
image: gravitl/netclient:v0.24.1
image: gravitl/netclient:v0.24.2
env:
- name: TOKEN
value: "TOKEN_VALUE"
Expand Down
2 changes: 1 addition & 1 deletion k8s/server/netmaker-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: netmaker-ui
image: gravitl/netmaker-ui:v0.24.1
image: gravitl/netmaker-ui:v0.24.2
ports:
- containerPort: 443
env:
Expand Down
29 changes: 12 additions & 17 deletions logic/extpeers.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func ToggleExtClientConnectivity(client *models.ExtClient, enable bool) (models.
return newClient, nil
}

func getExtPeers(node, peer *models.Node) ([]wgtypes.PeerConfig, []models.IDandAddr, []models.EgressNetworkRoutes, error) {
func GetExtPeers(node, peer *models.Node) ([]wgtypes.PeerConfig, []models.IDandAddr, []models.EgressNetworkRoutes, error) {
var peers []wgtypes.PeerConfig
var idsAndAddr []models.IDandAddr
var egressRoutes []models.EgressNetworkRoutes
Expand Down Expand Up @@ -431,7 +431,7 @@ func getExtPeers(node, peer *models.Node) ([]wgtypes.PeerConfig, []models.IDandA
allowedips = append(allowedips, *cidr)
}
}
egressRoutes = append(egressRoutes, getExtPeerEgressRoute(extPeer)...)
egressRoutes = append(egressRoutes, getExtPeerEgressRoute(*node, extPeer)...)
primaryAddr := extPeer.Address
if primaryAddr == "" {
primaryAddr = extPeer.Address6
Expand All @@ -453,23 +453,18 @@ func getExtPeers(node, peer *models.Node) ([]wgtypes.PeerConfig, []models.IDandA

}

func getExtPeerEgressRoute(extPeer models.ExtClient) (egressRoutes []models.EgressNetworkRoutes) {
if extPeer.Address != "" {
egressRoutes = append(egressRoutes, models.EgressNetworkRoutes{
NodeAddr: extPeer.AddressIPNet4(),
EgressRanges: extPeer.ExtraAllowedIPs,
})
}
if extPeer.Address6 != "" {
egressRoutes = append(egressRoutes, models.EgressNetworkRoutes{
NodeAddr: extPeer.AddressIPNet6(),
EgressRanges: extPeer.ExtraAllowedIPs,
})
}
func getExtPeerEgressRoute(node models.Node, extPeer models.ExtClient) (egressRoutes []models.EgressNetworkRoutes) {
egressRoutes = append(egressRoutes, models.EgressNetworkRoutes{
EgressGwAddr: extPeer.AddressIPNet4(),
EgressGwAddr6: extPeer.AddressIPNet6(),
NodeAddr: node.Address,
NodeAddr6: node.Address6,
EgressRanges: extPeer.ExtraAllowedIPs,
})
return
}

func getExtpeersExtraRoutes(network string) (egressRoutes []models.EgressNetworkRoutes) {
func getExtpeersExtraRoutes(node models.Node, network string) (egressRoutes []models.EgressNetworkRoutes) {
extPeers, err := GetNetworkExtClients(network)
if err != nil {
return
Expand All @@ -478,7 +473,7 @@ func getExtpeersExtraRoutes(network string) (egressRoutes []models.EgressNetwork
if len(extPeer.ExtraAllowedIPs) == 0 {
continue
}
egressRoutes = append(egressRoutes, getExtPeerEgressRoute(extPeer)...)
egressRoutes = append(egressRoutes, getExtPeerEgressRoute(node, extPeer)...)
}
return
}
Expand Down
18 changes: 6 additions & 12 deletions logic/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool)
currHost.Debug = newHost.Debug
currHost.Verbosity = newHost.Verbosity
currHost.Version = newHost.Version
currHost.IsStaticPort = newHost.IsStaticPort
currHost.IsStatic = newHost.IsStatic
currHost.MTU = newHost.MTU
currHost.Name = newHost.Name
Expand Down Expand Up @@ -396,20 +397,13 @@ func DissasociateNodeFromHost(n *models.Node, h *models.Host) error {
if len(h.Nodes) == 0 {
return fmt.Errorf("no nodes present in given host")
}
index := -1
nList := []string{}
for i := range h.Nodes {
if h.Nodes[i] == n.ID.String() {
index = i
break
if h.Nodes[i] != n.ID.String() {
nList = append(nList, h.Nodes[i])
}
}
if index < 0 {
if len(h.Nodes) == 0 {
return fmt.Errorf("node %s, not found in host, %s", n.ID.String(), h.ID.String())
}
} else {
h.Nodes = RemoveStringSlice(h.Nodes, index)
}
h.Nodes = nList
go func() {
if servercfg.IsPro {
if clients, err := GetNetworkExtClients(n.Network); err != nil {
Expand All @@ -434,7 +428,7 @@ func DisassociateAllNodesFromHost(hostID string) error {
for _, nodeID := range host.Nodes {
node, err := GetNodeByID(nodeID)
if err != nil {
logger.Log(0, "failed to get host node", err.Error())
logger.Log(0, "failed to get host node, node id:", nodeID, err.Error())
continue
}
if err := DeleteNode(&node, true); err != nil {
Expand Down
25 changes: 15 additions & 10 deletions logic/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
if err != nil {
continue
}

if !node.Connected || node.PendingDelete || node.Action == models.NODE_DELETE {
continue
}
Expand Down Expand Up @@ -181,7 +182,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
})
}
if peer.IsIngressGateway {
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, getExtpeersExtraRoutes(peer.Network)...)
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, getExtpeersExtraRoutes(node, peer.Network)...)
}
_, isFailOverPeer := node.FailOverPeers[peer.ID.String()]
if servercfg.IsPro {
Expand Down Expand Up @@ -249,20 +250,23 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
Interfaces: peerHost.Interfaces,
ListenPort: peerHost.ListenPort,
IsStatic: peerHost.IsStatic,
Interfaces: peerHost.Interfaces,
ListenPort: peerHost.ListenPort,
IsStaticPort: peerHost.IsStaticPort,
IsStatic: peerHost.IsStatic,
}
nodePeer = peerConfig
} else {
peerAllowedIPs := hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs
peerAllowedIPs = append(peerAllowedIPs, peerConfig.AllowedIPs...)
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Remove = false
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Endpoint = peerConfig.Endpoint
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
Interfaces: peerHost.Interfaces,
ListenPort: peerHost.ListenPort,
IsStatic: peerHost.IsStatic,
Interfaces: peerHost.Interfaces,
ListenPort: peerHost.ListenPort,
IsStaticPort: peerHost.IsStaticPort,
IsStatic: peerHost.IsStatic,
}
nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
}
Expand All @@ -283,7 +287,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
var extPeerIDAndAddrs []models.IDandAddr
var egressRoutes []models.EgressNetworkRoutes
if node.IsIngressGateway {
extPeers, extPeerIDAndAddrs, egressRoutes, err = getExtPeers(&node, &node)
extPeers, extPeerIDAndAddrs, egressRoutes, err = GetExtPeers(&node, &node)
if err == nil {
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, egressRoutes...)
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, extPeers...)
Expand Down Expand Up @@ -342,6 +346,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
},
}
}

}
// == post peer calculations ==
// indicate removal if no allowed IPs were calculated
Expand Down Expand Up @@ -392,7 +397,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
// GetPeerListenPort - given a host, retrieve it's appropriate listening port
func GetPeerListenPort(host *models.Host) int {
peerPort := host.ListenPort
if host.WgPublicListenPort != 0 {
if !host.IsStaticPort && host.WgPublicListenPort != 0 {
peerPort = host.WgPublicListenPort
}
return peerPort
Expand All @@ -415,7 +420,7 @@ func GetAllowedIPs(node, peer *models.Node, metrics *models.Metrics) []net.IPNet

// handle ingress gateway peers
if peer.IsIngressGateway {
extPeers, _, _, err := getExtPeers(peer, node)
extPeers, _, _, err := GetExtPeers(peer, node)
if err != nil {
logger.Log(2, "could not retrieve ext peers for ", peer.ID.String(), err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"golang.org/x/exp/slog"
)

var version = "v0.24.1"
var version = "v0.24.2"

// Start DB Connection and start API Request Handler
func main() {
Expand Down
3 changes: 3 additions & 0 deletions models/api_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ApiHost struct {
Name string `json:"name"`
OS string `json:"os"`
Debug bool `json:"debug"`
IsStaticPort bool `json:"isstaticport"`
IsStatic bool `json:"isstatic"`
ListenPort int `json:"listenport"`
WgPublicListenPort int `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
Expand Down Expand Up @@ -61,6 +62,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
}
}
a.DefaultInterface = h.DefaultInterface
a.IsStaticPort = h.IsStaticPort
a.IsStatic = h.IsStatic
a.ListenPort = h.ListenPort
a.MTU = h.MTU
Expand Down Expand Up @@ -104,6 +106,7 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
h.DefaultInterface = currentHost.DefaultInterface
h.IsDocker = currentHost.IsDocker
h.IsK8S = currentHost.IsK8S
h.IsStaticPort = a.IsStaticPort
h.IsStatic = a.IsStatic
h.ListenPort = a.ListenPort
h.MTU = a.MTU
Expand Down
Loading

0 comments on commit 22a00bd

Please sign in to comment.