mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
agent: use anyhow context
to attach context to Error
instead of match
Context is clearer than match for these situations. Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
parent
2f690a2bb0
commit
47ff2fb9a0
@ -166,23 +166,17 @@ impl Sandbox {
|
|||||||
|
|
||||||
pub fn setup_shared_namespaces(&mut self) -> Result<bool> {
|
pub fn setup_shared_namespaces(&mut self) -> Result<bool> {
|
||||||
// Set up shared IPC namespace
|
// Set up shared IPC namespace
|
||||||
self.shared_ipcns = match Namespace::new(&self.logger).as_ipc().setup() {
|
self.shared_ipcns = Namespace::new(&self.logger)
|
||||||
Ok(ns) => ns,
|
.as_ipc()
|
||||||
Err(err) => {
|
.setup()
|
||||||
return Err(anyhow!(err).context("Failed to setup persistent IPC namespace"));
|
.context("Failed to setup persistent IPC namespace")?;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// // Set up shared UTS namespace
|
// // Set up shared UTS namespace
|
||||||
self.shared_utsns = match Namespace::new(&self.logger)
|
self.shared_utsns = Namespace::new(&self.logger)
|
||||||
.as_uts(self.hostname.as_str())
|
.as_uts(self.hostname.as_str())
|
||||||
.setup()
|
.setup()
|
||||||
{
|
.context("Failed to setup persistent UTS namespace")?;
|
||||||
Ok(ns) => ns,
|
|
||||||
Err(err) => {
|
|
||||||
return Err(anyhow!(err).context("Failed to setup persistent UTS namespace"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user