mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 08:17:37 +00:00
runtime: make dialing timeout configurable
allow to set dialing timeout in configuration.toml
default is 30s
Fixes: #1789
(cherry-picked 01b56d6cbf
)
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
This commit is contained in:
parent
70734dfa17
commit
c0bdba2350
@ -150,6 +150,10 @@ block_device_driver = "@DEFBLOCKSTORAGEDRIVER_ACRN@"
|
|||||||
|
|
||||||
#debug_console_enabled = true
|
#debug_console_enabled = true
|
||||||
|
|
||||||
|
# Agent connection dialing timeout value in seconds
|
||||||
|
# (default: 30)
|
||||||
|
#dial_timeout = 30
|
||||||
|
|
||||||
[netmon]
|
[netmon]
|
||||||
# If enabled, the network monitoring process gets started when the
|
# If enabled, the network monitoring process gets started when the
|
||||||
# sandbox is created. This allows for the detection of some additional
|
# sandbox is created. This allows for the detection of some additional
|
||||||
|
@ -165,6 +165,10 @@ block_device_driver = "virtio-blk"
|
|||||||
|
|
||||||
#debug_console_enabled = true
|
#debug_console_enabled = true
|
||||||
|
|
||||||
|
# Agent connection dialing timeout value in seconds
|
||||||
|
# (default: 30)
|
||||||
|
#dial_timeout = 30
|
||||||
|
|
||||||
[netmon]
|
[netmon]
|
||||||
# If enabled, the network monitoring process gets started when the
|
# If enabled, the network monitoring process gets started when the
|
||||||
# sandbox is created. This allows for the detection of some additional
|
# sandbox is created. This allows for the detection of some additional
|
||||||
|
@ -287,6 +287,10 @@ kernel_modules=[]
|
|||||||
|
|
||||||
#debug_console_enabled = true
|
#debug_console_enabled = true
|
||||||
|
|
||||||
|
# Agent connection dialing timeout value in seconds
|
||||||
|
# (default: 30)
|
||||||
|
#dial_timeout = 30
|
||||||
|
|
||||||
[netmon]
|
[netmon]
|
||||||
# If enabled, the network monitoring process gets started when the
|
# If enabled, the network monitoring process gets started when the
|
||||||
# sandbox is created. This allows for the detection of some additional
|
# sandbox is created. This allows for the detection of some additional
|
||||||
|
@ -437,6 +437,10 @@ kernel_modules=[]
|
|||||||
|
|
||||||
#debug_console_enabled = true
|
#debug_console_enabled = true
|
||||||
|
|
||||||
|
# Agent connection dialing timeout value in seconds
|
||||||
|
# (default: 30)
|
||||||
|
#dial_timeout = 30
|
||||||
|
|
||||||
[netmon]
|
[netmon]
|
||||||
# If enabled, the network monitoring process gets started when the
|
# If enabled, the network monitoring process gets started when the
|
||||||
# sandbox is created. This allows for the detection of some additional
|
# sandbox is created. This allows for the detection of some additional
|
||||||
|
@ -154,6 +154,7 @@ type agent struct {
|
|||||||
Debug bool `toml:"enable_debug"`
|
Debug bool `toml:"enable_debug"`
|
||||||
Tracing bool `toml:"enable_tracing"`
|
Tracing bool `toml:"enable_tracing"`
|
||||||
DebugConsoleEnabled bool `toml:"debug_console_enabled"`
|
DebugConsoleEnabled bool `toml:"debug_console_enabled"`
|
||||||
|
DialTimeout uint32 `toml:"dial_timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type netmon struct {
|
type netmon struct {
|
||||||
@ -471,6 +472,10 @@ func (a agent) debugConsoleEnabled() bool {
|
|||||||
return a.DebugConsoleEnabled
|
return a.DebugConsoleEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a agent) dialTimout() uint32 {
|
||||||
|
return a.DialTimeout
|
||||||
|
}
|
||||||
|
|
||||||
func (a agent) debug() bool {
|
func (a agent) debug() bool {
|
||||||
return a.Debug
|
return a.Debug
|
||||||
}
|
}
|
||||||
@ -920,6 +925,7 @@ func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oc
|
|||||||
TraceType: agent.traceType(),
|
TraceType: agent.traceType(),
|
||||||
KernelModules: agent.kernelModules(),
|
KernelModules: agent.kernelModules(),
|
||||||
EnableDebugConsole: agent.debugConsoleEnabled(),
|
EnableDebugConsole: agent.debugConsoleEnabled(),
|
||||||
|
DialTimeout: agent.dialTimout(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +217,7 @@ type KataAgentConfig struct {
|
|||||||
ContainerPipeSize uint32
|
ContainerPipeSize uint32
|
||||||
TraceMode string
|
TraceMode string
|
||||||
TraceType string
|
TraceType string
|
||||||
|
DialTimeout uint32
|
||||||
KernelModules []string
|
KernelModules []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +237,7 @@ type kataAgent struct {
|
|||||||
keepConn bool
|
keepConn bool
|
||||||
dynamicTracing bool
|
dynamicTracing bool
|
||||||
dead bool
|
dead bool
|
||||||
|
dialTimout uint32
|
||||||
kmodules []string
|
kmodules []string
|
||||||
|
|
||||||
vmSocket interface{}
|
vmSocket interface{}
|
||||||
@ -344,6 +346,7 @@ func (k *kataAgent) init(ctx context.Context, sandbox *Sandbox, config KataAgent
|
|||||||
disableVMShutdown = k.handleTraceSettings(config)
|
disableVMShutdown = k.handleTraceSettings(config)
|
||||||
k.keepConn = config.LongLiveConn
|
k.keepConn = config.LongLiveConn
|
||||||
k.kmodules = config.KernelModules
|
k.kmodules = config.KernelModules
|
||||||
|
k.dialTimout = config.DialTimeout
|
||||||
|
|
||||||
return disableVMShutdown, nil
|
return disableVMShutdown, nil
|
||||||
}
|
}
|
||||||
@ -1794,7 +1797,7 @@ func (k *kataAgent) connect(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
k.Logger().WithField("url", k.state.URL).Info("New client")
|
k.Logger().WithField("url", k.state.URL).Info("New client")
|
||||||
client, err := kataclient.NewAgentClient(k.ctx, k.state.URL)
|
client, err := kataclient.NewAgentClient(k.ctx, k.state.URL, k.dialTimout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.dead = true
|
k.dead = true
|
||||||
return err
|
return err
|
||||||
|
@ -62,15 +62,21 @@ type dialer func(string, time.Duration) (net.Conn, error)
|
|||||||
// model, and mediates communication between AF_UNIX sockets (on the host end)
|
// model, and mediates communication between AF_UNIX sockets (on the host end)
|
||||||
// and AF_VSOCK sockets (on the guest end).
|
// and AF_VSOCK sockets (on the guest end).
|
||||||
// - mock://<path>. just for test use.
|
// - mock://<path>. just for test use.
|
||||||
func NewAgentClient(ctx context.Context, sock string) (*AgentClient, error) {
|
func NewAgentClient(ctx context.Context, sock string, timeout uint32) (*AgentClient, error) {
|
||||||
grpcAddr, parsedAddr, err := parse(sock)
|
grpcAddr, parsedAddr, err := parse(sock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialTimeout := defaultDialTimeout
|
||||||
|
if timeout > 0 {
|
||||||
|
dialTimeout = time.Duration(timeout) * time.Second
|
||||||
|
agentClientLog.WithField("timeout", timeout).Debug("custom dialing timeout has been set")
|
||||||
|
}
|
||||||
|
|
||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
var d = agentDialer(parsedAddr)
|
var d = agentDialer(parsedAddr)
|
||||||
conn, err = d(grpcAddr, defaultDialTimeout)
|
conn, err = d(grpcAddr, dialTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -92,7 +98,7 @@ func NewAgentClient(ctx context.Context, sock string) (*AgentClient, error) {
|
|||||||
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(tracer)))
|
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(tracer)))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, defaultDialTimeout)
|
ctx, cancel := context.WithTimeout(ctx, dialTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
conn, err := grpc.DialContext(ctx, grpcAddr, dialOpts...)
|
conn, err := grpc.DialContext(ctx, grpcAddr, dialOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user