Skip to content

Commit

Permalink
Fix type mismatch between table and view (#6039)
Browse files Browse the repository at this point in the history
vlan_id column in switchport settings child table is type `Int4`, but
`bgp_peer_view`'s diesel schema is `Int8`, causing an error when
deserializing data from the view (allocated buffer is larger than the
received bytes).
  • Loading branch information
internet-diglett authored Jul 10, 2024
1 parent 808b1a1 commit 09d7fc7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions nexus/db-model/src/bgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::schema::{
bgp_announce_set, bgp_announcement, bgp_config, bgp_peer_view,
};
use crate::SqlU32;
use crate::{SqlU16, SqlU32};
use db_macros::Resource;
use ipnetwork::IpNetwork;
use nexus_types::external_api::params;
Expand Down Expand Up @@ -141,5 +141,5 @@ pub struct BgpPeerView {
pub multi_exit_discriminator: Option<SqlU32>,
pub local_pref: Option<SqlU32>,
pub enforce_first_as: bool,
pub vlan_id: Option<SqlU32>,
pub vlan_id: Option<SqlU16>,
}
2 changes: 1 addition & 1 deletion nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ table! {
multi_exit_discriminator -> Nullable<Int8>,
local_pref -> Nullable<Int8>,
enforce_first_as -> Bool,
vlan_id -> Nullable<Int8>,
vlan_id -> Nullable<Int4>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ impl BackgroundTask for SwitchPortSettingsManager {
communities: Vec::new(),
allowed_export: ImportExportPolicy::NoFiltering,
allowed_import: ImportExportPolicy::NoFiltering,
vlan_id: c.vlan_id.map(|x| x.0 as u16),
vlan_id: c.vlan_id.map(|x| x.0),
}
}).collect(),
port: port.port_name.clone(),
Expand Down

0 comments on commit 09d7fc7

Please sign in to comment.