chore: dialer improvements (#1232)

* Relaxed test condition.
* Independence of `socat` image entrypoint.
* The `socat` image is configurable via environment variable.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek 2022-09-12 21:26:46 +02:00 committed by GitHub
parent 1f5a95a4a7
commit 427d453f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"os"
"sync" "sync"
"time" "time"
@ -130,6 +131,11 @@ func (c *contextDialer) startDialerPod(ctx context.Context) (err error) {
} }
}() }()
img := socatImage
if i, ok := os.LookupEnv("SOCAT_IMAGE"); ok {
img = i
}
runAsNonRoot := true runAsNonRoot := true
pod := &coreV1.Pod{ pod := &coreV1.Pod{
ObjectMeta: metaV1.ObjectMeta{ ObjectMeta: metaV1.ObjectMeta{
@ -141,10 +147,10 @@ func (c *contextDialer) startDialerPod(ctx context.Context) (err error) {
Containers: []coreV1.Container{ Containers: []coreV1.Container{
{ {
Name: c.podName, Name: c.podName,
Image: socatImage, Image: img,
Stdin: true, Stdin: true,
StdinOnce: true, StdinOnce: true,
Args: []string{"-u", "-", "OPEN:/dev/null,append"}, Command: []string{"socat", "-u", "-", "OPEN:/dev/null"},
SecurityContext: &coreV1.SecurityContext{ SecurityContext: &coreV1.SecurityContext{
Privileged: new(bool), Privileged: new(bool),
AllowPrivilegeEscalation: new(bool), AllowPrivilegeEscalation: new(bool),

View File

@ -181,7 +181,7 @@ func TestDialUnreachable(t *testing.T) {
t.Error("error was expected but got nil") t.Error("error was expected but got nil")
return return
} }
if !strings.Contains(err.Error(), "Name does not resolve") { if !strings.Contains(err.Error(), "not resolve") {
t.Errorf("error %q doesn't containe expected sub-string: ", err.Error()) t.Errorf("error %q doesn't containe expected sub-string: ", err.Error())
} }
} }