Skip to content

Commit

Permalink
Always initialize ovs_meter_packet_dropped_count metrics (#5428)
Browse files Browse the repository at this point in the history
Otherwise the metric is not showing up if OVS Meter is not supported on
the system, causing e2e test failure.

Signed-off-by: Quan Tian <[email protected]>
  • Loading branch information
tnqn authored Aug 23, 2023
1 parent a61d002 commit 9c34f70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pkg/agent/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
const (
metricNamespaceAntrea = "antrea"
metricSubsystemAgent = "agent"

LabelPacketInMeterNetworkPolicy = "PacketInMeterNetworkPolicy"
LabelPacketInMeterTraceflow = "PacketInMeterTraceflow"
)

var (
Expand Down Expand Up @@ -232,12 +235,14 @@ func InitializeOVSMetrics() {
}
// Initialize OpenFlow operations metrics with label add, modify and delete
// since those metrics won't come out until observation.
opsArray := [3]string{"add", "modify", "delete"}
for _, ops := range opsArray {
for _, ops := range []string{"add", "modify", "delete"} {
OVSFlowOpsCount.WithLabelValues(ops)
OVSFlowOpsErrorCount.WithLabelValues(ops)
OVSFlowOpsLatency.WithLabelValues(ops)
}
for _, label := range []string{LabelPacketInMeterNetworkPolicy, LabelPacketInMeterTraceflow} {
OVSMeterPacketDroppedCount.WithLabelValues(label)
}
}

func InitializeConnectionMetrics() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/openflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1558,9 +1558,9 @@ func (c *client) getMeterStats() {
handleMeterStatsReply := func(meterID int, packetCount int64) {
switch meterID {
case PacketInMeterIDNP:
metrics.OVSMeterPacketDroppedCount.WithLabelValues("PacketInMeterNetworkPolicy").Set(float64(packetCount))
metrics.OVSMeterPacketDroppedCount.WithLabelValues(metrics.LabelPacketInMeterNetworkPolicy).Set(float64(packetCount))
case PacketInMeterIDTF:
metrics.OVSMeterPacketDroppedCount.WithLabelValues("PacketInMeterTraceflow").Set(float64(packetCount))
metrics.OVSMeterPacketDroppedCount.WithLabelValues(metrics.LabelPacketInMeterTraceflow).Set(float64(packetCount))
default:
klog.V(4).InfoS("Received unexpected meterID", "meterID", meterID)
}
Expand Down

0 comments on commit 9c34f70

Please sign in to comment.