Skip to content

Commit cf50130

Browse files
authored
support clustersync component (#47)
1 parent 289aef1 commit cf50130

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

deploy/bare-metal/config.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ clusters:
2828
- name: storaged2
2929
endpointIP: 192.168.10.133
3030
endpointPort: 19779
31-
componentType: storaged
31+
componentType: storaged
32+
- name: meta-listener-0
33+
endpointIP: 192.168.10.134
34+
endpointPort: 19569
35+
componentType: meta_listener
36+
- name: storage-listener-0
37+
endpointIP: 192.168.10.134
38+
endpointPort: 19789
39+
componentType: storage_listener
40+
- name: drainer0
41+
endpointIP: 192.168.10.134
42+
endpointPort: 19889
43+
componentType: drainer

exporter/exporter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (e *NebulaExporter) collect(wg *sync.WaitGroup, namespace, clusterName stri
159159
instance.Name, instance.EndpointPort)
160160

161161
wg.Add(2)
162-
if instance.ComponentType == "storaged" {
162+
if instance.ComponentType == ComponentTypeStoraged {
163163
wg.Add(1)
164164
go func() {
165165
defer wg.Done()

exporter/type.go

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package exporter
22

3+
import "fmt"
4+
35
const (
46
DefaultClusterName = "default"
57

@@ -13,6 +15,13 @@ const (
1315
// FQNamespace represents the prometheus FQName
1416
FQNamespace = "nebula"
1517
NonNamespace = "none_namespace"
18+
19+
ComponentTypeGraphd = "graphd"
20+
ComponentTypeMetad = "metad"
21+
ComponentTypeStoraged = "storaged"
22+
ComponentTypeMetaListener = "meta_listener"
23+
ComponentTypeStorageListener = "storage_listener"
24+
ComponentTypeDrainer = "drainer"
1625
)
1726

1827
type (
@@ -33,3 +42,19 @@ type (
3342
ComponentType string `yaml:"componentType"`
3443
}
3544
)
45+
46+
func (s *StaticConfig) Validate() error {
47+
for _, cluster := range s.Clusters {
48+
for _, instance := range cluster.Instances {
49+
switch instance.ComponentType {
50+
case ComponentTypeGraphd, ComponentTypeMetad, ComponentTypeStoraged, ComponentTypeMetaListener, ComponentTypeStorageListener, ComponentTypeDrainer:
51+
continue
52+
default:
53+
return fmt.Errorf("invalid component type: %s", instance.ComponentType)
54+
}
55+
}
56+
57+
}
58+
59+
return nil
60+
}

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func main() {
9696
if err := yaml.Unmarshal(raw, &nebulaExporter.Config); err != nil {
9797
klog.Fatalf("unmarshal failed: %v", err)
9898
}
99+
100+
if err := nebulaExporter.Config.Validate(); err != nil {
101+
klog.Fatalf("bare-metal config validation failed: %v", err)
102+
}
99103
} else {
100104
config, err := buildConfig(*kubeconfig)
101105
if err != nil {

0 commit comments

Comments
 (0)