File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ import (
32
32
33
33
const (
34
34
fetchMetricsTimeout = 5 * time .Second
35
+ roleLabel = "llmd.org/role"
36
+ rolePrefill = "prefill"
37
+ roleDecode = "decode"
38
+ roleBoth = "both"
35
39
)
36
40
37
41
type podMetrics struct {
@@ -67,13 +71,34 @@ func (pm *podMetrics) UpdatePod(in *corev1.Pod) {
67
71
pm .pod .Store (toInternalPod (in ))
68
72
}
69
73
74
+ func podLabelToRole (in * corev1.Pod ) PodRole {
75
+ roleLabel , ok := in .ObjectMeta .Labels [roleLabel ]
76
+
77
+ if ok {
78
+ switch roleLabel {
79
+ case rolePrefill :
80
+ return Prefill
81
+ case roleDecode :
82
+ return Decode
83
+ case roleBoth :
84
+ return Both
85
+ default :
86
+ return Unknown
87
+ }
88
+ }
89
+
90
+ // role label is missing
91
+ return Both
92
+ }
93
+
70
94
func toInternalPod (in * corev1.Pod ) * Pod {
71
95
return & Pod {
72
96
NamespacedName : types.NamespacedName {
73
97
Name : in .Name ,
74
98
Namespace : in .Namespace ,
75
99
},
76
100
Address : in .Status .PodIP ,
101
+ Role : podLabelToRole (in ),
77
102
}
78
103
}
79
104
Original file line number Diff line number Diff line change @@ -65,9 +65,19 @@ type PodMetrics interface {
65
65
String () string
66
66
}
67
67
68
+ type PodRole int
69
+
70
+ const (
71
+ Prefill PodRole = iota
72
+ Decode
73
+ Both
74
+ Unknown
75
+ )
76
+
68
77
type Pod struct {
69
78
NamespacedName types.NamespacedName
70
79
Address string
80
+ Role PodRole
71
81
}
72
82
73
83
func (p * Pod ) String () string {
@@ -87,6 +97,7 @@ func (p *Pod) Clone() *Pod {
87
97
Namespace : p .NamespacedName .Namespace ,
88
98
},
89
99
Address : p .Address ,
100
+ Role : p .Role ,
90
101
}
91
102
}
92
103
You can’t perform that action at this time.
0 commit comments