From fc87b1740e893bc0d2e620d25e194159c4a5142b Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Sun, 1 May 2022 15:01:09 +0300 Subject: [PATCH] entrypoint - add parameters for socket bind address and port entrypoint.py ------------- Allow the user to set the port number also for the remote worker Allow the user to set the binding address for the composer api or remote worker api Set the default port of the composer API to 8080 Dockerfile-ubi -------------- Remove setting the port for the composer API since the default is already 8080 --- containers/osbuild-composer/entrypoint.py | 29 +++++++++++++++++++---- distribution/Dockerfile-ubi | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/containers/osbuild-composer/entrypoint.py b/containers/osbuild-composer/entrypoint.py index 1fb2bd2e1..1cf7d8622 100644 --- a/containers/osbuild-composer/entrypoint.py +++ b/containers/osbuild-composer/entrypoint.py @@ -50,10 +50,17 @@ class Cli(contextlib.AbstractContextManager): self._parser.add_argument( "--composer-api-port", type=int, - default=443, + default=8080, dest="composer_api_port", help="Port which the composer-API listens on", ) + self._parser.add_argument( + "--composer-api-bind-address", + type=str, + default="::", + dest="composer_api_bind_address", + help="Bind the composer API to the specified address", + ) # --[no-]local-worker-api self._parser.add_argument( @@ -82,6 +89,20 @@ class Cli(contextlib.AbstractContextManager): dest="remote_worker_api", help="Disable the remote-worker-API", ) + self._parser.add_argument( + "--remote-worker-api-port", + type=int, + default=8700, + dest="remote_worker_api_port", + help="Port which the remote-worker API listens on", + ) + self._parser.add_argument( + "--remote-worker-api-bind-address", + type=str, + default="::", + dest="remote_worker_api_bind_address", + help="Bind the remote worker API to the specified address", + ) # --[no-]weldr-api self._parser.add_argument( @@ -171,7 +192,7 @@ class Cli(contextlib.AbstractContextManager): self._exitstack.enter_context(contextlib.closing(sock)) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) - sock.bind(("::", self.args.composer_api_port)) + sock.bind((self.args.composer_api_bind_address, self.args.composer_api_port)) sock.listen() sockets.append(sock) names.append("osbuild-composer-api.socket") @@ -194,12 +215,12 @@ class Cli(contextlib.AbstractContextManager): # osbuild-remote-worker.socket if self.args.remote_worker_api: - print("Create remote-worker-api socket", file=sys.stderr) + print(f"Create remote-worker-api socket on address [{self.args.remote_worker_api_bind_address}]:{self.args.remote_worker_api_port}", file=sys.stderr) sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) self._exitstack.enter_context(contextlib.closing(sock)) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) - sock.bind(("::", 8700)) + sock.bind((self.args.remote_worker_api_bind_address, self.args.remote_worker_api_port)) sock.listen(256) sockets.append(sock) names.append("osbuild-remote-worker.socket") diff --git a/distribution/Dockerfile-ubi b/distribution/Dockerfile-ubi index 98536571b..d010f5601 100644 --- a/distribution/Dockerfile-ubi +++ b/distribution/Dockerfile-ubi @@ -23,4 +23,4 @@ COPY ./internal/jobqueue/dbjobqueue/schemas /opt/migrate/schemas COPY --from=builder2 /opt/app-root/src/go/bin/tern /opt/migrate/ EXPOSE 8080 8700 -ENTRYPOINT ["python3", "/opt/entrypoint.py", "--remote-worker-api", "--composer-api", "--composer-api-port", "8080"] +ENTRYPOINT ["python3", "/opt/entrypoint.py", "--remote-worker-api", "--composer-api"]