diff --git a/bindata/assets/deployments/downloads-deployment.yaml b/bindata/assets/deployments/downloads-deployment.yaml index 66a289da20..ef107f7f30 100644 --- a/bindata/assets/deployments/downloads-deployment.yaml +++ b/bindata/assets/deployments/downloads-deployment.yaml @@ -45,6 +45,7 @@ spec: periodSeconds: 10 successThreshold: 1 failureThreshold: 3 + initialDelaySeconds: 5 name: download-server securityContext: readOnlyRootFilesystem: false @@ -63,6 +64,7 @@ spec: periodSeconds: 10 successThreshold: 1 failureThreshold: 3 + initialDelaySeconds: 5 ports: - name: http containerPort: 8080 @@ -78,6 +80,8 @@ spec: signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) + ready = threading.Event() + def write_index(path, message): with open(path, 'wb') as f: f.write('\n'.join([ @@ -112,7 +116,8 @@ spec: # https://stackoverflow.com/questions/46210672/ httpd.socket = self.socket httpd.server_bind = self.server_close = lambda self: None - + if self.i == 0: + ready.set() httpd.serve_forever() temp_dir = tempfile.mkdtemp() @@ -125,19 +130,26 @@ spec: for arch, operating_system, path in [ ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc'), + ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel8'), + ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel9'), ('amd64', 'mac', '/usr/share/openshift/mac/oc'), ('amd64', 'windows', '/usr/share/openshift/windows/oc.exe'), ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc'), + ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel8'), + ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel9'), ('arm64', 'mac', '/usr/share/openshift/mac_arm64/oc'), ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc'), + ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel8'), + ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel9'), ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc'), + ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel8'), + ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel9'), ]: basename = os.path.basename(path) target_path = os.path.join(arch, operating_system, basename) - os.mkdir(os.path.join(arch, operating_system)) + os.makedirs(os.path.join(arch, operating_system), exist_ok=True) os.symlink(path, target_path) - base_root, _ = os.path.splitext(basename) - archive_path_root = os.path.join(arch, operating_system, base_root) + archive_path_root = os.path.join(arch, operating_system, basename) with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar: tar.add(path, basename) with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip: @@ -179,12 +191,32 @@ spec: addr = ('', 8080) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) else: - raise + raise sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(addr) sock.listen(5) - [Thread(i, socket=sock) for i in range(100)] + # Start server threads - using 10 threads to handle a good number of concurrent + # downloads while maintaining reasonable resource usage + threads = [Thread(i, socket=sock) for i in range(10)] + + # Wait for server to be ready + ready.wait() + + # Verify server is actually listening + for _ in range(30): # Try for 30 seconds + try: + test_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + test_sock.connect(('localhost', 8080)) + test_sock.close() + break + except socket.error: + time.sleep(1) + else: + print("Failed to verify server is listening", file=sys.stderr) + sys.exit(1) + + print("Server is ready and listening on port 8080") time.sleep(9e9) EOF exec python3 /tmp/serve.py diff --git a/pkg/console/controllers/clidownloads/controller.go b/pkg/console/controllers/clidownloads/controller.go index f38f97112d..f6a5a39bf5 100644 --- a/pkg/console/controllers/clidownloads/controller.go +++ b/pkg/console/controllers/clidownloads/controller.go @@ -184,12 +184,20 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso archType string }{ {"Linux for x86_64", "amd64/linux", "oc.tar"}, + {"Linux for x86_64 - RHEL 8", "amd64/linux", "oc.rhel8.tar"}, + {"Linux for x86_64 - RHEL 9", "amd64/linux", "oc.rhel9.tar"}, {"Mac for x86_64", "amd64/mac", "oc.zip"}, - {"Windows for x86_64", "amd64/windows", "oc.zip"}, + {"Windows for x86_64", "amd64/windows", "oc.exe.zip"}, {"Linux for ARM 64", "arm64/linux", "oc.tar"}, + {"Linux for ARM 64 - RHEL 8", "arm64/linux", "oc.rhel8.tar"}, + {"Linux for ARM 64 - RHEL 9", "arm64/linux", "oc.rhel9.tar"}, {"Mac for ARM 64", "arm64/mac", "oc.zip"}, {"Linux for IBM Power, little endian", "ppc64le/linux", "oc.tar"}, + {"Linux for IBM Power, little endian - RHEL 8", "ppc64le/linux", "oc.rhel8.tar"}, + {"Linux for IBM Power, little endian - RHEL 9", "ppc64le/linux", "oc.rhel9.tar"}, {"Linux for IBM Z", "s390x/linux", "oc.tar"}, + {"Linux for IBM Z - RHEL 8", "s390x/linux", "oc.rhel8.tar"}, + {"Linux for IBM Z - RHEL 9", "s390x/linux", "oc.rhel9.tar"}, } links := []v1.CLIDownloadLink{} @@ -212,7 +220,7 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso Spec: v1.ConsoleCLIDownloadSpec{ Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal. -The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. +The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. You can download oc using the following links. `, DisplayName: "oc - OpenShift Command Line Interface (CLI)", Links: links, diff --git a/pkg/console/controllers/clidownloads/controller_test.go b/pkg/console/controllers/clidownloads/controller_test.go index b67751aba3..f17ef8bafe 100644 --- a/pkg/console/controllers/clidownloads/controller_test.go +++ b/pkg/console/controllers/clidownloads/controller_test.go @@ -116,7 +116,7 @@ func TestPlatformBasedOCConsoleCLIDownloads(t *testing.T) { Spec: v1.ConsoleCLIDownloadSpec{ Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal. -The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. +The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. You can download oc using the following links. `, DisplayName: "oc - OpenShift Command Line Interface (CLI)", Links: []v1.CLIDownloadLink{ @@ -124,18 +124,34 @@ The oc binary offers the same capabilities as the kubectl binary, but it is furt Href: "https://www.example.com/amd64/linux/oc.tar", Text: "Download oc for Linux for x86_64", }, + { + Href: "https://www.example.com/amd64/linux/oc.rhel8.tar", + Text: "Download oc for Linux for x86_64 - RHEL 8", + }, + { + Href: "https://www.example.com/amd64/linux/oc.rhel9.tar", + Text: "Download oc for Linux for x86_64 - RHEL 9", + }, { Href: "https://www.example.com/amd64/mac/oc.zip", Text: "Download oc for Mac for x86_64", }, { - Href: "https://www.example.com/amd64/windows/oc.zip", + Href: "https://www.example.com/amd64/windows/oc.exe.zip", Text: "Download oc for Windows for x86_64", }, { Href: "https://www.example.com/arm64/linux/oc.tar", Text: "Download oc for Linux for ARM 64", }, + { + Href: "https://www.example.com/arm64/linux/oc.rhel8.tar", + Text: "Download oc for Linux for ARM 64 - RHEL 8", + }, + { + Href: "https://www.example.com/arm64/linux/oc.rhel9.tar", + Text: "Download oc for Linux for ARM 64 - RHEL 9", + }, { Href: "https://www.example.com/arm64/mac/oc.zip", Text: "Download oc for Mac for ARM 64", @@ -144,10 +160,26 @@ The oc binary offers the same capabilities as the kubectl binary, but it is furt Href: "https://www.example.com/ppc64le/linux/oc.tar", Text: "Download oc for Linux for IBM Power, little endian", }, + { + Href: "https://www.example.com/ppc64le/linux/oc.rhel8.tar", + Text: "Download oc for Linux for IBM Power, little endian - RHEL 8", + }, + { + Href: "https://www.example.com/ppc64le/linux/oc.rhel9.tar", + Text: "Download oc for Linux for IBM Power, little endian - RHEL 9", + }, { Href: "https://www.example.com/s390x/linux/oc.tar", Text: "Download oc for Linux for IBM Z", }, + { + Href: "https://www.example.com/s390x/linux/oc.rhel8.tar", + Text: "Download oc for Linux for IBM Z - RHEL 8", + }, + { + Href: "https://www.example.com/s390x/linux/oc.rhel9.tar", + Text: "Download oc for Linux for IBM Z - RHEL 9", + }, { Href: "https://www.example.com/oc-license", Text: "LICENSE", diff --git a/pkg/console/subresource/deployment/deployment_test.go b/pkg/console/subresource/deployment/deployment_test.go index 09b0b25781..62a2ef2fb0 100644 --- a/pkg/console/subresource/deployment/deployment_test.go +++ b/pkg/console/subresource/deployment/deployment_test.go @@ -1660,10 +1660,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) { Scheme: corev1.URIScheme("HTTP"), }, }, - TimeoutSeconds: 1, - PeriodSeconds: 10, - SuccessThreshold: 1, - FailureThreshold: 3, + TimeoutSeconds: 1, + PeriodSeconds: 10, + SuccessThreshold: 1, + FailureThreshold: 3, + InitialDelaySeconds: 5, }, LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ @@ -1673,10 +1674,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) { Scheme: corev1.URIScheme("HTTP"), }, }, - TimeoutSeconds: 1, - PeriodSeconds: 10, - SuccessThreshold: 1, - FailureThreshold: 3, + TimeoutSeconds: 1, + PeriodSeconds: 10, + SuccessThreshold: 1, + FailureThreshold: 3, + InitialDelaySeconds: 5, }, Command: []string{"/bin/sh"}, Resources: corev1.ResourceRequirements{ diff --git a/test/e2e/downloads_test.go b/test/e2e/downloads_test.go index 78e30d0aea..7d74676a94 100644 --- a/test/e2e/downloads_test.go +++ b/test/e2e/downloads_test.go @@ -42,6 +42,7 @@ func TestDownloadsEndpoint(t *testing.T) { req := getRequest(t, link.Href) client := getInsecureClient() resp, err := client.Do(req) + t.Logf("Requesting %s at %s\n", link.Text, link.Href) if err != nil { t.Fatalf("http error getting %s at %s: %s", link.Text, link.Href, err)