Skip to content

Commit 682d0cd

Browse files
daniel-nolandclaude
andcommitted
feat(rate-limit): configure shared meters from peering annotations
Accept named bits/packet meters, ordered ACL matches, and standard quantity and duration formats. Export per-meter counters to Prometheus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Daniel Noland <daniel@githedgehog.com>
1 parent 33d516c commit 682d0cd

25 files changed

Lines changed: 1946 additions & 987 deletions

File tree

‎Cargo.lock‎

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ netgauze-bgp-pkt = { version = "0.13.0", features = [] }
204204
netgauze-bmp-pkt = { version = "0.13.0", features = [] }
205205
nix = { version = "0.31.3", default-features = false, features = [] }
206206
num-derive = { version = "0.5.1", default-features = false, features = [] }
207+
num-bigint = { version = "0.5.1", default-features = false, features = ["std"] }
207208
num-traits = { version = "0.2.19", default-features = false, features = [] }
208209
once_cell = { version = "1.21.4", default-features = false, features = [] }
209210
ordermap = { version = "1.2.2", default-features = false, features = [] }

‎config/Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ bolero = { workspace = true, optional = true, default-features = false, features
2525
chrono = { workspace = true, features = ["alloc", "std"] }
2626
derive_builder = { workspace = true, features = [] }
2727
ipnet = { workspace = true }
28+
k8s-openapi = { workspace = true, features = ["latest"] }
29+
num-bigint = { workspace = true }
30+
num-traits = { workspace = true }
2831
multi_index_map = { workspace = true, features = ["serde"] }
2932
ordermap = { workspace = true, features = ["std"] }
33+
serde = { workspace = true, features = ["derive", "std"] }
34+
serde_json = { workspace = true, features = ["std", "arbitrary_precision"] }
3035
thiserror = { workspace = true }
3136
tracing = { workspace = true, features = ["attributes"] }
3237

‎config/src/converters/k8s/config/acl.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl TryFrom<(&SubnetMap, &SubnetMap, &GatewayAgentPeeringsAclRulesMatch)> for A
197197
/// # Errors
198198
///
199199
/// Returns an error if both values are blank, or if a non-blank value matches neither VPC name.
200-
fn complete_from_to(
200+
pub(super) fn complete_from_to(
201201
rule_name: &str,
202202
from: &str,
203203
to: &str,

‎config/src/converters/k8s/config/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod gwgroups;
1515
pub mod interface;
1616
pub mod overlay;
1717
pub mod peering;
18+
pub mod ratelimit;
1819
pub mod tracecfg;
1920
pub mod underlay;
2021
pub mod vpc;

‎config/src/converters/k8s/config/overlay.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::external::overlay::Overlay;
1212
use crate::external::overlay::vpc::{Vpc, VpcTable};
1313
use crate::external::overlay::vpcpeering::{VpcPeering, VpcPeeringTable};
1414

15-
fn extract_subnets(
15+
pub(super) fn extract_subnets(
1616
vpcs: &BTreeMap<String, GatewayAgentVpcs>,
1717
) -> Result<VpcSubnetMap, FromK8sConversionError> {
1818
let mut vpc_subnets = VpcSubnetMap::new();
@@ -65,7 +65,8 @@ impl TryFrom<&GatewayAgentSpec> for Overlay {
6565
type Error = FromK8sConversionError;
6666

6767
fn try_from(spec: &GatewayAgentSpec) -> Result<Self, Self::Error> {
68-
match (spec.vpcs.as_ref(), spec.peerings.as_ref()) {
68+
let rate_limits = super::ratelimit::rate_limits(spec)?;
69+
let overlay = match (spec.vpcs.as_ref(), spec.peerings.as_ref()) {
6970
(None, None) => Ok(Overlay::new(VpcTable::new(), VpcPeeringTable::new())),
7071
(None, Some(peerings)) => Err(FromK8sConversionError::NotAllowed(format!(
7172
"Found 0 vpcs but {} peerings",
@@ -83,7 +84,8 @@ impl TryFrom<&GatewayAgentSpec> for Overlay {
8384
let overlay = Overlay::new(vpc_table, peering_table);
8485
Ok(overlay)
8586
}
86-
}
87+
}?;
88+
Ok(overlay.with_rate_limits(rate_limits))
8789
}
8890
}
8991

0 commit comments

Comments
 (0)