mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 07:18:27 +00:00
kata-agent: fixing bug of unable setting hostname correctly.
When do update_container_namespaces updating namespaces, setting all UTS(and IPC) namespace paths to None resulted in hostnames set prior to the update becoming ineffective. This was primarily due to an error made while aligning with the oci spec: in an attempt to match empty strings with None values in oci-spec-rs, all paths were incorrectly set to None. Fixes #10325 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -1679,13 +1679,19 @@ fn update_container_namespaces(
|
||||
if let Some(namespaces) = linux.namespaces_mut() {
|
||||
for namespace in namespaces.iter_mut() {
|
||||
if namespace.typ().to_string() == NSTYPEIPC {
|
||||
namespace.set_path(Some(PathBuf::from(&sandbox.shared_ipcns.path.clone())));
|
||||
namespace.set_path(None);
|
||||
namespace.set_path(if !sandbox.shared_ipcns.path.is_empty() {
|
||||
Some(PathBuf::from(&sandbox.shared_ipcns.path))
|
||||
} else {
|
||||
None
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if namespace.typ().to_string() == NSTYPEUTS {
|
||||
namespace.set_path(Some(PathBuf::from(&sandbox.shared_utsns.path.clone())));
|
||||
namespace.set_path(None);
|
||||
namespace.set_path(if !sandbox.shared_utsns.path.is_empty() {
|
||||
Some(PathBuf::from(&sandbox.shared_utsns.path))
|
||||
} else {
|
||||
None
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user