-
Notifications
You must be signed in to change notification settings - Fork 138
/
types.go
56 lines (46 loc) · 1.24 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package monitoring
import (
"github.com/prometheus/client_golang/prometheus"
longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta1"
"github.com/longhorn/longhorn-manager/types"
)
const (
longhornName = "longhorn"
subsystemVolume = "volume"
subsystemNode = "node"
subsystemDisk = "disk"
subsystemInstanceManager = "instance_manager"
subsystemManager = "manager"
nodeLabel = "node"
diskLabel = "disk"
volumeLabel = "volume"
conditionLabel = "condition"
conditionReasonLabel = "condition_reason"
instanceManagerLabel = "instance_manager"
instanceManagerType = "instance_manager_type"
managerLabel = "manager"
)
type metricInfo struct {
Desc *prometheus.Desc
Type prometheus.ValueType
}
type diskInfo struct {
types.DiskSpec
types.DiskStatus
}
func getDiskListFromNode(node *longhorn.Node) map[string]diskInfo {
disks := make(map[string]diskInfo)
if node.Status.DiskStatus == nil {
return disks
}
for diskName, diskSpec := range node.Spec.Disks {
di := diskInfo{
DiskSpec: diskSpec,
}
if diskStatus, ok := node.Status.DiskStatus[diskName]; ok {
di.DiskStatus = *diskStatus
}
disks[diskName] = di
}
return disks
}