Skip to content

Agent channel service

This channel plugin manages communications with execution environments that are accessed via agents.

It exposes user-facing endpoints that are used by agents.

There are two service-specific configuration file options.

Environment variables

Logging

You can set the AGENTCHANNEL_DEBUG_LEVEL (all upper-cased) or DEBUG_LEVEL environment variables to DEBUG to add additional information in the console for the launched service. It defaults to INFO. (Please note that setting DEBUG_LEVEL to DEBUG will produce tons of logs.)

The possible values are NOTSET, DEBUG, INFO, WARNING, ERROR, and FATAL. Those values are from the most verbose, NOTSET, which shows all logs, to the least verbose, FATAL, which only shows fatal errors.

If AGENTCHANNEL_DEBUG_LEVEL is not defined then the value of DEBUG_LEVEL is used (or INFO if DEBUG_LEVEL is not defined either).

Access logs are only shown at NOTSET and DEBUG levels.

Hooks specification

The AGENTCHANNEL_CHANNEL_HOOKS environment variable, if defined, must refer to an existing file that contains hook definitions.

For more information about hooks, see “Hooks for jobs and providers.”

Tip

If the content of this referred file changes, the hooks definitions used by the channel handler will change accordingly. You do not need to restart the provider plugin.

Configuration options

You can also set the five configuration options using environment variables:

  • AGENTCHANNEL_AVAILABILITY_CHECK_DELAY_SECONDS sets the channel availability polling interval (defaults to 10 seconds).
  • AGENTCHANNEL_UNREACHABLE_DEREGISTRATION_TIMEOUT_MINUTES sets the delay before deregistering an unreachable agent (defaults to 60 minutes, set to 0 to disable timeout).
  • AGENTCHANNEL_LIVENESS_LIMIT_SECONDS sets the delay before considering an agent as unreachable (defaults to 300 seconds).
  • AGENTCHANNEL_WAITRESS_THREADS_COUNT sets the number of threads used by the waitress server (defaults to 10).
  • AGENTCHANNEL_WATCHDOG_POLLING_DELAY_SECONDS sets how often to check if hooks definition has changed (defaults to 30 seconds).

Telemetry

  • OPENTF_TELEMETRY enables telemetry if set to yes, 1, true, or on. For more information, see “Using Telemetry.”

Configuration file

This plugin has a configuration file (agentchannel.yaml by default) that describes the host, port, ssl_context, and trusted_authorities to use. In this file, it is possible to enable insecure logins or set availability_check_delay to define the channel availability polling interval (defaults to 10 seconds).

If no configuration file is found it will default to the following values:

apiVersion: opentestfactory.org/v1beta2
kind: ServiceConfig
current-context: default
contexts:
- context:
    port: 443
    host: 127.0.0.1
    ssl_context: adhoc
    eventbus:
      endpoint: https://127.0.0.1:38368
      token: invalid
    availability_check_delay_seconds: 10
    unreachable_deregistration_timeout_minutes: 60
    liveness_limit_seconds: 300
    watchdog_polling_delay_seconds: 30
    waitress_threads_count: 10
  name: default

The configuration included in the ‘allinone’ image is described in “Common settings.” The listening port is 24368 and the bind address is 0.0.0.0 as the service exposes user-facing endpoints.

Five service-specific configuration options can be refined.

availability_check_delay_seconds

The availability_check_delay_seconds option sets the channel availability polling interval. It defaults to 10 seconds.

unreachable_deregistration_timeout_minutes

The unreachable_deregistration_timeout_minutes option sets the delay before deregistering an unreachable agent. It defaults to 60 minutes.

Setting it to 0 disables the timeout.

liveness_limit_seconds

The liveness_limit_seconds option sets the delay before considering an agent as unreachable. It defaults to 300 seconds.

This value is used to set an agent liveness limit if it does not provide one at registration time.

watchdog_polling_delay_seconds

The watchdog_polling_delay_seconds option sets how often to check if the hooks definition has changed. It defaults to 30 seconds.

waitress_threads_count

The waitress_threads_count option sets the number of threads used by the waitress server. It defaults to 10.

Subscriptions

The agent channel plugin subscribes to the following events:

kind apiVersion
ExecutionCommand opentestfactory.org/v1beta1

The agent channel plugin exposes an /inbox endpoint that is used by the event bus to post relevant events.

Launch command

If you want to manually start the agent channel plugin, use the following command:

python -m opentf.plugins.agentchannel.main [--context context] [--config configfile]

Additional command-line options are available and described in “Command-line options.”