Skip to content

Commit b1e251e

Browse files
selector:MatchLabel (#249)
* selector:MatchLabel * selector:MatchLabel
1 parent 6862f0f commit b1e251e

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

pkg/analyze/node_resources.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ func nodeMatchesFilters(node corev1.Node, filters *troubleshootv1beta1.NodeResou
319319
}
320320

321321
// all filters must pass for this to pass
322+
if filters.Selector != nil {
323+
for k, v := range filters.Selector.MatchLabel {
324+
if l, found := node.Labels[k]; !found || l != v {
325+
return false, errors.Errorf("failed to match label %s", k)
326+
}
327+
}
328+
}
322329

323330
if filters.CPUCapacity != "" {
324331
parsed, err := resource.ParseQuantity(filters.CPUCapacity)

pkg/apis/troubleshoot/v1beta1/analyzer_shared.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,19 @@ type NodeResources struct {
8484
}
8585

8686
type NodeResourceFilters struct {
87-
CPUCapacity string `json:"cpuCapacity,omitempty" yaml:"cpuCapacity,omitempty"`
88-
CPUAllocatable string `json:"cpuAllocatable,omitempty" yaml:"cpuAllocatable,omitempty"`
89-
MemoryCapacity string `json:"memoryCapacity,omitempty" yaml:"memoryCapacity,omitempty"`
90-
MemoryAllocatable string `json:"memoryAllocatable,omitempty" yaml:"memoryAllocatable,omitempty"`
91-
PodCapacity string `json:"podCapacity,omitempty" yaml:"podCapacity,omitempty"`
92-
PodAllocatable string `json:"podAllocatable,omitempty" yaml:"podAllocatable,omitempty"`
93-
EphemeralStorageCapacity string `json:"ephemeralStorageCapacity,omitempty" yaml:"ephemeralStorageCapacity,omitempty"`
94-
EphemeralStorageAllocatable string `json:"ephemeralStorageAllocatable,omitempty" yaml:"ephemeralStorageAllocatable,omitempty"`
87+
CPUCapacity string `json:"cpuCapacity,omitempty" yaml:"cpuCapacity,omitempty"`
88+
CPUAllocatable string `json:"cpuAllocatable,omitempty" yaml:"cpuAllocatable,omitempty"`
89+
MemoryCapacity string `json:"memoryCapacity,omitempty" yaml:"memoryCapacity,omitempty"`
90+
MemoryAllocatable string `json:"memoryAllocatable,omitempty" yaml:"memoryAllocatable,omitempty"`
91+
PodCapacity string `json:"podCapacity,omitempty" yaml:"podCapacity,omitempty"`
92+
PodAllocatable string `json:"podAllocatable,omitempty" yaml:"podAllocatable,omitempty"`
93+
EphemeralStorageCapacity string `json:"ephemeralStorageCapacity,omitempty" yaml:"ephemeralStorageCapacity,omitempty"`
94+
EphemeralStorageAllocatable string `json:"ephemeralStorageAllocatable,omitempty" yaml:"ephemeralStorageAllocatable,omitempty"`
95+
Selector *NodeResourceSelectors `json:"selector,omitempty" yaml:"selector,omitempty"`
96+
}
97+
98+
type NodeResourceSelectors struct {
99+
MatchLabel map[string]string `json:"matchLabel,omitempty" yaml:"matchLabel,omitempty"`
95100
}
96101

97102
type TextAnalyze struct {

0 commit comments

Comments
 (0)