mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-11 04:42:16 +00:00
Merge pull request #5047 from amshinde/2.5.1-branch-bump
# Kata Containers 2.5.1
This commit is contained in:
commit
65dd151e0a
@ -249,7 +249,20 @@ impl AgentService {
|
|||||||
info!(sl!(), "no process configurations!");
|
info!(sl!(), "no process configurations!");
|
||||||
return Err(anyhow!(nix::Error::EINVAL));
|
return Err(anyhow!(nix::Error::EINVAL));
|
||||||
};
|
};
|
||||||
ctr.start(p).await?;
|
|
||||||
|
// if starting container failed, we will do some rollback work
|
||||||
|
// to ensure no resources are leaked.
|
||||||
|
if let Err(err) = ctr.start(p).await {
|
||||||
|
error!(sl!(), "failed to start container: {:?}", err);
|
||||||
|
if let Err(e) = ctr.destroy().await {
|
||||||
|
error!(sl!(), "failed to destroy container: {:?}", e);
|
||||||
|
}
|
||||||
|
if let Err(e) = remove_container_resources(&mut s, &cid) {
|
||||||
|
error!(sl!(), "failed to remove container resources: {:?}", e);
|
||||||
|
}
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
|
||||||
s.update_shared_pidns(&ctr)?;
|
s.update_shared_pidns(&ctr)?;
|
||||||
s.add_container(ctr);
|
s.add_container(ctr);
|
||||||
info!(sl!(), "created container!");
|
info!(sl!(), "created container!");
|
||||||
@ -295,27 +308,6 @@ impl AgentService {
|
|||||||
req: protocols::agent::RemoveContainerRequest,
|
req: protocols::agent::RemoveContainerRequest,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let cid = req.container_id.clone();
|
let cid = req.container_id.clone();
|
||||||
let mut cmounts: Vec<String> = vec![];
|
|
||||||
|
|
||||||
let mut remove_container_resources = |sandbox: &mut Sandbox| -> Result<()> {
|
|
||||||
// Find the sandbox storage used by this container
|
|
||||||
let mounts = sandbox.container_mounts.get(&cid);
|
|
||||||
if let Some(mounts) = mounts {
|
|
||||||
for m in mounts.iter() {
|
|
||||||
if sandbox.storages.get(m).is_some() {
|
|
||||||
cmounts.push(m.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for m in cmounts.iter() {
|
|
||||||
sandbox.unset_and_remove_sandbox_storage(m)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
sandbox.container_mounts.remove(cid.as_str());
|
|
||||||
sandbox.containers.remove(cid.as_str());
|
|
||||||
Ok(())
|
|
||||||
};
|
|
||||||
|
|
||||||
if req.timeout == 0 {
|
if req.timeout == 0 {
|
||||||
let s = Arc::clone(&self.sandbox);
|
let s = Arc::clone(&self.sandbox);
|
||||||
@ -329,7 +321,7 @@ impl AgentService {
|
|||||||
.destroy()
|
.destroy()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
remove_container_resources(&mut sandbox)?;
|
remove_container_resources(&mut sandbox, &cid)?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -361,8 +353,7 @@ impl AgentService {
|
|||||||
|
|
||||||
let s = self.sandbox.clone();
|
let s = self.sandbox.clone();
|
||||||
let mut sandbox = s.lock().await;
|
let mut sandbox = s.lock().await;
|
||||||
|
remove_container_resources(&mut sandbox, &cid)?;
|
||||||
remove_container_resources(&mut sandbox)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1752,6 +1743,35 @@ fn update_container_namespaces(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_container_resources(sandbox: &mut Sandbox, cid: &str) -> Result<()> {
|
||||||
|
let mut cmounts: Vec<String> = vec![];
|
||||||
|
|
||||||
|
// Find the sandbox storage used by this container
|
||||||
|
let mounts = sandbox.container_mounts.get(cid);
|
||||||
|
if let Some(mounts) = mounts {
|
||||||
|
for m in mounts.iter() {
|
||||||
|
if sandbox.storages.get(m).is_some() {
|
||||||
|
cmounts.push(m.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for m in cmounts.iter() {
|
||||||
|
if let Err(err) = sandbox.unset_and_remove_sandbox_storage(m) {
|
||||||
|
error!(
|
||||||
|
sl!(),
|
||||||
|
"failed to unset_and_remove_sandbox_storage for container {}, error: {:?}",
|
||||||
|
cid,
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sandbox.container_mounts.remove(cid);
|
||||||
|
sandbox.containers.remove(cid);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn append_guest_hooks(s: &Sandbox, oci: &mut Spec) -> Result<()> {
|
fn append_guest_hooks(s: &Sandbox, oci: &mut Spec) -> Result<()> {
|
||||||
if let Some(ref guest_hooks) = s.hooks {
|
if let Some(ref guest_hooks) = s.hooks {
|
||||||
let mut hooks = oci.hooks.take().unwrap_or_default();
|
let mut hooks = oci.hooks.take().unwrap_or_default();
|
||||||
|
@ -97,9 +97,10 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create root span
|
// create root span
|
||||||
|
// rootSpan will be ended when the entire trace is ended
|
||||||
rootSpan, newCtx := katatrace.Trace(s.ctx, shimLog, "rootSpan", shimTracingTags)
|
rootSpan, newCtx := katatrace.Trace(s.ctx, shimLog, "rootSpan", shimTracingTags)
|
||||||
s.rootCtx = newCtx
|
s.rootCtx = newCtx
|
||||||
defer rootSpan.End()
|
s.rootSpan = rootSpan
|
||||||
|
|
||||||
// create span
|
// create span
|
||||||
span, newCtx := katatrace.Trace(s.rootCtx, shimLog, "create", shimTracingTags)
|
span, newCtx := katatrace.Trace(s.rootCtx, shimLog, "create", shimTracingTags)
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
otelTrace "go.opentelemetry.io/otel/trace"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
|
||||||
@ -124,6 +125,7 @@ type service struct {
|
|||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
rootCtx context.Context // root context for tracing
|
rootCtx context.Context // root context for tracing
|
||||||
|
rootSpan otelTrace.Span
|
||||||
|
|
||||||
containers map[string]*container
|
containers map[string]*container
|
||||||
|
|
||||||
@ -946,6 +948,7 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *
|
|||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
span.End()
|
span.End()
|
||||||
|
s.rootSpan.End()
|
||||||
katatrace.StopTracing(s.rootCtx)
|
katatrace.StopTracing(s.rootCtx)
|
||||||
|
|
||||||
return empty, nil
|
return empty, nil
|
||||||
|
@ -18,7 +18,7 @@ spec:
|
|||||||
katacontainers.io/kata-runtime: cleanup
|
katacontainers.io/kata-runtime: cleanup
|
||||||
containers:
|
containers:
|
||||||
- name: kube-kata-cleanup
|
- name: kube-kata-cleanup
|
||||||
image: quay.io/kata-containers/kata-deploy:2.5.0
|
image: quay.io/kata-containers/kata-deploy:2.5.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
|
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
|
||||||
env:
|
env:
|
||||||
|
@ -16,7 +16,7 @@ spec:
|
|||||||
serviceAccountName: kata-label-node
|
serviceAccountName: kata-label-node
|
||||||
containers:
|
containers:
|
||||||
- name: kube-kata
|
- name: kube-kata
|
||||||
image: quay.io/kata-containers/kata-deploy:2.5.0
|
image: quay.io/kata-containers/kata-deploy:2.5.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
lifecycle:
|
lifecycle:
|
||||||
preStop:
|
preStop:
|
||||||
|
@ -12,6 +12,7 @@ CONFIG_CGROUP_FREEZER=y
|
|||||||
CONFIG_CPUSETS=y
|
CONFIG_CPUSETS=y
|
||||||
CONFIG_CGROUP_DEVICE=y
|
CONFIG_CGROUP_DEVICE=y
|
||||||
CONFIG_CGROUP_CPUACCT=y
|
CONFIG_CGROUP_CPUACCT=y
|
||||||
|
CONFIG_CGROUP_HUGETLB=y
|
||||||
CONFIG_CGROUP_PERF=y
|
CONFIG_CGROUP_PERF=y
|
||||||
CONFIG_SOCK_CGROUP_DATA=y
|
CONFIG_SOCK_CGROUP_DATA=y
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
94
|
95
|
||||||
|
Loading…
Reference in New Issue
Block a user