Skip to content

Commit 4b76b13

Browse files
committed
publish: v0.1.6
1 parent 60d94a0 commit 4b76b13

File tree

12 files changed

+64
-31
lines changed

12 files changed

+64
-31
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION ?= 0.1.5
1+
VERSION ?= 0.1.6
22
DOCKERHUB_USER ?= plan9better
33
LOCAL_REGISTRY ?= 192.168.10.201:5000
44

cmd/manager/collector.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"os"
45
"time"
56

67
"github.com/prometheus/client_golang/prometheus"
@@ -41,27 +42,27 @@ func NewManagerCollector(network string, id int) *ManagerCollector {
4142
BytesIn: prometheus.NewDesc(
4243
ns+"_bytes_in",
4344
"Number of bytes received on the interface",
44-
[]string{"interface"}, nil,
45+
[]string{"interface", "type", "id"}, nil,
4546
),
4647
BytesOut: prometheus.NewDesc(
4748
ns+"_bytes_out",
4849
"Number of bytes sent on the interface",
49-
[]string{"interface"}, nil,
50+
[]string{"interface", "type", "id"}, nil,
5051
),
5152
PacketsIn: prometheus.NewDesc(
5253
ns+"_packets_in",
5354
"Number of packets received on the interface",
54-
[]string{"interface"}, nil,
55+
[]string{"interface", "type", "id"}, nil,
5556
),
5657
PacketsOut: prometheus.NewDesc(
5758
ns+"_packets_out",
5859
"Number of packets sent on the interface",
59-
[]string{"interface"}, nil,
60+
[]string{"interface", "type", "id"}, nil,
6061
),
6162
InterfaceState: prometheus.NewDesc(
6263
ns+"_interface_state",
6364
"State of the interface, value of 1 means 'up'",
64-
[]string{"interface", "state"}, nil,
65+
[]string{"interface", "state", "type", "id"}, nil,
6566
),
6667
}
6768
prometheus.MustRegister(mc)
@@ -99,44 +100,45 @@ func (mc *ManagerCollector) Collect(ch chan<- prometheus.Metric) {
99100
}
100101

101102
func (mc *ManagerCollector) collectDevInfo(dev procfs.NetDevLine, ch chan<- prometheus.Metric) {
103+
vlanID := os.Getenv("VLAN_ID")
104+
link, err := netlink.LinkByName(dev.Name)
105+
if err != nil {
106+
klog.V(4).Infof("Error finding link '%s' by name: %s", dev.Name, err.Error())
107+
return
108+
}
109+
stateValue := 0.0
110+
if link.Attrs().OperState.String() == "up" {
111+
stateValue = 1.0
112+
}
102113
ch <- prometheus.MustNewConstMetric(
103114
mc.BytesIn,
104115
prometheus.GaugeValue,
105116
float64(dev.RxBytes),
106-
dev.Name,
117+
dev.Name, link.Type(), vlanID,
107118
)
108119
ch <- prometheus.MustNewConstMetric(
109120
mc.BytesOut,
110121
prometheus.GaugeValue,
111122
float64(dev.TxBytes),
112-
dev.Name,
123+
dev.Name, link.Type(), vlanID,
113124
)
114125
ch <- prometheus.MustNewConstMetric(
115126
mc.PacketsIn,
116127
prometheus.GaugeValue,
117128
float64(dev.RxPackets),
118-
dev.Name,
129+
dev.Name, link.Type(), vlanID,
119130
)
120131
ch <- prometheus.MustNewConstMetric(
121132
mc.PacketsOut,
122133
prometheus.GaugeValue,
123134
float64(dev.TxPackets),
124-
dev.Name,
135+
dev.Name, link.Type(), vlanID,
125136
)
126-
link, err := netlink.LinkByName(dev.Name)
127-
if err != nil {
128-
klog.V(4).Infof("Error finding link '%s' by name: %s", dev.Name, err.Error())
129-
return
130-
}
131-
stateValue := 0.0
132-
if link.Attrs().OperState.String() == "up" {
133-
stateValue = 1.0
134-
}
135137
ch <- prometheus.MustNewConstMetric(
136138
mc.InterfaceState,
137139
prometheus.GaugeValue,
138140
stateValue,
139-
dev.Name, link.Attrs().OperState.String(),
141+
dev.Name, link.Attrs().OperState.String(), link.Type(), vlanID,
140142
)
141143
}
142144

cmd/manager/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bytes"
45
"context"
56
"encoding/json"
67
"flag"
@@ -127,7 +128,7 @@ func macvlan(w http.ResponseWriter, r *http.Request) {
127128
}
128129

