Skip to content

Commit ef407a2

Browse files
committed
Add kind label to metadata; rename owner->workload for user-exposed api
Since these annotations are a user-exposed API, it is preferable to use a more k8s-standard terminology, ie "workload" instead of "owner".
1 parent abedf75 commit ef407a2

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

internal/pkg/metrics/alerts/builder_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,35 +195,37 @@ func TestHealthAnnotationMetadata(t *testing.T) {
195195
groupBy flowslatest.HealthRuleGroupBy
196196
expectedNodeLabels []string
197197
expectedNamespaceLabels []string
198-
expectedOwnerLabels []string
198+
expectedWorkloadLabels []string
199+
expectedKindLabels []string
199200
}{
200201
{
201202
name: "Global (no grouping)",
202203
groupBy: "",
203204
expectedNodeLabels: nil,
204205
expectedNamespaceLabels: nil,
205-
expectedOwnerLabels: nil,
206+
expectedWorkloadLabels: nil,
206207
},
207208
{
208209
name: "GroupBy Node",
209210
groupBy: flowslatest.GroupByNode,
210211
expectedNodeLabels: []string{"node"},
211212
expectedNamespaceLabels: nil,
212-
expectedOwnerLabels: nil,
213+
expectedWorkloadLabels: nil,
213214
},
214215
{
215216
name: "GroupBy Namespace",
216217
groupBy: flowslatest.GroupByNamespace,
217218
expectedNodeLabels: nil,
218219
expectedNamespaceLabels: []string{"namespace"},
219-
expectedOwnerLabels: nil,
220+
expectedWorkloadLabels: nil,
220221
},
221222
{
222223
name: "GroupBy Workload",
223224
groupBy: flowslatest.GroupByWorkload,
224225
expectedNodeLabels: nil,
225226
expectedNamespaceLabels: []string{"namespace"},
226-
expectedOwnerLabels: []string{"workload"},
227+
expectedWorkloadLabels: []string{"workload"},
228+
expectedKindLabels: []string{"kind"},
227229
},
228230
}
229231

@@ -247,7 +249,8 @@ func TestHealthAnnotationMetadata(t *testing.T) {
247249

248250
assert.Equal(t, tt.expectedNodeLabels, ha.NodeLabels, "Expected nodeLabels=%s in annotation for %s", tt.expectedNodeLabels, tt.name)
249251
assert.Equal(t, tt.expectedNamespaceLabels, ha.NamespaceLabels, "Expected namespaceLabels=%s in annotation for %s", tt.expectedNamespaceLabels, tt.name)
250-
assert.Equal(t, tt.expectedOwnerLabels, ha.OwnerLabels, "Expected ownerLabels=%s in annotation for %s", tt.expectedOwnerLabels, tt.name)
252+
assert.Equal(t, tt.expectedWorkloadLabels, ha.WorkloadLabels, "Expected workloadLabels=%s in annotation for %s", tt.expectedWorkloadLabels, tt.name)
253+
assert.Equal(t, tt.expectedKindLabels, ha.KindLabels, "Expected kindLabels=%s in annotation for %s", tt.expectedKindLabels, tt.name)
251254
})
252255
}
253256
}

internal/pkg/metrics/alerts/context.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ type healthAnnotation struct {
3636
Unit string `json:"unit,omitempty"`
3737
NodeLabels []string `json:"nodeLabels,omitempty"`
3838
NamespaceLabels []string `json:"namespaceLabels,omitempty"`
39-
OwnerLabels []string `json:"ownerLabels,omitempty"`
39+
WorkloadLabels []string `json:"workloadLabels,omitempty"`
40+
KindLabels []string `json:"kindLabels,omitempty"`
4041
TrafficLink *trafficLink `json:"trafficLink,omitempty"`
4142
}
4243

@@ -98,7 +99,8 @@ func newHealthAnnotation(ctx *ruleContext) *healthAnnotation {
9899
annotation.NamespaceLabels = []string{"namespace"}
99100
case flowslatest.GroupByWorkload:
100101
annotation.NamespaceLabels = []string{"namespace"}
101-
annotation.OwnerLabels = []string{"workload"}
102+
annotation.WorkloadLabels = []string{"workload"}
103+
annotation.KindLabels = []string{"kind"}
102104
}
103105
return &annotation
104106
}

0 commit comments

Comments
 (0)