mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 15:57:09 +00:00
runtime: support to configure CreateContainer timeout in annotation
Support to configure CreateContainerRequestTimeout in the annotations. e.g.: annotations: "io.katacontainers.config.runtime.create_container_timeout": "300" Note: The effective timeout is determined by the lesser of two values: runtime-request-timeout from kubelet config (https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/#:~:text=runtime%2Drequest%2Dtimeout) and create_container_timeout. In essence, the timeout used for guest pull=runtime-request-timeout<create_container_timeout?runtime-request-timeout:create_container_timeout. Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
This commit is contained in:
parent
39bd462431
commit
2224f6d63f
@ -186,6 +186,7 @@ type runtime struct {
|
|||||||
StaticSandboxResourceMgmt bool `toml:"static_sandbox_resource_mgmt"`
|
StaticSandboxResourceMgmt bool `toml:"static_sandbox_resource_mgmt"`
|
||||||
EnablePprof bool `toml:"enable_pprof"`
|
EnablePprof bool `toml:"enable_pprof"`
|
||||||
DisableGuestEmptyDir bool `toml:"disable_guest_empty_dir"`
|
DisableGuestEmptyDir bool `toml:"disable_guest_empty_dir"`
|
||||||
|
CreateContainerTimeout uint64 `toml:"create_container_timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type agent struct {
|
type agent struct {
|
||||||
@ -1569,6 +1570,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.CreateContainerTimeout = tomlConf.Runtime.CreateContainerTimeout
|
||||||
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 {
|
||||||
|
@ -156,6 +156,10 @@ type RuntimeConfig struct {
|
|||||||
|
|
||||||
// Determines if Kata creates emptyDir on the guest
|
// Determines if Kata creates emptyDir on the guest
|
||||||
DisableGuestEmptyDir bool
|
DisableGuestEmptyDir bool
|
||||||
|
|
||||||
|
// CreateContainer timeout which, if provided, indicates the createcontainer request timeout
|
||||||
|
// needed for the workload ( Mostly used for pulling images in the guest )
|
||||||
|
CreateContainerTimeout uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddKernelParam allows the addition of new kernel parameters to an existing
|
// AddKernelParam allows the addition of new kernel parameters to an existing
|
||||||
@ -864,6 +868,12 @@ func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, r
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := newAnnotationConfiguration(ocispec, vcAnnotations.CreateContainerTimeout).setUint(func(createContainerTimeout uint64) {
|
||||||
|
sbConfig.CreateContainerTimeout = createContainerTimeout
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := newAnnotationConfiguration(ocispec, vcAnnotations.EnableVCPUsPinning).setBool(func(enableVCPUsPinning bool) {
|
if err := newAnnotationConfiguration(ocispec, vcAnnotations.EnableVCPUsPinning).setBool(func(enableVCPUsPinning bool) {
|
||||||
sbConfig.EnableVCPUsPinning = enableVCPUsPinning
|
sbConfig.EnableVCPUsPinning = enableVCPUsPinning
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -1007,6 +1017,8 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid st
|
|||||||
GuestSeLinuxLabel: runtime.GuestSeLinuxLabel,
|
GuestSeLinuxLabel: runtime.GuestSeLinuxLabel,
|
||||||
|
|
||||||
Experimental: runtime.Experimental,
|
Experimental: runtime.Experimental,
|
||||||
|
|
||||||
|
CreateContainerTimeout: runtime.CreateContainerTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := addAnnotations(ocispec, &sandboxConfig, runtime); err != nil {
|
if err := addAnnotations(ocispec, &sandboxConfig, runtime); err != nil {
|
||||||
|
@ -810,12 +810,14 @@ func TestAddRuntimeAnnotations(t *testing.T) {
|
|||||||
ocispec.Annotations[vcAnnotations.SandboxCgroupOnly] = "true"
|
ocispec.Annotations[vcAnnotations.SandboxCgroupOnly] = "true"
|
||||||
ocispec.Annotations[vcAnnotations.DisableNewNetNs] = "true"
|
ocispec.Annotations[vcAnnotations.DisableNewNetNs] = "true"
|
||||||
ocispec.Annotations[vcAnnotations.InterNetworkModel] = "macvtap"
|
ocispec.Annotations[vcAnnotations.InterNetworkModel] = "macvtap"
|
||||||
|
ocispec.Annotations[vcAnnotations.CreateContainerTimeout] = "100"
|
||||||
|
|
||||||
addAnnotations(ocispec, &config, runtimeConfig)
|
addAnnotations(ocispec, &config, runtimeConfig)
|
||||||
assert.Equal(config.DisableGuestSeccomp, true)
|
assert.Equal(config.DisableGuestSeccomp, true)
|
||||||
assert.Equal(config.SandboxCgroupOnly, true)
|
assert.Equal(config.SandboxCgroupOnly, true)
|
||||||
assert.Equal(config.NetworkConfig.DisableNewNetwork, true)
|
assert.Equal(config.NetworkConfig.DisableNewNetwork, true)
|
||||||
assert.Equal(config.NetworkConfig.InterworkingModel, vc.NetXConnectMacVtapModel)
|
assert.Equal(config.NetworkConfig.InterworkingModel, vc.NetXConnectMacVtapModel)
|
||||||
|
assert.Equal(config.CreateContainerTimeout, uint64(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegexpContains(t *testing.T) {
|
func TestRegexpContains(t *testing.T) {
|
||||||
|
@ -377,6 +377,11 @@ func (k *kataAgent) init(ctx context.Context, sandbox *Sandbox, config KataAgent
|
|||||||
k.kmodules = config.KernelModules
|
k.kmodules = config.KernelModules
|
||||||
k.dialTimout = config.DialTimeout
|
k.dialTimout = config.DialTimeout
|
||||||
|
|
||||||
|
createContainerRequestTimeout = time.Duration(sandbox.config.CreateContainerTimeout) * time.Second
|
||||||
|
k.Logger().WithFields(logrus.Fields{
|
||||||
|
"createContainerRequestTimeout": fmt.Sprintf("%+v", createContainerRequestTimeout),
|
||||||
|
}).Info("The createContainerRequestTimeout has been set ")
|
||||||
|
|
||||||
return disableVMShutdown, nil
|
return disableVMShutdown, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +271,9 @@ const (
|
|||||||
// VfioMode is a sandbox annotation to specify how attached VFIO devices should be treated
|
// VfioMode is a sandbox annotation to specify how attached VFIO devices should be treated
|
||||||
// Overrides the runtime.vfio_mode parameter in the global configuration.toml
|
// Overrides the runtime.vfio_mode parameter in the global configuration.toml
|
||||||
VfioMode = kataAnnotRuntimePrefix + "vfio_mode"
|
VfioMode = kataAnnotRuntimePrefix + "vfio_mode"
|
||||||
|
|
||||||
|
// CreateContainerTimeout is a sandbox annotaion that sets the create container timeout.
|
||||||
|
CreateContainerTimeout = kataAnnotRuntimePrefix + "create_container_timeout"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Agent related annotations
|
// Agent related annotations
|
||||||
|
@ -182,6 +182,10 @@ type SandboxConfig struct {
|
|||||||
|
|
||||||
// EnableVCPUsPinning controls whether each vCPU thread should be scheduled to a fixed CPU
|
// EnableVCPUsPinning controls whether each vCPU thread should be scheduled to a fixed CPU
|
||||||
EnableVCPUsPinning bool
|
EnableVCPUsPinning bool
|
||||||
|
|
||||||
|
// Create container timeout which, if provided, indicates the create container timeout
|
||||||
|
// needed for the workload(s)
|
||||||
|
CreateContainerTimeout uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid checks that the sandbox configuration is valid.
|
// valid checks that the sandbox configuration is valid.
|
||||||
|
Loading…
Reference in New Issue
Block a user