129130
cmd := exec.Command("bash", "-c", fmt.Sprintf("lsns | grep %d | awk '{print $4}'", mvr.NsID))
130-
PID, err := cmd.Output()
131+
PIDs, err := cmd.Output()
131132
if err != nil {
132133
exErr, ok := err.(*exec.ExitError)
133134
if !ok {
@@ -137,6 +138,12 @@ func macvlan(w http.ResponseWriter, r *http.Request) {
137138
writeError(fmt.Sprintf("Error checking PID of NsID: %s", string(exErr.Stderr)), exErr)
138139
return
139140
}
141+
var PID string
142+
if idx := bytes.IndexByte(PIDs, '\n'); idx >= 0 {
143+
PID = string(PIDs[:idx])
144+
} else {
145+
PID = strings.TrimSpace(string(PIDs))
146+
}
140147

141148
cmd = exec.Command("ip", "link", "set", attrs.Name, "netns", strings.TrimSpace(string(PID)))
142149
out, err = cmd.Output()

flake.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
mkdir -p final/templates
126126
cat $src/values.yaml > final/values.yaml
127127
cat $src/Chart.yaml > final/Chart.yaml
128-
cp $src/vlanman-*.tgz final/
129128
130129
cp -aL ${manifests}/. final/templates/
131130
@@ -134,7 +133,11 @@
134133
135134
export VERSION=${version}
136135
perl -pi -e 's|(image:\s*")[^/]+/([^:"]+):[^"]+|\1$ENV{REGISTRY}/\2:$ENV{VERSION}|' final/values.yaml
137-
perl -pi -e 's/pullPolicy:\s*Always/pullPolicy: IfNotPresent/g' final/values.yaml
136+
${
137+
if version == "dev"
138+
then "#"
139+
else ""
140+
} perl -pi -e 's/pullPolicy:\s*Always/pullPolicy: IfNotPresent/g' final/values.yaml
138141
139142
# version
140143
yq '.version="${
@@ -204,7 +207,7 @@
204207
EDITOR = "hx";
205208
};
206209
};
207-
version = "0.1.5";
210+
version = "0.1.6";
208211
}
209212
);
210213
}

index.yaml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,28 @@ entries:
1414
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
1515
apiVersion: v2
1616
appVersion: 1.16.0
17-
created: "2025-08-07T15:56:41.935689+02:00"
17+
created: "2025-08-12T17:42:57.813356+02:00"
18+
description: VLAN network manager
19+
digest: 9ccfc3f1289aea3cc81b1f6a973b8ee5071f5ed6079339c71837ad79575d607d
20+
name: vlanman
21+
type: application
22+
urls:
23+
- https://github.com/dialohq/vlanman/releases/download/v0.1.6/vlanman-0.1.6.tgz
24+
version: 0.1.6
25+
- annotations:
26+
artifacthub.io/category: networking
27+
artifacthub.io/crds: |
28+
- kind: VlanNetwork
29+
version: v1
30+
name: vlannetwork
31+
description: Defines the VLAN connection
32+
artifacthub.io/license: MIT
33+
artifacthub.io/recommendations: |
34+
- https://artifacthub.io/packages/helm/cert-manager/cert-manager
35+
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
36+
apiVersion: v2
37+
appVersion: 1.16.0
38+
created: "2025-08-12T17:42:57.812843+02:00"
1839
description: VLAN network manager
1940
digest: 34a50a6a95d7c171f597cff2afb786b8149ecb11b05d199f1c93034dcd7309cf
2041
name: vlanman
@@ -35,7 +56,7 @@ entries:
3556
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
3657
apiVersion: v2
3758
appVersion: 1.16.0
38-
created: "2025-08-07T15:56:41.933775+02:00"
59+
created: "2025-08-12T17:42:57.810188+02:00"
3960
description: VLAN network manager
4061
digest: 7555c142d6f65eb7a52d0135685b6bbe32407f0e69c6e113b580a467eb259a30
4162
name: vlanman
@@ -56,7 +77,7 @@ entries:
5677
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
5778
apiVersion: v2
5879
appVersion: 1.16.0
59-
created: "2025-08-07T15:56:41.931348+02:00"
80+
created: "2025-08-12T17:42:57.807963+02:00"
6081
description: VLAN network manager
6182
digest: 8e2efb5c505d6b963b74e704eaf96ee4cabae4a6fe2317d4dd8c494fa6013b8e
6283
name: vlanman
@@ -77,7 +98,7 @@ entries:
7798
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
7899
apiVersion: v2
79100
appVersion: 1.16.0
80-
created: "2025-08-07T15:56:41.929552+02:00"
101+
created: "2025-08-12T17:42:57.806468+02:00"
81102
description: VLAN network manager
82103
digest: 4a4c3b41a49039bb06b13221dc5a42973813e546a51a362cdf6f693c07fb90b4
83104
name: vlanman
@@ -98,7 +119,7 @@ entries:
98119
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
99120
apiVersion: v2
100121
appVersion: 1.16.0
101-
created: "2025-08-07T15:56:41.928333+02:00"
122+
created: "2025-08-12T17:42:57.805445+02:00"
102123
description: VLAN network manager
103124
digest: ab1060ee1c74386328a1913148b305e245a4dcbeea28cc8fb1cf4945f00c330d
104125
name: vlanman
@@ -119,12 +140,12 @@ entries:
119140
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
120141
apiVersion: v2
121142
appVersion: 1.16.0
122-
created: "2025-08-07T15:56:41.927378+02:00"
143+
created: "2025-08-12T17:42:57.805072+02:00"
123144
description: VLAN network manager
124145
digest: 0bf004ba2202856151915191f652966b1850352072d0af9a83fddf53e96aaa57
125146
name: vlanman
126147
type: application
127148
urls:
128149
- https://github.com/dialohq/vlanman/releases/download/v0.1.0/vlanman-0.1.0.tgz
129150
version: 0.1.0
130-
generated: "2025-08-07T15:56:41.92634+02:00"
151+
generated: "2025-08-12T17:42:57.804229+02:00"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)