Skip to content

Commit

Permalink
Remove azcopy support for downloading boot images
Browse files Browse the repository at this point in the history
We don't need it any more. We download images from internal MinIO
cluster.
  • Loading branch information
enescakir committed Feb 2, 2024
1 parent 4980853 commit 230ddfb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
17 changes: 1 addition & 16 deletions rhizome/host/lib/vm_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,7 @@ def download_boot_image(boot_image, custom_url: nil)
# same time.
temp_path = File.join(vp.image_root, boot_image + image_ext + ".tmp")
File.open(temp_path, File::RDWR | File::CREAT | File::EXCL, 0o644) do
if download.match?(/^https:\/\/.+\.blob\.core\.windows\.net/)
install_azcopy
r "AZCOPY_CONCURRENCY_VALUE=5 azcopy copy #{download.shellescape} #{temp_path.shellescape}"
else
r "curl -f -L10 -o #{temp_path.shellescape} #{download.shellescape}"
end
r "curl -f -L10 -o #{temp_path.shellescape} #{download.shellescape}"
end

if initial_format == "raw"
Expand All @@ -472,16 +467,6 @@ def download_boot_image(boot_image, custom_url: nil)
end
end

def install_azcopy
r "which azcopy"
rescue CommandFail
r "curl -L10 -o azcopy_v10.tar.gz 'https://aka.ms/downloadazcopy-v10-linux#{Arch.render(x64: "", arm64: "-arm64")}'"
r "tar --strip-components=1 --exclude=*.txt -xzvf azcopy_v10.tar.gz"
r "rm azcopy_v10.tar.gz"
r "mv azcopy /usr/bin/azcopy"
r "chmod +x /usr/bin/azcopy"
end

# Unnecessary if host has this set before creating the netns, but
# harmless and fast enough to double up.
def forwarding
Expand Down
12 changes: 5 additions & 7 deletions rhizome/host/spec/vm_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ def key_wrapping_secrets
vs.download_boot_image("ubuntu-jammy")
end

it "can download image with custom URL that has query params using azcopy" do
it "can download vhd image with custom URL that has query params using curl" do
expect(File).to receive(:exist?).with("/var/storage/images/github-ubuntu-2204.raw").and_return(false)
expect(File).to receive(:open) do |path, *_args|
expect(path).to eq("/var/storage/images/github-ubuntu-2204.vhd.tmp")
end.and_yield
expect(FileUtils).to receive(:mkdir_p).with("/var/storage/images/")
expect(vs).to receive(:r).with("which azcopy")
expect(vs).to receive(:r).with("AZCOPY_CONCURRENCY_VALUE=5 azcopy copy https://images.blob.core.windows.net/images/ubuntu2204.vhd\\?sp\\=r\\&st\\=2023-09-05T22:44:05Z\\&se\\=2023-10-07T06:44:05 /var/storage/images/github-ubuntu-2204.vhd.tmp")
expect(vs).to receive(:r).with("curl -f -L10 -o /var/storage/images/github-ubuntu-2204.vhd.tmp http://minio.ubicloud.com:9000/ubicloud-images/ubuntu-22.04-x64.vhd\\?X-Amz-Algorithm\\=AWS4-HMAC-SHA256\\&X-Amz-Credential\\=user\\%2F20240112\\%2Fus-east-1\\%2Fs3\\%2Faws4_request\\&X-Amz-Date\\=20240112T132931Z\\&X-Amz-Expires\\=3600\\&X-Amz-SignedHeaders\\=host\\&X-Amz-Signature\\=aabbcc")
expect(vs).to receive(:r).with("qemu-img convert -p -f vpc -O raw /var/storage/images/github-ubuntu-2204.vhd.tmp /var/storage/images/github-ubuntu-2204.raw")
expect(FileUtils).to receive(:rm_r).with("/var/storage/images/github-ubuntu-2204.vhd.tmp")

vs.download_boot_image("github-ubuntu-2204", custom_url: "https://images.blob.core.windows.net/images/ubuntu2204.vhd?sp=r&st=2023-09-05T22:44:05Z&se=2023-10-07T06:44:05")
vs.download_boot_image("github-ubuntu-2204", custom_url: "http://minio.ubicloud.com:9000/ubicloud-images/ubuntu-22.04-x64.vhd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=user%2F20240112%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240112T132931Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=aabbcc")
end

it "does not convert image if it's in raw format already" do
Expand All @@ -69,12 +68,11 @@ def key_wrapping_secrets
expect(path).to eq("/var/storage/images/github-ubuntu-2204.raw.tmp")
end.and_yield
expect(FileUtils).to receive(:mkdir_p).with("/var/storage/images/")
expect(vs).to receive(:r).with("which azcopy")
expect(vs).to receive(:r).with("AZCOPY_CONCURRENCY_VALUE=5 azcopy copy https://images.blob.core.windows.net/images/ubuntu2204.raw\\?sp\\=r\\&st\\=2023-09-05T22:44:05Z\\&se\\=2023-10-07T06:44:05 /var/storage/images/github-ubuntu-2204.raw.tmp")
expect(vs).to receive(:r).with("curl -f -L10 -o /var/storage/images/github-ubuntu-2204.raw.tmp http://minio.ubicloud.com:9000/ubicloud-images/ubuntu-22.04-x64.raw\\?X-Amz-Algorithm\\=AWS4-HMAC-SHA256\\&X-Amz-Credential\\=user\\%2F20240112\\%2Fus-east-1\\%2Fs3\\%2Faws4_request\\&X-Amz-Date\\=20240112T132931Z\\&X-Amz-Expires\\=3600\\&X-Amz-SignedHeaders\\=host\\&X-Amz-Signature\\=aabbcc")
expect(File).to receive(:rename).with("/var/storage/images/github-ubuntu-2204.raw.tmp", "/var/storage/images/github-ubuntu-2204.raw")
expect(FileUtils).to receive(:rm_r).with("/var/storage/images/github-ubuntu-2204.raw.tmp")

vs.download_boot_image("github-ubuntu-2204", custom_url: "https://images.blob.core.windows.net/images/ubuntu2204.raw?sp=r&st=2023-09-05T22:44:05Z&se=2023-10-07T06:44:05")
vs.download_boot_image("github-ubuntu-2204", custom_url: "http://minio.ubicloud.com:9000/ubicloud-images/ubuntu-22.04-x64.raw?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=user%2F20240112%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240112T132931Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=aabbcc")
end

it "can use an image that's already downloaded" do
Expand Down

0 comments on commit 230ddfb

Please sign in to comment.