Skip to content

Commit cf35d2a

Browse files
Return all LLDP configs for each switch port settings object (#8665)
* We allowed multiple LLDP link configs to be created on a single switch port settings object, but we would only return one when viewing the object. This has been fixed. * Note that until we support breakout connections, only one lldp configuration will be applied. This is not a regression. Related --- Resolves #8640
1 parent 1591e21 commit cf35d2a

File tree

6 files changed

+69
-20
lines changed

6 files changed

+69
-20
lines changed

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(177, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(178, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(178, "change-lldp-management-ip-to-inet"),
3132
KnownVersion::new(177, "add-host-ereport-part-number"),
3233
KnownVersion::new(176, "audit-log"),
3334
KnownVersion::new(175, "inv-host-phase-1-active-slot"),

nexus/db-queries/src/db/datastore/switch_port.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ impl DataStore {
504504
result.link_lldp = lldp_link_config::dsl::lldp_link_config
505505
.filter(lldp_link_config::id.eq_any(lldp_link_ids))
506506
.select(LldpLinkConfig::as_select())
507-
.limit(1)
508507
.load_async::<LldpLinkConfig>(&conn)
509508
.await?;
510509

@@ -523,7 +522,6 @@ impl DataStore {
523522
let configs = tx_eq_config::dsl::tx_eq_config
524523
.filter(tx_eq_config::id.eq_any(tx_eq_ids))
525524
.select(TxEqConfig::as_select())
526-
.limit(1)
527525
.load_async::<TxEqConfig>(&conn)
528526
.await?;
529527
result.tx_eq = tx_eq_ids_and_nulls

nexus/tests/integration_tests/switch_port.rs

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,38 +112,70 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
112112
description: "just a port".into(),
113113
});
114114

115-
let link_name =
115+
let link0_name =
116116
Name::from_str("phy0").expect("phy0 should be a valid name");
117117

118-
let lldp_params = LldpLinkConfigCreate {
118+
let lldp0_params = LldpLinkConfigCreate {
119119
enabled: true,
120120
link_name: Some("Link Name".into()),
121-
link_description: Some("link_ Dscription".into()),
121+
link_description: Some("link description".into()),
122122
chassis_id: Some("Chassis ID".into()),
123123
system_name: Some("System Name".into()),
124124
system_description: Some("System description".into()),
125-
management_ip: None,
125+
management_ip: Some(
126+
"203.0.113.10"
127+
.parse()
128+
.expect("management_ip should be a valid address"),
129+
),
130+
};
131+
132+
let link1_name =
133+
Name::from_str("phy1").expect("phy1 should be a valid name");
134+
135+
let lldp1_params = LldpLinkConfigCreate {
136+
enabled: true,
137+
link_name: Some("Link Name 2".into()),
138+
link_description: Some("link description".into()),
139+
chassis_id: Some("Chassis ID".into()),
140+
system_name: Some("System Name".into()),
141+
system_description: Some("System description".into()),
142+
management_ip: Some(
143+
"203.0.113.10"
144+
.parse()
145+
.expect("management_ip should be a valid address"),
146+
),
126147
};
127148

128149
// links
129150
settings.links.push(LinkConfigCreate {
130-
link_name: link_name.clone(),
151+
link_name: link0_name.clone(),
152+
mtu: 4700,
153+
lldp: lldp0_params.clone(),
154+
fec: Some(LinkFec::None),
155+
speed: LinkSpeed::Speed100G,
156+
autoneg: false,
157+
tx_eq: None,
158+
});
159+
160+
settings.links.push(LinkConfigCreate {
161+
link_name: link1_name.clone(),
131162
mtu: 4700,
132-
lldp: lldp_params.clone(),
163+
lldp: lldp1_params.clone(),
133164
fec: Some(LinkFec::None),
134165
speed: LinkSpeed::Speed100G,
135166
autoneg: false,
136167
tx_eq: None,
137168
});
169+
138170
// interfaces
139171
settings.interfaces.push(SwitchInterfaceConfigCreate {
140-
link_name: link_name.clone(),
172+
link_name: link0_name.clone(),
141173
v6_enabled: true,
142174
kind: SwitchInterfaceKind::Primary,
143175
});
144176
// routes
145177
settings.routes.push(RouteConfig {
146-
link_name: link_name.clone(),
178+
link_name: link0_name.clone(),
147179
routes: vec![Route {
148180
dst: "1.2.3.0/24".parse().unwrap(),
149181
gw: "1.2.3.4".parse().unwrap(),
@@ -153,7 +185,7 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
153185
});
154186
// addresses
155187
settings.addresses.push(AddressConfig {
156-
link_name: link_name.clone(),
188+
link_name: link0_name.clone(),
157189
addresses: vec![Address {
158190
address: "203.0.113.10/24".parse().unwrap(),
159191
vlan_id: None,
@@ -173,7 +205,7 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
173205
.parsed_body()
174206
.unwrap();
175207

176-
assert_eq!(created.links.len(), 1);
208+
assert_eq!(created.links.len(), 2);
177209
assert_eq!(created.routes.len(), 1);
178210
assert_eq!(created.addresses.len(), 1);
179211

@@ -182,7 +214,14 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
182214
assert_eq!(link0.mtu, 4700);
183215

184216
let lldp0 = link0.lldp_link_config.clone().unwrap();
185-
assert_eq!(lldp0, lldp_params);
217+
assert_eq!(lldp0, lldp0_params);
218+
219+
let link1 = &created.links[1];
220+
assert_eq!(&link1.link_name.to_string(), "phy1");
221+
assert_eq!(link1.mtu, 4700);
222+
223+
let lldp1 = link1.lldp_link_config.clone().unwrap();
224+
assert_eq!(lldp1, lldp1_params);
186225

187226
let ifx0 = &created.interfaces[0];
188227
assert_eq!(&ifx0.interface_name.to_string(), "phy0");
@@ -208,7 +247,7 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
208247
.parsed_body()
209248
.unwrap();
210249

211-
assert_eq!(roundtrip.links.len(), 1);
250+
assert_eq!(roundtrip.links.len(), 2);
212251
assert_eq!(roundtrip.routes.len(), 1);
213252
assert_eq!(roundtrip.addresses.len(), 1);
214253

@@ -217,7 +256,14 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
217256
assert_eq!(link0.mtu, 4700);
218257

219258
let lldp0 = link0.lldp_link_config.clone().unwrap();
220-
assert_eq!(lldp0, lldp_params);
259+
assert_eq!(lldp0, lldp0_params);
260+
261+
let link1 = &roundtrip.links[1];
262+
assert_eq!(&link1.link_name.to_string(), "phy1");
263+
assert_eq!(link1.mtu, 4700);
264+
265+
let lldp1 = link1.lldp_link_config.clone().unwrap();
266+
assert_eq!(lldp1, lldp1_params);
221267

222268
let ifx0 = &roundtrip.interfaces[0];
223269
assert_eq!(&ifx0.interface_name.to_string(), "phy0");
@@ -259,7 +305,7 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
259305

260306
// Update port settings. Should not see conflict.
261307
settings.bgp_peers.push(BgpPeerConfig {
262-
link_name: link_name.clone(),
308+
link_name: link0_name.clone(),
263309
peers: vec![BgpPeer {
264310
bgp_config: NameOrId::Name("as47".parse().unwrap()),
265311
interface_name: "phy0".parse().unwrap(),
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE IF EXISTS omicron.public.lldp_link_config
2+
DROP COLUMN IF EXISTS management_ip;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE IF EXISTS omicron.public.lldp_link_config
2+
ADD COLUMN IF NOT EXISTS management_ip INET;

schema/crdb/dbinit.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,10 +3108,10 @@ CREATE TABLE IF NOT EXISTS omicron.public.lldp_link_config (
31083108
chassis_id STRING(63),
31093109
system_name STRING(63),
31103110
system_description STRING(612),
3111-
management_ip TEXT,
31123111
time_created TIMESTAMPTZ NOT NULL,
31133112
time_modified TIMESTAMPTZ NOT NULL,
3114-
time_deleted TIMESTAMPTZ
3113+
time_deleted TIMESTAMPTZ,
3114+
management_ip INET
31153115
);
31163116

31173117
CREATE TABLE IF NOT EXISTS omicron.public.tx_eq_config (
@@ -6497,7 +6497,7 @@ INSERT INTO omicron.public.db_metadata (
64976497
version,
64986498
target_version
64996499
) VALUES
6500-
(TRUE, NOW(), NOW(), '177.0.0', NULL)
6500+
(TRUE, NOW(), NOW(), '178.0.0', NULL)
65016501
ON CONFLICT DO NOTHING;
65026502

65036503
COMMIT;

0 commit comments

Comments
 (0)