Skip to content

Commit edaa926

Browse files
committed
Map cluster-wide proxy env variable for compatibility with Vector expectations
Signed-off-by: Vitalii Parfonov <[email protected]>
1 parent 48896de commit edaa926

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

internal/collector/vector/run_script.go

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ VECTOR_DATA_DIR=%s
1111
echo "Creating the directory used for persisting Vector state $VECTOR_DATA_DIR"
1212
mkdir -p ${VECTOR_DATA_DIR}
1313
14+
# Remap lowercase to uppercase if it's set
15+
if [ -z "${HTTP_PROXY:-}" ] && [ -n "${http_proxy:-}" ]; then
16+
export HTTP_PROXY="$http_proxy"
17+
echo HTTP_PROXY="$HTTP_PROXY"
18+
fi
19+
if [ -z "${HTTPS_PROXY:-}" ] && [ -n "${https_proxy:-}" ]; then
20+
export HTTPS_PROXY="$https_proxy"
21+
echo HTTPS_PROXY="$HTTPS_PROXY"
22+
fi
23+
if [ -z "${NO_PROXY:-}" ] && [ -n "${no_proxy:-}" ]; then
24+
export NO_PROXY="$no_proxy"
25+
echo NO_PROXY="$NO_PROXY"
26+
fi
27+
28+
29+
1430
echo "Checking for buffer lock files"
1531
# Vector does not appear to release locks when the process terminates. Try to clean up for restart
1632
pushd ${VECTOR_DATA_DIR}

test/functional/misc/vector_api_cli_test.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
//go:build !fluentd
2-
31
package misc
42

53
import (
64
. "github.com/onsi/ginkgo"
75
. "github.com/onsi/gomega"
86
logging "github.com/openshift/cluster-logging-operator/api/logging/v1"
97
"github.com/openshift/cluster-logging-operator/internal/constants"
8+
"github.com/openshift/cluster-logging-operator/internal/runtime"
109
"github.com/openshift/cluster-logging-operator/test/framework/functional"
1110
testfw "github.com/openshift/cluster-logging-operator/test/functional"
1211
)
@@ -36,5 +35,19 @@ var _ = Describe("[Functional][Misc][API_CLI] Functional test", func() {
3635
out, _ := framework.RunCommand(constants.CollectorName, `curl`, `-sv`, `-m`, `5`, `--connect-timeout`, `3`, `http://127.0.0.1:8686/health`)
3736
Expect(out).To(ContainSubstring(`{"ok":true}`))
3837
})
38+
It("should remap Proxy env variable from lowercase to uppercase if it's set", func() {
39+
envVisitor := func(b *runtime.PodBuilder) error {
40+
b.GetContainer(constants.CollectorName).AddEnvVar("http_proxy", "http://my_proxy:8080")
41+
b.GetContainer(constants.CollectorName).AddEnvVar("https_proxy", "https://my_proxy:9090")
42+
b.GetContainer(constants.CollectorName).AddEnvVar("no_proxy", "my-host,your-host")
43+
return nil
44+
}
45+
Expect(framework.DeployWithVisitor(envVisitor)).To(BeNil())
46+
out, err := framework.ReadCollectorLogs()
47+
Expect(err).To(BeNil())
48+
Expect(out).To(ContainSubstring(`HTTP_PROXY=http://my_proxy:8080`))
49+
Expect(out).To(ContainSubstring(`HTTPS_PROXY=https://my_proxy:9090`))
50+
Expect(out).To(ContainSubstring(`NO_PROXY=my-host,your-host`))
51+
})
3952
})
4053
})

0 commit comments

Comments
 (0)