mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-22 06:27:49 +00:00
Improve error messages. Fix gateway_id is missing ... errors.
The error would occur when the uplink was also received by an unknown gateway. In this case fetching the metadata for this gateway would fail, causing the gateway_private_up and _down not to be populated with the gateway_id.
This commit is contained in:
parent
f776dd3898
commit
eda5753bb9
@ -46,7 +46,9 @@ pub fn select_downlink_gateway(
|
||||
.collect();
|
||||
|
||||
if rx_info.items.is_empty() {
|
||||
return Err(anyhow!("rx_info.items can not be empty"));
|
||||
return Err(anyhow!(
|
||||
"RxInfo set is empty after applying filters, no downlink gateway available"
|
||||
));
|
||||
}
|
||||
|
||||
let region_conf = region::get(region_config_id)?;
|
||||
|
@ -407,7 +407,7 @@ impl Data {
|
||||
trace!("Filtering rx_info by tenant_id");
|
||||
|
||||
match filter_rx_info_by_tenant_id(
|
||||
&self.application.as_ref().unwrap().tenant_id,
|
||||
self.application.as_ref().unwrap().tenant_id,
|
||||
&mut self.uplink_frame_set,
|
||||
) {
|
||||
Ok(_) => Ok(()),
|
||||
|
@ -218,7 +218,7 @@ impl JoinRequest {
|
||||
trace!("Filtering rx_info by tenant_id");
|
||||
|
||||
filter_rx_info_by_tenant_id(
|
||||
&self.application.as_ref().unwrap().tenant_id,
|
||||
self.application.as_ref().unwrap().tenant_id,
|
||||
&mut self.uplink_frame_set,
|
||||
)?;
|
||||
Ok(())
|
||||
|
@ -354,7 +354,7 @@ async fn update_gateway_metadata(ufs: &mut UplinkFrameSet) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn filter_rx_info_by_tenant_id(tenant_id: &Uuid, uplink: &mut UplinkFrameSet) -> Result<()> {
|
||||
fn filter_rx_info_by_tenant_id(tenant_id: Uuid, uplink: &mut UplinkFrameSet) -> Result<()> {
|
||||
let mut rx_info_set: Vec<gw::UplinkRxInfo> = Vec::new();
|
||||
|
||||
for rx_info in &uplink.rx_info_set {
|
||||
@ -366,15 +366,17 @@ fn filter_rx_info_by_tenant_id(tenant_id: &Uuid, uplink: &mut UplinkFrameSet) ->
|
||||
.ok_or_else(|| anyhow!("No region_config_id in rx_info metadata"))?;
|
||||
let force_gws_private = config::get_force_gws_private(®ion_config_id)?;
|
||||
|
||||
if !(*uplink
|
||||
if !(uplink
|
||||
.gateway_private_up_map
|
||||
.get(&gateway_id)
|
||||
.ok_or_else(|| anyhow!("gateway_id missing in gateway_private_up_map"))?
|
||||
.cloned()
|
||||
.unwrap_or_else(|| true)
|
||||
|| force_gws_private)
|
||||
|| uplink
|
||||
.gateway_tenant_id_map
|
||||
.get(&gateway_id)
|
||||
.ok_or_else(|| anyhow!("gateway_id is missing in gateway_tenant_id_map"))?
|
||||
.cloned()
|
||||
.unwrap_or_else(|| Uuid::new_v4())
|
||||
== tenant_id
|
||||
{
|
||||
rx_info_set.push(rx_info.clone());
|
||||
@ -383,7 +385,7 @@ fn filter_rx_info_by_tenant_id(tenant_id: &Uuid, uplink: &mut UplinkFrameSet) ->
|
||||
|
||||
uplink.rx_info_set = rx_info_set;
|
||||
if uplink.rx_info_set.is_empty() {
|
||||
return Err(anyhow!("rx_info_set has no items"));
|
||||
return Err(anyhow!("RxInfo set is empty after applying filters"));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user