Skip to content

Commit

Permalink
remove OS metric label
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerad committed Nov 9, 2021
1 parent 9d34d21 commit a41d432
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
2 changes: 0 additions & 2 deletions pkg/controllers/metrics/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ const (

metricLabelArch = "arch"
metricLabelInstanceType = "instancetype"
metricLabelOS = "os"
metricLabelPhase = "phase"
metricLabelProvisioner = metrics.ProvisionerLabel
metricLabelZone = "zone"

nodeLabelArch = v1.LabelArchStable
nodeLabelInstanceType = v1.LabelInstanceTypeStable
nodeLabelOS = v1.LabelOSStable
nodeLabelZone = v1.LabelTopologyZone

nodeConditionTypeReady = v1.NodeReady
Expand Down
3 changes: 0 additions & 3 deletions pkg/controllers/metrics/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,15 @@ func (c *Controller) updateNodeCounts(ctx context.Context, provisioner *v1alpha5

archValues := sets.NewString()
instanceTypeValues := sets.NewString()
osValues := sets.NewString()
zoneValues := sets.NewString()
for _, instanceType := range instanceTypes {
archValues.Insert(instanceType.Architecture())
instanceTypeValues.Insert(instanceType.Name())
osValues.Insert(instanceType.OperatingSystems().UnsortedList()...)
zoneValues.Insert(instanceType.Zones().UnsortedList()...)
}
knownValuesForNodeLabels := map[string]sets.String{
nodeLabelArch: archValues,
nodeLabelInstanceType: instanceTypeValues,
nodeLabelOS: osValues,
nodeLabelZone: zoneValues,
}

Expand Down
20 changes: 2 additions & 18 deletions pkg/controllers/metrics/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ var (
Namespace: metrics.Namespace,
Subsystem: metricSubsystemCapacity,
Name: "ready_node_os_count",
Help: "Count of nodes that are ready by operating system, provisioner, and zone.",
Help: "Count of nodes that are ready by provisioner, and zone.",
},
[]string{
metricLabelOS,
metricLabelProvisioner,
metricLabelZone,
},
Expand All @@ -111,10 +110,9 @@ func init() {
func publishNodeCounts(provisioner string, knownValuesForNodeLabels map[string]sets.String, consumeNodesWith consumeNodesWithFunc) error {
archValues := knownValuesForNodeLabels[nodeLabelArch]
instanceTypeValues := knownValuesForNodeLabels[nodeLabelInstanceType]
osValues := knownValuesForNodeLabels[nodeLabelOS]
zoneValues := knownValuesForNodeLabels[nodeLabelZone]

errors := make([]error, 0, len(archValues)*len(instanceTypeValues)*len(osValues)*len(zoneValues))
errors := make([]error, 0, len(archValues)*len(instanceTypeValues)*len(zoneValues))

nodeLabels := client.MatchingLabels{nodeLabelProvisioner: provisioner}
errors = append(errors, consumeNodesWith(nodeLabels, func(nodes []v1.Node) error {
Expand Down Expand Up @@ -151,17 +149,6 @@ func publishNodeCounts(provisioner string, knownValuesForNodeLabels map[string]s
return publishCount(readyNodeCountByInstancetypeProvisionerZone, metricLabelsFrom(nodeLabels), len(readyNodes))
})))
}

for os := range osValues {
nodeLabels := client.MatchingLabels{
nodeLabelOS: os,
nodeLabelProvisioner: provisioner,
nodeLabelZone: zone,
}
errors = append(errors, consumeNodesWith(nodeLabels, filterReadyNodes(func(readyNodes []v1.Node) error {
return publishCount(readyNodeCountByOsProvisionerZone, metricLabelsFrom(nodeLabels), len(readyNodes))
})))
}
}

return multierr.Combine(errors...)
Expand Down Expand Up @@ -192,9 +179,6 @@ func metricLabelsFrom(nodeLabels map[string]string) prometheus.Labels {
if instanceType := nodeLabels[nodeLabelInstanceType]; instanceType != "" {
metricLabels[metricLabelInstanceType] = instanceType
}
if os := nodeLabels[nodeLabelOS]; os != "" {
metricLabels[metricLabelOS] = os
}
if provisioner := nodeLabels[nodeLabelProvisioner]; provisioner != "" {
metricLabels[metricLabelProvisioner] = provisioner
}
Expand Down

0 comments on commit a41d432

Please sign in to comment.