ifaces: Do not verify absent real NIC

When NetworkManager has inactive connection referring to a real NIC via
MAC address other than interface name, nmstate will not able to remove
that profile/connection which fail the verification for absent action:

    VerificationError: Absent interface ens3f0np0/ethernet still found as
    state up

It is complex to match such profile to interface when performing profile
deletion(the inactivate mac-referring profile only link to interface
after we delete its active profile).

Considering this is corner case, we just loose the absent verification on
real hardware.

Unit test case included.

Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
Gris Ge 2022-09-26 17:24:54 +08:00 committed by Fernando Fernández Mancera
parent 64df47df95
commit afd380e1db
2 changed files with 23 additions and 14 deletions

View File

@ -375,21 +375,8 @@ fn verify_desire_absent_but_found_in_current(
);
log::error!("{}", e);
Err(e)
} else if cur_iface.is_up() {
// Real hardware should be marked as down by absent action
let e = NmstateError::new(
ErrorKind::VerificationError,
format!(
"Absent interface {}/{} still found as \
state up: {:?}",
des_iface.name(),
des_iface.iface_type(),
cur_iface
),
);
log::error!("{}", e);
Err(e)
} else {
// Hard to predict real hardware state due to backend variety.
Ok(())
}
}

View File

@ -76,3 +76,25 @@ fn test_veth_change_peer_away_from_ignored_peer() {
assert_eq!(e.kind(), ErrorKind::InvalidArgument);
}
}
#[test]
fn test_eth_verify_absent_ignore_current_up() {
let desired: Interfaces = serde_yaml::from_str(
r#"---
- name: eth1
type: ethernet
state: absent
"#,
)
.unwrap();
let current: Interfaces = serde_yaml::from_str(
r#"---
- name: eth1
type: ethernet
state: up
"#,
)
.unwrap();
desired.verify(&Interfaces::new(), &current).unwrap();
}