Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions completions/bash/crio
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ h
--storage-opt
--stream-address
--stream-enable-tls
--stream-idle-timeout
--stream-port
--stream-tls-ca
--stream-tls-cert
Expand Down
1 change: 1 addition & 0 deletions completions/fish/crio.fish
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ complete -c crio -n '__fish_crio_no_subcommand' -f -l storage-driver -s s -r -d
complete -c crio -n '__fish_crio_no_subcommand' -f -l storage-opt -r -d 'OCI storage driver option'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stream-address -r -d 'Bind address for streaming socket'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stream-enable-tls -d 'Enable encrypted TLS transport of the stream server (default: false)'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stream-idle-timeout -r -d 'Length of time until open streams terminate due to lack of activity'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stream-port -r -d 'Bind port for streaming socket. If the port is set to \'0\', then CRI-O will allocate a random free port number.'
complete -c crio -n '__fish_crio_no_subcommand' -l stream-tls-ca -r -d 'Path to the x509 CA(s) file used to verify and authenticate client communication with the encrypted stream. This file can change and CRI-O will automatically pick up the changes within 5 minutes (default: "")'
complete -c crio -n '__fish_crio_no_subcommand' -l stream-tls-cert -r -d 'Path to the x509 certificate file used to serve the encrypted stream. This file can change and CRI-O will automatically pick up the changes within 5 minutes (default: "")'
Expand Down
2 changes: 1 addition & 1 deletion completions/zsh/_crio
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it later with **--config**. Global options will modify the output.' 'version:dis
_describe 'commands' cmds

local -a opts
opts=('--additional-devices' '--apparmor-profile' '--big-files-temporary-dir' '--bind-mount-prefix' '--cgroup-manager' '--cni-config-dir' '--cni-default-network' '--cni-plugin-dir' '--config' '--config-dir' '--conmon' '--conmon-cgroup' '--conmon-env' '--container-attach-socket-dir' '--container-exits-dir' '--ctr-stop-timeout' '--decryption-keys-path' '--default-capabilities' '--default-env' '--default-mounts-file' '--default-runtime' '--default-sysctls' '--default-transport' '--default-ulimits' '--drop-infra-ctr' '--enable-metrics' '--enable-profile-unix-socket' '--gid-mappings' '--global-auth-file' '--grpc-max-recv-msg-size' '--grpc-max-send-msg-size' '--hooks-dir' '--image-volumes' '--infra-ctr-cpuset' '--insecure-registry' '--irqbalance-config-file' '--listen' '--log' '--log-dir' '--log-filter' '--log-format' '--log-journald' '--log-level' '--log-size-max' '--metrics-port' '--metrics-socket' '--namespaces-dir' '--no-pivot' '--pause-command' '--pause-image' '--pause-image-auth-file' '--pids-limit' '--pinns-path' '--profile' '--profile-port' '--read-only' '--registries-conf' '--registry' '--root' '--runroot' '--runtimes' '--seccomp-profile' '--seccomp-use-default-when-empty' '--selinux' '--separate-pull-cgroup' '--signature-policy' '--storage-driver' '--storage-opt' '--stream-address' '--stream-enable-tls' '--stream-port' '--stream-tls-ca' '--stream-tls-cert' '--stream-tls-key' '--uid-mappings' '--version-file' '--version-file-persist' '--help' '--version')
opts=('--additional-devices' '--apparmor-profile' '--big-files-temporary-dir' '--bind-mount-prefix' '--cgroup-manager' '--cni-config-dir' '--cni-default-network' '--cni-plugin-dir' '--config' '--config-dir' '--conmon' '--conmon-cgroup' '--conmon-env' '--container-attach-socket-dir' '--container-exits-dir' '--ctr-stop-timeout' '--decryption-keys-path' '--default-capabilities' '--default-env' '--default-mounts-file' '--default-runtime' '--default-sysctls' '--default-transport' '--default-ulimits' '--drop-infra-ctr' '--enable-metrics' '--enable-profile-unix-socket' '--gid-mappings' '--global-auth-file' '--grpc-max-recv-msg-size' '--grpc-max-send-msg-size' '--hooks-dir' '--image-volumes' '--infra-ctr-cpuset' '--insecure-registry' '--irqbalance-config-file' '--listen' '--log' '--log-dir' '--log-filter' '--log-format' '--log-journald' '--log-level' '--log-size-max' '--metrics-port' '--metrics-socket' '--namespaces-dir' '--no-pivot' '--pause-command' '--pause-image' '--pause-image-auth-file' '--pids-limit' '--pinns-path' '--profile' '--profile-port' '--read-only' '--registries-conf' '--registry' '--root' '--runroot' '--runtimes' '--seccomp-profile' '--seccomp-use-default-when-empty' '--selinux' '--separate-pull-cgroup' '--signature-policy' '--storage-driver' '--storage-opt' '--stream-address' '--stream-enable-tls' '--stream-idle-timeout' '--stream-port' '--stream-tls-ca' '--stream-tls-cert' '--stream-tls-key' '--uid-mappings' '--version-file' '--version-file-persist' '--help' '--version')
_describe 'global options' opts

