Skip to content

Commit 567f45b

Browse files
authored
adds node up/preflight to arm binaries (#140)
* adds node up/preflight to arm binaries * linter happiness
1 parent 1b96f07 commit 567f45b

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

internal/node/prereq.go

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,69 @@ import (
1010
"net/http"
1111
"os"
1212
"path/filepath"
13+
"runtime"
1314
"strings"
1415

1516
"github.com/fatih/color"
1617

1718
_ "embed"
1819
)
1920

20-
const (
21-
vmLinuxKernelURL string = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/x86_64/vmlinux-5.10.186"
22-
vmLinuxKernelSHA256 string = "d48d320e320a8cf970184e79e66a833b044a049a4c2c645b9a1abefdb2fe7b31"
21+
func init() {
22+
switch runtime.GOARCH {
23+
case "amd64":
24+
vmLinuxKernelURL = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/x86_64/vmlinux-5.10.186"
25+
vmLinuxKernelSHA256 = "d48d320e320a8cf970184e79e66a833b044a049a4c2c645b9a1abefdb2fe7b31"
2326

24-
cniPluginsTarballURL string = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz"
25-
cniPluginsTarballSHA256 string = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz.sha256"
26-
// TODO: once awslabs fixes their release action, this URL needs to be changed
27-
tcRedirectCNIPluginURL string = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64"
28-
tcRedirectCNIPluginSHA256 string = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64.sha256"
27+
cniPluginsTarballURL = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz"
28+
cniPluginsTarballSHA256 = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz.sha256"
29+
// TODO: once awslabs fixes their release action, this URL needs to be changed
30+
tcRedirectCNIPluginURL = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64"
31+
tcRedirectCNIPluginSHA256 = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-amd64.sha256"
2932

30-
firecrackerTarballURL string = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz"
31-
firecrackerTarballSHA256 string = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz.sha256.txt"
33+
firecrackerTarballURL = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz"
34+
firecrackerTarballSHA256 = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-x86_64.tgz.sha256.txt"
3235

33-
rootfsGzipURL string = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
34-
rootfsGzipSHA256 string = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
35-
)
36+
rootfsGzipURL = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
37+
rootfsGzipSHA256 = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
38+
case "arm64":
39+
vmLinuxKernelURL = "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.5/aarch64/vmlinux-5.10.186"
40+
vmLinuxKernelSHA256 = ""
41+
42+
cniPluginsTarballURL = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-arm64-v1.3.0.tgz"
43+
cniPluginsTarballSHA256 = "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-arm64-v1.3.0.tgz.sha256"
44+
45+
tcRedirectCNIPluginURL = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-arm64"
46+
tcRedirectCNIPluginSHA256 = "https://github.com/jordan-rash/tc-redirect-tap/releases/download/v0.0.1/tc-redirect-tap-arm64.sha256"
47+
48+
firecrackerTarballURL = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-aarch64.tgz"
49+
firecrackerTarballSHA256 = "https://github.com/firecracker-microvm/firecracker/releases/download/v1.5.0/firecracker-v1.5.0-aarch64.tgz.sha256.txt"
50+
51+
rootfsGzipURL = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz"
52+
rootfsGzipSHA256 = "https://synadia-nex.s3.us-east-2.amazonaws.com/rootfs.ext4.gz.sha256"
53+
}
54+
}
3655

3756
var (
3857
cyan = color.New(color.FgCyan).SprintFunc()
3958
red = color.New(color.FgRed).SprintFunc()
4059
magenta = color.New(color.FgMagenta).SprintFunc()
4160
green = color.New(color.FgHiGreen).SprintFunc()
61+
62+
vmLinuxKernelURL string
63+
vmLinuxKernelSHA256 string
64+
65+
cniPluginsTarballURL string
66+
cniPluginsTarballSHA256 string
67+
68+
tcRedirectCNIPluginURL string
69+
tcRedirectCNIPluginSHA256 string
70+
71+
firecrackerTarballURL string
72+
firecrackerTarballSHA256 string
73+
74+
rootfsGzipURL string
75+
rootfsGzipSHA256 string
4276
)
4377

4478
type initFunc func(*requirement, *NodeConfiguration) error
@@ -240,6 +274,7 @@ func writeCniConf(r *requirement, c *NodeConfiguration) error {
240274
}
241275

242276
func downloadKernel(r *requirement, _ *NodeConfiguration) error {
277+
_ = vmLinuxKernelSHA256 // TODO: implement sha verification
243278
for _, f := range r.files {
244279
// TODO: this is a hack for now
245280
if f.description != "VMLinux Kernel" {
@@ -271,6 +306,7 @@ func downloadKernel(r *requirement, _ *NodeConfiguration) error {
271306
}
272307

273308
func downloadFirecracker(_ *requirement, _ *NodeConfiguration) error {
309+
_ = firecrackerTarballSHA256
274310
// TODO: firecracker repo made the sha difficult to use
275311
rawData, err := decompressTarFromURL(firecrackerTarballURL, "")
276312
if err != nil {
@@ -286,7 +322,7 @@ func downloadFirecracker(_ *requirement, _ *NodeConfiguration) error {
286322
return err
287323
}
288324

289-
if header.Name == "release-v1.5.0-x86_64/firecracker-v1.5.0-x86_64" {
325+
if header.Name == "release-v1.5.0-x86_64/firecracker-v1.5.0-x86_64" || header.Name == "release-v1.5.0-aarch64/firecracker-v1.5.0-aarch64" {
290326
outFile, err := os.Create("/usr/local/bin/firecracker")
291327
if err != nil {
292328
fmt.Println(err)
@@ -350,6 +386,7 @@ func downloadCNIPlugins(r *requirement, c *NodeConfiguration) error {
350386
}
351387

352388
func downloadTCRedirectTap(r *requirement, _ *NodeConfiguration) error {
389+
_ = tcRedirectCNIPluginSHA256
353390
respBin, err := http.Get(tcRedirectCNIPluginURL)
354391
if err != nil {
355392
return err
@@ -377,6 +414,7 @@ func downloadTCRedirectTap(r *requirement, _ *NodeConfiguration) error {
377414
}
378415

379416
func downloadRootFS(r *requirement, _ *NodeConfiguration) error {
417+
_ = rootfsGzipSHA256
380418
for _, f := range r.files {
381419
// TODO: this is a hack for now
382420
if f.description != "Root Filesystem Template" {
@@ -407,7 +445,7 @@ func downloadRootFS(r *requirement, _ *NodeConfiguration) error {
407445
return nil
408446
}
409447

410-
func decompressTarFromURL(url string, urlSha string) (*tar.Reader, error) {
448+
func decompressTarFromURL(url string, _ string) (*tar.Reader, error) {
411449
respTar, err := http.Get(url)
412450
if err != nil {
413451
return nil, err

nex/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !(linux && amd64)
1+
//go:build !(linux && amd64) && !(linux && arm64)
22

33
package main
44

nex/node_linux_amd64.go renamed to nex/node_up_preflight.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build (linux && amd64) || (linux && arm64)
2+
13
package main
24

35
import (

0 commit comments

Comments
 (0)