Skip to content

Commit

Permalink
Reverted some breaking changes made in commit
Browse files Browse the repository at this point in the history
077a625, and later. The change in this commit
made `jupyterhub_traefik/install.py` not download any versions of traefik, consul
or etcd where the checksums were not present.

Further, (and this was a change made in a later commit
faa2832), the default version of etcd was
updated to 3.4.15 and although this was present in the checksums, for some
reason it did not install properly in the github workflow.

Finally, updated some assert statements in tests/proxytest.py, to instead
run `assert_equal(val, cmp)`, which makes the pytest error message easier to
follow.
  • Loading branch information
alexleach committed Jun 23, 2021
1 parent c90686b commit 9685be6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
63 changes: 32 additions & 31 deletions jupyterhub_traefik_proxy/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def install_etcd(prefix, plat, etcd_version):
print("--- Done ---")
return
else:
if checksum_file(etcd_downloaded_archive) == checksums_etcd[etcd_url]:
checksum_etcd_archive = checksum_file(etcd_downloaded_archive)
if checksum_etcd_archive == checksums_etcd[etcd_url]:
os.chmod(etcd_bin, 0o755)
os.chmod(etcdctl_bin, 0o755)
print("--- Done ---")
Expand All @@ -161,43 +162,43 @@ def install_etcd(prefix, plat, etcd_version):
os.remove(etcdctl_bin)
os.remove(etcd_downloaded_archive)

if etcd_url in checksums_etcd:
if not os.path.exists(etcd_downloaded_archive):
print(f"Downloading {etcd_downloaded_dir_name} archive...")
urlretrieve(etcd_url, etcd_downloaded_archive)
else:
print(f"Archive {etcd_downloaded_dir_name} already exists")
if not os.path.exists(etcd_downloaded_archive):
print(f"Downloading {etcd_downloaded_dir_name} archive...")
urlretrieve(etcd_url, etcd_downloaded_archive)
else:
print(f"Archive {etcd_downloaded_dir_name} already exists")

if checksum_file(etcd_downloaded_archive) != checksums_etcd[etcd_url]:
if etcd_url in checksums_etcd:
checksum_etcd_archive = checksum_file(etcd_downloaded_archive)
if checksum_etcd_archive != checksums_etcd[etcd_url]:
raise IOError("Checksum failed")

print("Extracting the archive...")

if etcd_archive_extension == "zip":
with zipfile.ZipFile(etcd_downloaded_archive, "r") as zip_ref:
zip_ref.extract(etcd_downloaded_dir_name + "/etcd", etcd_binaries)
zip_ref.extract(etcd_downloaded_dir_name + "/etcdctl", etcd_binaries)
else:
with (tarfile.open(etcd_downloaded_archive, "r")) as tar_ref:
tar_ref.extract(etcd_downloaded_dir_name + "/etcd", etcd_binaries)
tar_ref.extract(etcd_downloaded_dir_name + "/etcdctl", etcd_binaries)

shutil.copy(os.path.join(etcd_binaries, etcd_downloaded_dir_name, "etcd"), etcd_bin)
shutil.copy(
os.path.join(etcd_binaries, etcd_downloaded_dir_name, "etcdctl"), etcdctl_bin)

os.chmod(etcd_bin, 0o755)
os.chmod(etcdctl_bin, 0o755)

# Cleanup
shutil.rmtree(etcd_binaries)
else:
warnings.warn(
f"Etcd {etcd_version} not supported ! Or, at least, we don't "
f"recognise {etcd_url} in our checksums",
stacklevel=2
)

print("Extracting the archive...")
if etcd_archive_extension == "zip":
with zipfile.ZipFile(etcd_downloaded_archive, "r") as zip_ref:
zip_ref.extract(etcd_downloaded_dir_name + "/etcd", etcd_binaries)
zip_ref.extract(etcd_downloaded_dir_name + "/etcdctl", etcd_binaries)
else:
with (tarfile.open(etcd_downloaded_archive, "r")) as tar_ref:
tar_ref.extract(etcd_downloaded_dir_name + "/etcd", etcd_binaries)
tar_ref.extract(etcd_downloaded_dir_name + "/etcdctl", etcd_binaries)

shutil.copy(os.path.join(etcd_binaries, etcd_downloaded_dir_name, "etcd"), etcd_bin)
shutil.copy(
os.path.join(etcd_binaries, etcd_downloaded_dir_name, "etcdctl"), etcdctl_bin)

os.chmod(etcd_bin, 0o755)
os.chmod(etcdctl_bin, 0o755)

# Cleanup
shutil.rmtree(etcd_binaries)

print("--- Done ---")


Expand Down Expand Up @@ -288,8 +289,8 @@ def main():
- v3.4.15-windows-amd64
- v3.3.10-linux-amd64
- v3.3.10-darwin-amd64
- v3.2.25-linux-amd64
- v3.2.25-darwin-amd64
- v3.2.26-linux-amd64
- v3.2.26-darwin-amd64
- consul:
- v1.9.4_darwin
- v1.9.4_linux_amd64
Expand Down
4 changes: 2 additions & 2 deletions tests/proxytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ async def test_check_routes(proxy, username):
# run initial check first, to ensure that `/` is in the routes
await proxy.check_routes(users, services)
routes = await proxy.get_all_routes()
assert sorted(routes) == ["/"]
assert_equal(sorted(routes), ["/"])

users[username] = test_user = MockUser(username)
spawner = test_user.spawners[""]
Expand Down Expand Up @@ -422,7 +422,7 @@ async def test_check_routes(proxy, username):
assert test_user.proxy_spec in after

# check that before and after state are the same
assert before == after
assert_equal(before, after)


async def test_websockets(proxy, launch_backend):
Expand Down

0 comments on commit 9685be6

Please sign in to comment.