return
Expand Down
3 changes: 3 additions & 0 deletions docs/crio.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ crio
[--storage-opt]=[value]
[--stream-address]=[value]
[--stream-enable-tls]
[--stream-idle-timeout]=[value]
[--stream-port]=[value]
[--stream-tls-ca]=[value]
[--stream-tls-cert]=[value]
Expand Down Expand Up @@ -296,6 +297,8 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]

**--stream-enable-tls**: Enable encrypted TLS transport of the stream server (default: false)

**--stream-idle-timeout**="": Length of time until open streams terminate due to lack of activity

**--stream-port**="": Bind port for streaming socket. If the port is set to '0', then CRI-O will allocate a random free port number. (default: 0)

**--stream-tls-ca**="": Path to the x509 CA(s) file used to verify and authenticate client communication with the encrypted stream. This file can change and CRI-O will automatically pick up the changes within 5 minutes (default: "")
Expand Down
3 changes: 3 additions & 0 deletions docs/crio.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ The `crio.api` table contains settings for the kubelet/gRPC interface.
**stream_enable_tls**=false
Enable encrypted TLS transport of the stream server.

**stream_idle_timeout**=""
Length of time until open streams terminate due to lack of activity.

**stream_tls_cert**=""
Path to the x509 certificate file used to serve the encrypted stream. This file can change and CRI-O will automatically pick up the changes within 5 minutes.

Expand Down
8 changes: 8 additions & 0 deletions internal/criocli/criocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ func mergeConfig(config *libconfig.Config, ctx *cli.Context) error {
if ctx.IsSet("stream-tls-key") {
config.StreamTLSKey = ctx.String("stream-tls-key")
}
if ctx.IsSet("stream-idle-timeout") {
config.StreamIdleTimeout = ctx.String("stream-idle-timeout")
}
if ctx.IsSet("version-file") {
config.VersionFile = ctx.String("version-file")
}
Expand Down Expand Up @@ -789,6 +792,11 @@ func getCrioFlags(defConf *libconfig.Config) []cli.Flag {
EnvVars: []string{"CONTAINER_TLS_KEY"},
TakesFile: true,
},
&cli.StringFlag{
Name: "stream-idle-timeout",
Usage: "Length of time until open streams terminate due to lack of activity",
EnvVars: []string{"STREAM_IDLE_TIMEOUT"},
},
&cli.StringFlag{
Name: "registries-conf",
Usage: "path to the registries.conf file",
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ type APIConfig struct {
// StreamTLSCA is the x509 CA(s) file used to verify and authenticate client
// communication with the tls encrypted stream
StreamTLSCA string `toml:"stream_tls_ca"`

// StreamIdleTimeout is how long to leave idle connections open for
StreamIdleTimeout string `toml:"stream_idle_timeout"`
}

// MetricsConfig specifies all necessary configuration for Prometheus based
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ stream_port = "{{ .StreamPort }}"
# Enable encrypted TLS transport of the stream server.
stream_enable_tls = {{ .StreamEnableTLS }}

# Length of time until open streams terminate due to lack of activity
stream_idle_timeout = "{{.StreamIdleTimeout}}"

# Path to the x509 certificate file used to serve the encrypted stream. This
# file can change, and CRI-O will automatically pick up the changes within 5
# minutes.
Expand Down
8 changes: 8 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ func New(

// Prepare streaming server
streamServerConfig := streaming.DefaultConfig
if config.StreamIdleTimeout != "" {
idleTimeout, err := time.ParseDuration(config.StreamIdleTimeout)
if err != nil {
return nil, errors.New("unable to parse timeout as duration")
}

streamServerConfig.StreamIdleTimeout = idleTimeout
}
streamServerConfig.Addr = net.JoinHostPort(bindAddressStr, config.StreamPort)
if config.StreamEnableTLS {
certCache := &certConfigCache{
Expand Down
16 changes: 16 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@ var _ = t.Describe("Server", func() {
Expect(err).NotTo(BeNil())
Expect(server).To(BeNil())
})
It("should fail with invalid timeout duration", func() {
mockNewServer()
serverConfig.StreamIdleTimeout = "invalid duration"

server, err := server.New(context.Background(), libMock)
Expect(err).NotTo(BeNil())
Expect(server).To(BeNil())
})
It("should succeed to set a valid timeout duration", func() {
mockNewServer()
serverConfig.StreamIdleTimeout = "200ms"

server, err := server.New(context.Background(), libMock)
Expect(err).To(BeNil())
Expect(server).ToNot(BeNil())
})
})

t.Describe("CreateMetricsEndpoint", func() {
Expand Down
2 changes: 1 addition & 1 deletion server/streaming/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type Config struct {
// DefaultConfig provides default values for server Config. The DefaultConfig is partial, so
// some fields like Addr must still be provided.
var DefaultConfig = Config{
StreamIdleTimeout: 4 * time.Hour,
StreamIdleTimeout: 15 * time.Minute,
StreamCreationTimeout: remotecommandconsts.DefaultStreamCreationTimeout,
SupportedRemoteCommandProtocols: remotecommandconsts.SupportedStreamingProtocols,
SupportedPortForwardProtocols: portforward.SupportedProtocols,
Expand Down