Skip to content

Commit 4b219f9

Browse files
committed
Try adding support for generic proxy to domain proxy.
1 parent 692bcbc commit 4b219f9

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

deploy/tasks/buildah-oci-ta.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,17 @@ spec:
146146
- name: PROXY_TARGET_WHITELIST
147147
description: Comma separated whitelist of target hosts for the domain proxy.
148148
type: string
149-
- name: CACHE_URL
150-
description: Cache URL.
149+
- name: INTERNAL_PROXY_ADDRESS
150+
description: Host and port of proxy used internally by the domain proxy.
151+
type: string
152+
- name: INTERNAL_PROXY_USER
153+
description: User of proxy used internally by the domain proxy.
154+
type: string
155+
- name: INTERNAL_PROXY_PASSWORD
156+
description: Password of proxy used internally by the domain proxy.
157+
type: string
158+
- name: INTERNAL_NON_PROXY_HOSTS
159+
description: Comma separated list of target hosts that bypass the proxy used internally by the domain proxy.
151160
type: string
152161
results:
153162
- name: IMAGE_DIGEST
@@ -240,8 +249,14 @@ spec:
240249
value: $(params.BYTE_BUFFER_SIZE)
241250
- name: PROXY_TARGET_WHITELIST
242251
value: $(params.PROXY_TARGET_WHITELIST)
243-
- name: CACHE_URL
244-
value: $(params.CACHE_URL)
252+
- name: INTERNAL_PROXY_ADDRESS
253+
value: $(params.INTERNAL_PROXY_ADDRESS)
254+
- name: INTERNAL_PROXY_USER
255+
value: $(params.INTERNAL_PROXY_USER)
256+
- name: INTERNAL_PROXY_PASSWORD
257+
value: $(params.INTERNAL_PROXY_PASSWORD)
258+
- name: INTERNAL_NON_PROXY_HOSTS
259+
value: $(params.INTERNAL_NON_PROXY_HOSTS)
245260
volumeMounts:
246261
- mountPath: /shared
247262
name: shared
@@ -398,7 +413,6 @@ spec:
398413
echo ${DOMAIN_PROXY_ARGS[@]} # TODO remove
399414
/app/domain-proxy-server-runner &
400415
server_pid=$!
401-
curl -v "${CACHE_URL}/org/apache/maven/plugins/maven-jar-plugin/3.4.1/maven-jar-plugin-3.4.1.jar"
402416
fi
403417
fi
404418

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ public void run() {
8989
9090
export http_proxy=http://localhost:8080
9191
export https_proxy=${http_proxy}
92-
export HTTP_PROXY=${http_proxy}
93-
export HTTPS_PROXY=${http_proxy}
9492
#fix this when we no longer need to run as root
9593
export HOME=${HOME:=/root}
9694
# Custom base working directory.
@@ -108,7 +106,6 @@ public void run() {
108106
# useful if Gradle/Ant also requires Maven configured.
109107
export MAVEN_HOME=${MAVEN_HOME:=/opt/maven/3.8.8}
110108
export GRADLE_USER_HOME="${JBS_WORKDIR}/software/settings/.gradle"
111-
curl -v "${PROXY_URL}/org/apache/maven/plugins/maven-jar-plugin/3.4.1/maven-jar-plugin-3.4.1.jar"
112109
113110
mkdir -p ${JBS_WORKDIR}/logs ${JBS_WORKDIR}/packages ${JBS_WORKDIR}/settings ${HOME}/.sbt/1.0 ${GRADLE_USER_HOME} ${HOME}/.m2
114111
cd ${JBS_WORKDIR}/source
@@ -183,8 +180,6 @@ private String getContainerFile() {
183180
ENV PROXY_URL=$PROXY_URL
184181
ENV http_proxy=http://localhost:8080
185182
ENV https_proxy=${http_proxy}
186-
ENV HTTP_PROXY=${http_proxy}
187-
ENV HTTPS_PROXY=${http_proxy}
188183
COPY .jbs/run-build.sh /var/workdir
189184
COPY . /var/workdir/workspace/source/
190185
RUN /var/workdir/run-build.sh
@@ -412,9 +407,7 @@ private String getAntSetup() {
412407
<property name="local-pattern" value="\\${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"/>
413408
<settings defaultResolver="defaultChain"/>
414409
<resolvers>
415-
<ibiblio name="default" root="\\${cache-url}" pattern="\\${default-pattern}" m2compatible="true">
416-
<proxy host="localhost" port="8080" />
417-
</ibiblio>
410+
<ibiblio name="default" root="\\${cache-url}" pattern="\\${default-pattern}" m2compatible="true"/>
418411
<filesystem name="local" m2compatible="true">
419412
<artifact pattern="\\${local-pattern}"/>
420413
<ivy pattern="\\${local-pattern}"/>

java-components/domain-proxy/server/src/main/java/com/redhat/hacbs/domainproxy/ExternalProxyVerticle.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public class ExternalProxyVerticle extends AbstractVerticle {
3535
@ConfigProperty(name = "proxy-target-whitelist")
3636
Set<String> proxyTargetWhitelist;
3737

38+
@Inject
39+
@ConfigProperty(name = "quarkus.rest-client.non-proxy-hosts")
40+
Set<String> nonProxyHosts;
41+
3842
private final WebClient webClient;
3943
private final NetClient netClient;
4044
private final HttpServer httpServer;
@@ -125,8 +129,8 @@ private void handleConnectRequest(final HttpServerRequest request) {
125129

126130
private boolean isTargetWhitelisted(final String targetHost, final HttpServerRequest request) {
127131
Log.infof("Target %s", targetHost);
128-
if (!proxyTargetWhitelist.contains(targetHost)) {
129-
Log.error("Target is not in whitelist");
132+
if (!proxyTargetWhitelist.contains(targetHost) && !nonProxyHosts.contains(targetHost)) {
133+
Log.error("Target is not whitelisted or a non-proxy host");
130134
request.response()
131135
.setStatusCode(HttpResponseStatus.NOT_FOUND.code())
132136
.setStatusMessage(HttpResponseStatus.NOT_FOUND.reasonPhrase())

java-components/domain-proxy/server/src/main/resources/application.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ server-domain-socket=${DOMAIN_SOCKET:/tmp/domain-server}
22
server-http-port=2000
33
byte-buffer-size=${BYTE_BUFFER_SIZE:1024}
44
proxy-target-whitelist=${PROXY_TARGET_WHITELIST:repo.maven.apache.org,repository.jboss.org,packages.confluent.io,jitpack.io,repo.gradle.org,plugins.gradle.org}
5+
quarkus.rest-client.proxy-address=${INTERNAL_PROXY_ADDRESS:indy-generic-proxy:80}
6+
quarkus.rest-client.proxy-user=${INTERNAL_PROXY_USER}
7+
quarkus.rest-client.proxy-password=${INTERNAL_PROXY_PASSWORD}
8+
quarkus.rest-client.non-proxy-hosts=${INTERNAL_NON_PROXY_HOSTS:localhost}
59
quarkus.log.level=DEBUG

pkg/reconciler/dependencybuild/buildrecipeyaml.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,35 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
556556
Name: "PROXY_TARGET_WHITELIST",
557557
Value: tektonpipeline.ParamValue{
558558
Type: tektonpipeline.ParamTypeString,
559-
StringVal: whitelistUrl.Host + ",cdn-ubi.redhat.com",
559+
StringVal: "cdn-ubi.redhat.com",
560560
},
561561
},
562562
{
563-
Name: "CACHE_URL",
563+
Name: "INTERNAL_PROXY_ADDRESS",
564564
Value: tektonpipeline.ParamValue{
565565
Type: tektonpipeline.ParamTypeString,
566-
StringVal: cacheUrl,
566+
StringVal: "indy-generic-proxy:80",
567+
},
568+
},
569+
{
570+
Name: "INTERNAL_PROXY_USER",
571+
Value: tektonpipeline.ParamValue{
572+
Type: tektonpipeline.ParamTypeString,
573+
StringVal: "${BUILD_ID}+tracking",
574+
},
575+
},
576+
{
577+
Name: "INTERNAL_PROXY_PASSWORD",
578+
Value: tektonpipeline.ParamValue{
579+
Type: tektonpipeline.ParamTypeString,
580+
StringVal: "${ACCESS_TOKEN}",
581+
},
582+
},
583+
{
584+
Name: "INTERNAL_NON_PROXY_HOSTS",
585+
Value: tektonpipeline.ParamValue{
586+
Type: tektonpipeline.ParamTypeString,
587+
StringVal: whitelistUrl.Host + ",localhost",
567588
},
568589
},
569590
},

0 commit comments

Comments
 (0)