Skip to content

Commit 37beeb7

Browse files
rbtrjpayne3506
authored andcommitted
change total IPs and add secondary IP metric (#2172)
* change total IPs and add secondary IP metric Updates the Total IPs metrics to include the NC Primary IP in the total. Adds a Secondary IPs metric which holds the value that the Total IPs previously held: NC Secondary IPs known to CNS which could be used by Pods. Signed-off-by: GitHub <[email protected]> * update help wording on IPAM metrics Signed-off-by: Evan Baker <[email protected]> * reword PrimaryIP metric help Signed-off-by: Evan Baker <[email protected]> --------- Signed-off-by: GitHub <[email protected]> Signed-off-by: Evan Baker <[email protected]>
1 parent 00cb951 commit 37beeb7

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

cns/ipampool/metrics.go

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ var (
2020
ipamAllocatedIPCount = prometheus.NewGaugeVec(
2121
prometheus.GaugeOpts{
2222
Name: "cx_ipam_pod_allocated_ips",
23-
Help: "Count of IPs CNS has allocated to Pods.",
23+
Help: "IPs currently in use by Pods on this CNS Node.",
2424
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
2525
},
2626
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
2727
)
2828
ipamAvailableIPCount = prometheus.NewGaugeVec(
2929
prometheus.GaugeOpts{
3030
Name: "cx_ipam_available_ips",
31-
Help: "Available IP count.",
31+
Help: "IPs available on this CNS Node for use by a Pod.",
3232
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
3333
},
3434
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
3535
)
3636
ipamBatchSize = prometheus.NewGaugeVec(
3737
prometheus.GaugeOpts{
3838
Name: "cx_ipam_batch_size",
39-
Help: "IPAM IP pool batch size.",
39+
Help: "IPAM IP pool scaling batch size.",
4040
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
4141
},
4242
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
@@ -60,65 +60,73 @@ var (
6060
ipamMaxIPCount = prometheus.NewGaugeVec(
6161
prometheus.GaugeOpts{
6262
Name: "cx_ipam_max_ips",
63-
Help: "Maximum IP count.",
63+
Help: "Maximum Secondary IPs allowed on this Node.",
6464
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
6565
},
6666
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
6767
)
6868
ipamPendingProgramIPCount = prometheus.NewGaugeVec(
6969
prometheus.GaugeOpts{
7070
Name: "cx_ipam_pending_programming_ips",
71-
Help: "Pending programming IP count.",
71+
Help: "IPs reserved but not yet available (Pending Programming).",
7272
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
7373
},
7474
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
7575
)
7676
ipamPendingReleaseIPCount = prometheus.NewGaugeVec(
7777
prometheus.GaugeOpts{
7878
Name: "cx_ipam_pending_release_ips",
79-
Help: "Pending release IP count.",
79+
Help: "IPs reserved but not available anymore (Pending Release).",
8080
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
8181
},
8282
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
8383
)
8484
ipamPrimaryIPCount = prometheus.NewGaugeVec(
8585
prometheus.GaugeOpts{
8686
Name: "cx_ipam_primary_ips",
87-
Help: "NC Primary IP count.",
87+
Help: "NC Primary IP count (reserved from Pod Subnet for DNS and IMDS SNAT).",
8888
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
8989
},
9090
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
9191
)
9292
ipamRequestedIPConfigCount = prometheus.NewGaugeVec(
9393
prometheus.GaugeOpts{
9494
Name: "cx_ipam_requested_ips",
95-
Help: "Requested IP count.",
95+
Help: "Secondary Pod Subnet IPs requested by this CNS Node (for Pods).",
9696
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
9797
},
9898
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
9999
)
100-
ipamTotalIPCount = prometheus.NewGaugeVec(
100+
ipamSecondaryIPCount = prometheus.NewGaugeVec(
101101
prometheus.GaugeOpts{
102-
Name: "cx_ipam_total_ips",
103-
Help: "Count of total IP pool size allocated to CNS by DNC.",
102+
Name: "cx_ipam_secondary_ips",
103+
Help: "Node NC Secondary IP count (reserved usable by Pods).",
104104
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
105105
},
106106
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
107107
)
108+
ipamSubnetExhaustionCount = prometheus.NewCounterVec(
109+
prometheus.CounterOpts{
110+
Name: "cx_ipam_subnet_exhaustion_state_count_total",
111+
Help: "Count of the number of times the ipam pool monitor sees subnet exhaustion",
112+
},
113+
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel, subnetExhaustionStateLabel},
114+
)
108115
ipamSubnetExhaustionState = prometheus.NewGaugeVec(
109116
prometheus.GaugeOpts{
110117
Name: "cx_ipam_subnet_exhaustion_state",
111-
Help: "IPAM view of subnet exhaustion state",
118+
Help: "CNS view of subnet exhaustion state",
112119
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
113120
},
114121
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
115122
)
116-
ipamSubnetExhaustionCount = prometheus.NewCounterVec(
117-
prometheus.CounterOpts{
118-
Name: "cx_ipam_subnet_exhaustion_state_count_total",
119-
Help: "Count of the number of times the ipam pool monitor sees subnet exhaustion",
123+
ipamTotalIPCount = prometheus.NewGaugeVec(
124+
prometheus.GaugeOpts{
125+
Name: "cx_ipam_total_ips",
126+
Help: "Total IPs reserved from the Pod Subnet by this Node.",
127+
ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
120128
},
121-
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel, subnetExhaustionStateLabel},
129+
[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
122130
)
123131
)
124132

@@ -134,9 +142,10 @@ func init() {
134142
ipamPendingReleaseIPCount,
135143
ipamPrimaryIPCount,
136144
ipamRequestedIPConfigCount,
137-
ipamTotalIPCount,
138-
ipamSubnetExhaustionState,
145+
ipamSecondaryIPCount,
139146
ipamSubnetExhaustionCount,
147+
ipamSubnetExhaustionState,
148+
ipamTotalIPCount,
140149
)
141150
}
142151

@@ -152,7 +161,8 @@ func observeIPPoolState(state ipPoolState, meta metaState) {
152161
ipamPendingReleaseIPCount.WithLabelValues(labels...).Set(float64(state.pendingRelease))
153162
ipamPrimaryIPCount.WithLabelValues(labels...).Set(float64(len(meta.primaryIPAddresses)))
154163
ipamRequestedIPConfigCount.WithLabelValues(labels...).Set(float64(state.requestedIPs))
155-
ipamTotalIPCount.WithLabelValues(labels...).Set(float64(state.totalIPs))
164+
ipamSecondaryIPCount.WithLabelValues(labels...).Set(float64(state.secondaryIPs))
165+
ipamTotalIPCount.WithLabelValues(labels...).Set(float64(state.secondaryIPs + int64(len(meta.primaryIPAddresses))))
156166
if meta.exhausted {
157167
ipamSubnetExhaustionState.WithLabelValues(labels...).Set(float64(subnetIPExhausted))
158168
} else {

cns/ipampool/monitor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ type ipPoolState struct {
164164
pendingRelease int64
165165
// requestedIPs are the IPs CNS has requested that it be allocated by DNC.
166166
requestedIPs int64
167-
// totalIPs are all the IPs given to CNS by DNC.
168-
totalIPs int64
167+
// secondaryIPs are all the IPs given to CNS by DNC, not including the primary IP of the NC.
168+
secondaryIPs int64
169169
}
170170

171171
func buildIPPoolState(ips map[string]cns.IPConfigurationStatus, spec v1alpha.NodeNetworkConfigSpec) ipPoolState {
172172
state := ipPoolState{
173-
totalIPs: int64(len(ips)),
173+
secondaryIPs: int64(len(ips)),
174174
requestedIPs: spec.RequestedIPCount,
175175
}
176176
for i := range ips {
@@ -186,7 +186,7 @@ func buildIPPoolState(ips map[string]cns.IPConfigurationStatus, spec v1alpha.Nod
186186
state.pendingRelease++
187187
}
188188
}
189-
state.currentAvailableIPs = state.totalIPs - state.allocatedToPods - state.pendingRelease
189+
state.currentAvailableIPs = state.secondaryIPs - state.allocatedToPods - state.pendingRelease
190190
state.expectedAvailableIPs = state.requestedIPs - state.allocatedToPods
191191
return state
192192
}

0 commit comments

Comments
 (0)