mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
shim: Fix CreateContainer for the confidential computing case
In the confidential computing scenario, there is no Image information on the host, so skip handling Rootfs at CreateContainer. Fixes #3009 Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
This commit is contained in:
@@ -242,6 +242,11 @@ func loadRuntimeConfig(s *service, r *taskAPI.CreateTaskRequest, anno map[string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkAndMount(s *service, r *taskAPI.CreateTaskRequest) (bool, error) {
|
func checkAndMount(s *service, r *taskAPI.CreateTaskRequest) (bool, error) {
|
||||||
|
// In the confidential computing, there is no Image information on the host,
|
||||||
|
// so there is no Rootfs.
|
||||||
|
if s.config.ServiceOffload && len(r.Rootfs) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
if len(r.Rootfs) == 1 {
|
if len(r.Rootfs) == 1 {
|
||||||
m := r.Rootfs[0]
|
m := r.Rootfs[0]
|
||||||
|
|
||||||
|
@@ -1166,6 +1166,7 @@ func LoadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat
|
|||||||
config.JaegerEndpoint = tomlConf.Runtime.JaegerEndpoint
|
config.JaegerEndpoint = tomlConf.Runtime.JaegerEndpoint
|
||||||
config.JaegerUser = tomlConf.Runtime.JaegerUser
|
config.JaegerUser = tomlConf.Runtime.JaegerUser
|
||||||
config.JaegerPassword = tomlConf.Runtime.JaegerPassword
|
config.JaegerPassword = tomlConf.Runtime.JaegerPassword
|
||||||
|
config.ServiceOffload = tomlConf.Image.ServiceOffload
|
||||||
for _, f := range tomlConf.Runtime.Experimental {
|
for _, f := range tomlConf.Runtime.Experimental {
|
||||||
feature := exp.Get(f)
|
feature := exp.Get(f)
|
||||||
if feature == nil {
|
if feature == nil {
|
||||||
|
@@ -1252,6 +1252,11 @@ func (c *Container) hotplugDrive(ctx context.Context) error {
|
|||||||
// Check to see if the rootfs is an umounted block device (source) or if the
|
// Check to see if the rootfs is an umounted block device (source) or if the
|
||||||
// mount (target) is backed by a block device:
|
// mount (target) is backed by a block device:
|
||||||
if !c.rootFs.Mounted {
|
if !c.rootFs.Mounted {
|
||||||
|
// In the confidential computing, there is no Image information on the host,
|
||||||
|
// so there is no Rootfs.Source.
|
||||||
|
if c.sandbox.config.ServiceOffload && c.rootFs.Source == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
dev, err = getDeviceForPath(c.rootFs.Source)
|
dev, err = getDeviceForPath(c.rootFs.Source)
|
||||||
// there is no "rootfs" dir on block device backed rootfs
|
// there is no "rootfs" dir on block device backed rootfs
|
||||||
c.rootfsSuffix = ""
|
c.rootfsSuffix = ""
|
||||||
|
@@ -1235,6 +1235,11 @@ func (k *kataAgent) rollbackFailingContainerCreation(ctx context.Context, c *Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) buildContainerRootfs(ctx context.Context, sandbox *Sandbox, c *Container, rootPathParent string) (*grpc.Storage, error) {
|
func (k *kataAgent) buildContainerRootfs(ctx context.Context, sandbox *Sandbox, c *Container, rootPathParent string) (*grpc.Storage, error) {
|
||||||
|
// In the confidential computing, there is no Image information on the host,
|
||||||
|
// so there is no Rootfs.Target.
|
||||||
|
if sandbox.config.ServiceOffload && c.rootFs.Target == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
if c.state.Fstype != "" && c.state.BlockDeviceID != "" {
|
if c.state.Fstype != "" && c.state.BlockDeviceID != "" {
|
||||||
// The rootfs storage volume represents the container rootfs
|
// The rootfs storage volume represents the container rootfs
|
||||||
// mount point inside the guest.
|
// mount point inside the guest.
|
||||||
|
@@ -134,6 +134,9 @@ type RuntimeConfig struct {
|
|||||||
|
|
||||||
// Determines if enable pprof
|
// Determines if enable pprof
|
||||||
EnablePprof bool
|
EnablePprof bool
|
||||||
|
|
||||||
|
// Offload the CRI image management service to the Kata agent.
|
||||||
|
ServiceOffload bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddKernelParam allows the addition of new kernel parameters to an existing
|
// AddKernelParam allows the addition of new kernel parameters to an existing
|
||||||
@@ -917,6 +920,8 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c
|
|||||||
// Spec: &ocispec,
|
// Spec: &ocispec,
|
||||||
|
|
||||||
Experimental: runtime.Experimental,
|
Experimental: runtime.Experimental,
|
||||||
|
|
||||||
|
ServiceOffload: runtime.ServiceOffload,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := addAnnotations(ocispec, &sandboxConfig, runtime); err != nil {
|
if err := addAnnotations(ocispec, &sandboxConfig, runtime); err != nil {
|
||||||
|
@@ -147,6 +147,9 @@ type SandboxConfig struct {
|
|||||||
SandboxCgroupOnly bool
|
SandboxCgroupOnly bool
|
||||||
|
|
||||||
DisableGuestSeccomp bool
|
DisableGuestSeccomp bool
|
||||||
|
|
||||||
|
// Offload the CRI image management service to the Kata agent.
|
||||||
|
ServiceOffload bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid checks that the sandbox configuration is valid.
|
// valid checks that the sandbox configuration is valid.
|
||||||
|
Reference in New Issue
Block a user