Skip to content

Commit d89155f

Browse files
committed
CONSOLE-4523: Add rhel8 and rhel9 oc binaries for Linux OS in CLI downloads
1 parent e7945a0 commit d89155f

File tree

5 files changed

+93
-18
lines changed

5 files changed

+93
-18
lines changed

bindata/assets/deployments/downloads-deployment.yaml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ spec:
4545
periodSeconds: 10
4646
successThreshold: 1
4747
failureThreshold: 3
48+
initialDelaySeconds: 5
4849
name: download-server
4950
securityContext:
5051
readOnlyRootFilesystem: false
@@ -63,6 +64,7 @@ spec:
6364
periodSeconds: 10
6465
successThreshold: 1
6566
failureThreshold: 3
67+
initialDelaySeconds: 5
6668
ports:
6769
- name: http
6870
containerPort: 8080
@@ -78,6 +80,8 @@ spec:
7880
7981
signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0))
8082
83+
ready = threading.Event()
84+
8185
def write_index(path, message):
8286
with open(path, 'wb') as f:
8387
f.write('\n'.join([
@@ -112,7 +116,8 @@ spec:
112116
# https://stackoverflow.com/questions/46210672/
113117
httpd.socket = self.socket
114118
httpd.server_bind = self.server_close = lambda self: None
115-
119+
if self.i == 0:
120+
ready.set()
116121
httpd.serve_forever()
117122
118123
temp_dir = tempfile.mkdtemp()
@@ -125,19 +130,26 @@ spec:
125130
126131
for arch, operating_system, path in [
127132
('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc'),
133+
('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel8'),
134+
('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel9'),
128135
('amd64', 'mac', '/usr/share/openshift/mac/oc'),
129136
('amd64', 'windows', '/usr/share/openshift/windows/oc.exe'),
130137
('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc'),
138+
('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel8'),
139+
('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel9'),
131140
('arm64', 'mac', '/usr/share/openshift/mac_arm64/oc'),
132141
('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc'),
142+
('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel8'),
143+
('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel9'),
133144
('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc'),
145+
('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel8'),
146+
('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel9'),
134147
]:
135148
basename = os.path.basename(path)
136149
target_path = os.path.join(arch, operating_system, basename)
137-
os.mkdir(os.path.join(arch, operating_system))
150+
os.makedirs(os.path.join(arch, operating_system), exist_ok=True)
138151
os.symlink(path, target_path)
139-
base_root, _ = os.path.splitext(basename)
140-
archive_path_root = os.path.join(arch, operating_system, base_root)
152+
archive_path_root = os.path.join(arch, operating_system, basename)
141153
with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar:
142154
tar.add(path, basename)
143155
with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip:
@@ -179,12 +191,32 @@ spec:
179191
addr = ('', 8080)
180192
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
181193
else:
182-
raise
194+
raise
183195
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
184196
sock.bind(addr)
185197
sock.listen(5)
186198
187-
[Thread(i, socket=sock) for i in range(100)]
199+
# Start server threads - using 10 threads to handle a good number of concurrent
200+
# downloads while maintaining reasonable resource usage
201+
threads = [Thread(i, socket=sock) for i in range(10)]
202+
203+
# Wait for server to be ready
204+
ready.wait()
205+
206+
# Verify server is actually listening
207+
for _ in range(30): # Try for 30 seconds
208+
try:
209+
test_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
210+
test_sock.connect(('localhost', 8080))
211+
test_sock.close()
212+
break
213+
except socket.error:
214+
time.sleep(1)
215+
else:
216+
print("Failed to verify server is listening", file=sys.stderr)
217+
sys.exit(1)
218+
219+
print("Server is ready and listening on port 8080")
188220
time.sleep(9e9)
189221
EOF
190222
exec python3 /tmp/serve.py

pkg/console/controllers/clidownloads/controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,20 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso
184184
archType string
185185
}{
186186
{"Linux for x86_64", "amd64/linux", "oc.tar"},
187+
{"Linux for x86_64 - RHEL 8", "amd64/linux", "oc.rhel8.tar"},
188+
{"Linux for x86_64 - RHEL 9", "amd64/linux", "oc.rhel9.tar"},
187189
{"Mac for x86_64", "amd64/mac", "oc.zip"},
188-
{"Windows for x86_64", "amd64/windows", "oc.zip"},
190+
{"Windows for x86_64", "amd64/windows", "oc.exe.zip"},
189191
{"Linux for ARM 64", "arm64/linux", "oc.tar"},
192+
{"Linux for ARM 64 - RHEL 8", "arm64/linux", "oc.rhel8.tar"},
193+
{"Linux for ARM 64 - RHEL 9", "arm64/linux", "oc.rhel9.tar"},
190194
{"Mac for ARM 64", "arm64/mac", "oc.zip"},
191195
{"Linux for IBM Power, little endian", "ppc64le/linux", "oc.tar"},
196+
{"Linux for IBM Power, little endian - RHEL 8", "ppc64le/linux", "oc.rhel8.tar"},
197+
{"Linux for IBM Power, little endian - RHEL 9", "ppc64le/linux", "oc.rhel9.tar"},
192198
{"Linux for IBM Z", "s390x/linux", "oc.tar"},
199+
{"Linux for IBM Z - RHEL 8", "s390x/linux", "oc.rhel8.tar"},
200+
{"Linux for IBM Z - RHEL 9", "s390x/linux", "oc.rhel9.tar"},
193201
}
194202

195203
links := []v1.CLIDownloadLink{}
@@ -212,7 +220,7 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso
212220
Spec: v1.ConsoleCLIDownloadSpec{
213221
Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal.
214222
215-
The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features.
223+
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.
216224
`,
217225
DisplayName: "oc - OpenShift Command Line Interface (CLI)",
218226
Links: links,

pkg/console/controllers/clidownloads/controller_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,42 @@ func TestPlatformBasedOCConsoleCLIDownloads(t *testing.T) {
116116
Spec: v1.ConsoleCLIDownloadSpec{
117117
Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal.
118118
119-
The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features.
119+
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.
120120
`,
121121
DisplayName: "oc - OpenShift Command Line Interface (CLI)",
122122
Links: []v1.CLIDownloadLink{
123123
{
124124
Href: "https://www.example.com/amd64/linux/oc.tar",
125125
Text: "Download oc for Linux for x86_64",
126126
},
127+
{
128+
Href: "https://www.example.com/amd64/linux/oc.rhel8.tar",
129+
Text: "Download oc for Linux for x86_64 - RHEL 8",
130+
},
131+
{
132+
Href: "https://www.example.com/amd64/linux/oc.rhel9.tar",
133+
Text: "Download oc for Linux for x86_64 - RHEL 9",
134+
},
127135
{
128136
Href: "https://www.example.com/amd64/mac/oc.zip",
129137
Text: "Download oc for Mac for x86_64",
130138
},
131139
{
132-
Href: "https://www.example.com/amd64/windows/oc.zip",
140+
Href: "https://www.example.com/amd64/windows/oc.exe.zip",
133141
Text: "Download oc for Windows for x86_64",
134142
},
135143
{
136144
Href: "https://www.example.com/arm64/linux/oc.tar",
137145
Text: "Download oc for Linux for ARM 64",
138146
},
147+
{
148+
Href: "https://www.example.com/arm64/linux/oc.rhel8.tar",
149+
Text: "Download oc for Linux for ARM 64 - RHEL 8",
150+
},
151+
{
152+
Href: "https://www.example.com/arm64/linux/oc.rhel9.tar",
153+
Text: "Download oc for Linux for ARM 64 - RHEL 9",
154+
},
139155
{
140156
Href: "https://www.example.com/arm64/mac/oc.zip",
141157
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
144160
Href: "https://www.example.com/ppc64le/linux/oc.tar",
145161
Text: "Download oc for Linux for IBM Power, little endian",
146162
},
163+
{
164+
Href: "https://www.example.com/ppc64le/linux/oc.rhel8.tar",
165+
Text: "Download oc for Linux for IBM Power, little endian - RHEL 8",
166+
},
167+
{
168+
Href: "https://www.example.com/ppc64le/linux/oc.rhel9.tar",
169+
Text: "Download oc for Linux for IBM Power, little endian - RHEL 9",
170+
},
147171
{
148172
Href: "https://www.example.com/s390x/linux/oc.tar",
149173
Text: "Download oc for Linux for IBM Z",
150174
},
175+
{
176+
Href: "https://www.example.com/s390x/linux/oc.rhel8.tar",
177+
Text: "Download oc for Linux for IBM Z - RHEL 8",
178+
},
179+
{
180+
Href: "https://www.example.com/s390x/linux/oc.rhel9.tar",
181+
Text: "Download oc for Linux for IBM Z - RHEL 9",
182+
},
151183
{
152184
Href: "https://www.example.com/oc-license",
153185
Text: "LICENSE",

pkg/console/subresource/deployment/deployment_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
15291529
Scheme: corev1.URIScheme("HTTP"),
15301530
},
15311531
},
1532-
TimeoutSeconds: 1,
1533-
PeriodSeconds: 10,
1534-
SuccessThreshold: 1,
1535-
FailureThreshold: 3,
1532+
TimeoutSeconds: 1,
1533+
PeriodSeconds: 10,
1534+
SuccessThreshold: 1,
1535+
FailureThreshold: 3,
1536+
InitialDelaySeconds: 5,
15361537
},
15371538
LivenessProbe: &corev1.Probe{
15381539
ProbeHandler: corev1.ProbeHandler{
@@ -1542,10 +1543,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
15421543
Scheme: corev1.URIScheme("HTTP"),
15431544
},
15441545
},
1545-
TimeoutSeconds: 1,
1546-
PeriodSeconds: 10,
1547-
SuccessThreshold: 1,
1548-
FailureThreshold: 3,
1546+
TimeoutSeconds: 1,
1547+
PeriodSeconds: 10,
1548+
SuccessThreshold: 1,
1549+
FailureThreshold: 3,
1550+
InitialDelaySeconds: 5,
15491551
},
15501552
Command: []string{"/bin/sh"},
15511553
Resources: corev1.ResourceRequirements{

test/e2e/downloads_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestDownloadsEndpoint(t *testing.T) {
4242
req := getRequest(t, link.Href)
4343
client := getInsecureClient()
4444
resp, err := client.Do(req)
45+
t.Logf("Requesting %s at %s\n", link.Text, link.Href)
4546

4647
if err != nil {
4748
t.Fatalf("http error getting %s at %s: %s", link.Text, link.Href, err)

0 commit comments

Comments
 (0)