Skip to content

Commit 005aac0

Browse files
authored
Oximeter: Add opte metrics. (#11003)
Expose a subset of opte kstats as oximeter metrics, limited to uft and route cache metrics initially. We track each opte port in sled-agent so that we can collate control plane metadata (nic id, parent id, etc.) with kstat values. Part of #10892. Note: this is mostly a mechanical change, extracting more metrics from opte's new kstats. We already know how to track and untrack links, so we can mostly reuse that logic. I think the interesting parts are which metrics to include (I'm proposing a subset related to uft and route cache performance and occupancy) and how often to sample them (I'm using the link sampling interval of 10s for now). It's easier to add features than remove them, so I'd like to identify the minimal useful set of opte metrics for now, then think about expanding the set later on. Marking as draft while I deploy to a racklette for testing, and write up notes on cardinality.
1 parent 7964f11 commit 005aac0

10 files changed

Lines changed: 771 additions & 19 deletions

File tree

‎illumos-utils/src/opte/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use oxnet::IpNet;
3333
use oxnet::Ipv4Net;
3434
use oxnet::Ipv6Net;
3535
pub use port::Port;
36+
pub use port::PortInfo;
3637
pub use port_manager::MulticastGroupCfg;
3738
pub use port_manager::PortCreateParams;
3839
pub use port_manager::PortManager;

‎illumos-utils/src/opte/port.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ use omicron_common::api::internal::shared::RouterId;
1414
use omicron_common::api::internal::shared::RouterKind;
1515
use oxnet::Ipv4Net;
1616
use oxnet::Ipv6Net;
17+
use sled_agent_types::inventory::NetworkInterfaceKind;
1718
use std::net::IpAddr;
1819
use std::net::Ipv4Addr;
1920
use std::net::Ipv6Addr;
2021
use std::sync::Arc;
22+
use uuid::Uuid;
2123

2224
#[derive(Debug)]
2325
pub struct PortData {
@@ -159,3 +161,10 @@ impl Port {
159161
})
160162
}
161163
}
164+
165+
/// An OPTE port, along with its control plane metadata.
166+
pub struct PortInfo {
167+
pub port: Port,
168+
pub nic_id: Uuid,
169+
pub nic_kind: NetworkInterfaceKind,
170+
}

‎illumos-utils/src/opte/port_manager.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,14 @@ impl PortTicket {
11561156
Self { id, kind, manager }
11571157
}
11581158

1159+
pub fn id(&self) -> Uuid {
1160+
self.id
1161+
}
1162+
1163+
pub fn kind(&self) -> NetworkInterfaceKind {
1164+
self.kind
1165+
}
1166+
11591167
fn release_inner(&mut self) -> Result<(), Error> {
11601168
let mut ports = self.manager.ports.lock().unwrap();
11611169
let Some(port) = ports.remove(&(self.id, self.kind)) else {

‎illumos-utils/src/running_zone.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::addrobj::{
1212
use crate::contract;
1313
use crate::dladm::Etherstub;
1414
use crate::link::{Link, VnicAllocator};
15-
use crate::opte::{Port, PortTicket};
15+
use crate::opte::{Port, PortInfo, PortTicket};
1616
use crate::zone::Zones;
1717
use crate::zone::{AddressRequest, ROUTE};
1818
use crate::zpool::{PathInPool, ZpoolOrRamdisk};
@@ -496,6 +496,10 @@ impl RunningZone {
496496
self.inner.opte_ports()
497497
}
498498

499+
pub fn opte_port_info(&self) -> impl Iterator<Item = PortInfo> {
500+
self.inner.opte_port_info()
501+
}
502+
499503
/// Remove the OPTE ports on this zone from the port manager.
500504
pub fn release_opte_ports(&mut self) {
501505
for (_, ticket) in self.inner.opte_ports.drain(..) {
@@ -752,6 +756,15 @@ impl InstalledZone {
752756
self.opte_ports.iter().map(|(port, _)| port)
753757
}
754758

759+
/// Returns references to the OPTE ports and metadata for this zone.
760+
pub fn opte_port_info(&self) -> impl Iterator<Item = PortInfo> {
761+
self.opte_ports.iter().map(|(port, ticket)| PortInfo {
762+
port: port.clone(),
763+
nic_id: ticket.id(),
764+
nic_kind: ticket.kind(),
765+
})
766+
}
767+
755768
/// Returns the filesystem path to the zone's root in the GZ.
756769
pub fn root(&self) -> Utf8PathBuf {
757770
self.zonepath.path.join(Self::ROOT_FS_PATH)

‎oximeter/instruments/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ uuid = { workspace = true, optional = true }
3131
omicron-workspace-hack.workspace = true
3232

3333
[features]
34-
default = ["http-instruments", "cpu", "datalink", "zfs", "zone"]
34+
default = ["http-instruments", "cpu", "datalink", "opte_port", "zfs", "zone"]
3535
http-instruments = [
3636
"dep:chrono",
3737
"dep:dropshot",
@@ -59,6 +59,7 @@ kstat = [
5959
]
6060
cpu = ["kstat"]
6161
datalink = ["kstat"]
62+
opte_port = ["kstat"]
6263
zfs = [
6364
"dep:anyhow",
6465
"dep:illumos-utils",

‎oximeter/instruments/src/kstat/link.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
//! Report metrics about Ethernet data links on the host system
5+
//! Report metrics about Ethernet data links on the host system.
66
77
use crate::kstat::ConvertNamedData;
88
use crate::kstat::Error;

‎oximeter/instruments/src/kstat/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ use std::time::Duration;
8989
pub mod cpu;
9090
#[cfg(any(feature = "datalink", test))]
9191
pub mod link;
92+
#[cfg(any(feature = "opte_port", test))]
93+
pub mod opte_port;
9294
mod sampler;
9395
#[cfg(any(feature = "zone", test))]
9496
pub mod zone;

0 commit comments

Comments
 (0)