mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +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> {
|
||||
// Set up shared IPC namespace
|
||||
self.shared_ipcns = match Namespace::new(&self.logger).as_ipc().setup() {
|
||||
Ok(ns) => ns,
|
||||
Err(err) => {
|
||||
return Err(anyhow!(err).context("Failed to setup persistent IPC namespace"));
|
||||
}
|
||||
};
|
||||
self.shared_ipcns = Namespace::new(&self.logger)
|
||||
.as_ipc()
|
||||
.setup()
|
||||
.context("Failed to setup persistent IPC 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())
|
||||
.setup()
|
||||
{
|
||||
Ok(ns) => ns,
|
||||
Err(err) => {
|
||||
return Err(anyhow!(err).context("Failed to setup persistent UTS namespace"));
|
||||
}
|
||||
};
|
||||
.context("Failed to setup persistent UTS namespace")?;
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user