From b5deda3e0863b33c19375d65e37ef996ec36453a Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Tue, 22 Apr 2025 17:47:22 -0500 Subject: [PATCH] Add CPU architecture to the remote extensions object key (#11590) ARM computes are incoming and we need to account for that in remote extensions. Previously, we just blindly assumed that all computes were x86_64. Note that we use the Go architecture naming convention instead of the Rust one directly to do our best and be consistent across the stack. Part-of: https://github.com/neondatabase/cloud/issues/23148 Signed-off-by: Tristan Partin --- libs/compute_api/src/spec.rs | 13 +++++++++++-- test_runner/regress/test_download_extensions.py | 14 +++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libs/compute_api/src/spec.rs b/libs/compute_api/src/spec.rs index 5e67ccce00..ad246c48ec 100644 --- a/libs/compute_api/src/spec.rs +++ b/libs/compute_api/src/spec.rs @@ -242,13 +242,22 @@ impl RemoteExtSpec { match self.extension_data.get(real_ext_name) { Some(_ext_data) => { + // We have decided to use the Go naming convention due to Kubernetes. + + let arch = match std::env::consts::ARCH { + "x86_64" => "amd64", + "aarch64" => "arm64", + arch => arch, + }; + // Construct the path to the extension archive // BUILD_TAG/PG_MAJOR_VERSION/extensions/EXTENSION_NAME.tar.zst // // Keep it in sync with path generation in // https://github.com/neondatabase/build-custom-extensions/tree/main - let archive_path_str = - format!("{build_tag}/{pg_major_version}/extensions/{real_ext_name}.tar.zst"); + let archive_path_str = format!( + "{build_tag}/{arch}/{pg_major_version}/extensions/{real_ext_name}.tar.zst" + ); Ok(( real_ext_name.to_string(), RemotePath::from_string(&archive_path_str)?, diff --git a/test_runner/regress/test_download_extensions.py b/test_runner/regress/test_download_extensions.py index 77babe12cd..a81d55e57b 100644 --- a/test_runner/regress/test_download_extensions.py +++ b/test_runner/regress/test_download_extensions.py @@ -1,6 +1,7 @@ from __future__ import annotations import os +import platform import shutil import tarfile from typing import TYPE_CHECKING @@ -58,7 +59,18 @@ def test_remote_extensions( extensions_endpoint = f"http://{host}:{port}/pg-ext-s3-gateway" build_tag = os.environ.get("BUILD_TAG", "latest") - archive_route = f"{build_tag}/v{pg_version}/extensions/test_extension.tar.zst" + + # We have decided to use the Go naming convention due to Kubernetes. + arch = platform.machine() + match arch: + case "aarch64": + arch = "arm64" + case "x86_64": + arch = "amd64" + case _: + pass + + archive_route = f"{build_tag}/{arch}/v{pg_version}/extensions/test_extension.tar.zst" tarball = test_output_dir / "test_extension.tar" extension_dir = ( base_dir / "test_runner" / "regress" / "data" / "test_remote_extensions" / "test_extension"