Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not perform network namespace detection on AV update #912

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/dns/aardvark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,27 @@ impl Aardvark {
Ok(())
}

pub fn notify(&self, start: bool) -> NetavarkResult<()> {
pub fn notify(&self, start: bool, is_update: bool) -> NetavarkResult<()> {
match self.get_aardvark_pid() {
Ok(pid) => {
match signal::kill(Pid::from_raw(pid), Signal::SIGHUP) {
Ok(_) => match self.check_netns(pid) {
Ok(_) => return Ok(()),
Err(e) => {
// If the error is ENOENT it means the process must have died in
// the meantime so drop down below to start a new server process.
if e.kind() != std::io::ErrorKind::NotFound {
return Err(NetavarkError::wrap(
"check aardvark-dns netns",
e.into(),
));
Ok(_) => {
if !is_update {
match self.check_netns(pid) {
Ok(_) => return Ok(()),
Err(e) => {
// If the error is ENOENT it means the process must have died in
// the meantime so drop down below to start a new server process.
if e.kind() != std::io::ErrorKind::NotFound {
return Err(NetavarkError::wrap(
"check aardvark-dns netns",
e.into(),
));
}
}
}
}
},
}
Err(err) => {
// ESRCH == process does not exists
// start new sever below in that case and not error
Expand Down Expand Up @@ -312,7 +316,7 @@ impl Aardvark {
pub fn commit_netavark_entries(&self, entries: Vec<AardvarkEntry>) -> NetavarkResult<()> {
if !entries.is_empty() {
self.commit_entries(entries)?;
self.notify(true)?;
self.notify(true, false)?;
}
Ok(())
}
Expand Down Expand Up @@ -407,7 +411,7 @@ impl Aardvark {
// If dns servers were updated notify the aardvark-dns server
// if refresh is needed.
if dns_servers_modified {
self.notify(false)?;
self.notify(false, true)?;
}

Ok(())
Expand All @@ -417,6 +421,6 @@ impl Aardvark {
for entry in &entries {
self.delete_entry(entry.container_id, entry.network_name)?;
}
self.notify(false)
self.notify(false, false)
}
}
5 changes: 4 additions & 1 deletion test/100-bridge-iptables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ fw_driver=iptables
run_helper ps "$aardvark_pid"
assert "${lines[1]}" =~ ".*aardvark-dns --config $NETAVARK_TMPDIR/config/aardvark-dns -p $dns_port run" "aardvark not running or bad options"

NETAVARK_DNS_PORT="$dns_port" run_netavark --file ${TESTSDIR}/testfiles/dualstack-bridge-network-container-dns-server.json \
# Use run_helper instead of run_netavark here to check network namespace detection logic.
# See https://github.com/containers/netavark/issues/911 for details.
NETAVARK_DNS_PORT="$dns_port" run_helper $NETAVARK --config "$NETAVARK_TMPDIR/config" --rootless "$rootless" --file ${TESTSDIR}/testfiles/dualstack-bridge-network-container-dns-server.json \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment on what we do this here may be appropriate as it may be forgotten otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

update podman1 --network-dns-servers 8.8.8.8
assert "$output" = ""

# check aardvark config and running
run_helper cat "$NETAVARK_TMPDIR/config/aardvark-dns/podman1"
Expand Down