Skip to content

Commit d72655c

Browse files
committed
env/linux-arm/aws, dashboard: add linux-arm-aws builder
This change adds the linux-arm-aws builder. This builder will be started on a EC2 instance which will spawn a single instance of the container. After the builder work is done, the instance will be destroyed. Updates golang/go#41867 Change-Id: I09d911c2f99d1dff8fe02feb458457e07e7d0cdd Reviewed-on: https://go-review.googlesource.com/c/build/+/260797 Trust: Carlos Amedee <[email protected]> Run-TryBot: Carlos Amedee <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]>
1 parent 725674f commit d72655c

File tree

9 files changed

+253
-1
lines changed

9 files changed

+253
-1
lines changed

cmd/buildlet/stage0/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ buildlet-stage0.windows-amd64: FORCE
2222
go install golang.org/x/build/cmd/upload
2323
upload --verbose --osarch=$@ --file=go:golang.org/x/build/cmd/buildlet/stage0 --public --cacheable=false go-builder-data/$@
2424

25+
buildlet-stage0.linux-arm: FORCE
26+
go install golang.org/x/build/cmd/upload
27+
upload --verbose --osarch=$@ --file=go:golang.org/x/build/cmd/buildlet/stage0 --public --cacheable=false go-builder-data/$@
28+
2529
buildlet-stage0.linux-arm-scaleway: FORCE
2630
go install golang.org/x/build/cmd/upload
2731
upload --verbose --osarch=$@ --file=go:golang.org/x/build/cmd/buildlet/stage0 --public --cacheable=false go-builder-data/$@

dashboard/builders.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,17 @@ var Hosts = map[string]*HostConfig{
525525
machineType: "m6g.xlarge",
526526
isEC2: true,
527527
env: []string{"GOROOT_BOOTSTRAP=/usr/local/go-bootstrap"},
528-
buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.linux-amd64",
528+
buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.linux-arm64",
529+
SSHUsername: "root",
530+
},
531+
"host-linux-arm-aws": &HostConfig{
532+
Notes: "Debian Buster, EC2 arm instance. See x/build/env/linux-arm/aws",
533+
VMImage: "ami-07409163bccd5ac4d",
534+
ContainerImage: "gobuilder-arm-aws:latest",
535+
machineType: "m6g.xlarge",
536+
isEC2: true,
537+
env: []string{"GOROOT_BOOTSTRAP=/usr/local/go-bootstrap"},
538+
buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.linux-arm",
529539
SSHUsername: "root",
530540
},
531541
"host-illumos-amd64-jclulow": &HostConfig{
@@ -2289,6 +2299,11 @@ func init() {
22892299
Name: "linux-arm64-aws",
22902300
HostType: "host-linux-arm64-aws",
22912301
})
2302+
addBuilder(BuildConfig{
2303+
Name: "linux-arm-aws",
2304+
HostType: "host-linux-arm-aws",
2305+
KnownIssue: 41867, // builder being tested for reliability
2306+
})
22922307
addBuilder(BuildConfig{
22932308
FlakyNet: true,
22942309
HostType: "host-linux-mipsle-mengzhuo",

env/linux-arm/aws/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2020 The Go Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style
3+
# license that can be found in the LICENSE file.
4+
5+
FROM arm32v6/debian:buster
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
RUN apt-get update && \
10+
apt-get install --yes \
11+
gcc curl strace \
12+
ca-certificates netbase \
13+
procps lsof psmisc \
14+
openssh-server
15+
16+
RUN mkdir /usr/local/go-bootstrap && \
17+
curl --silent https://storage.googleapis.com/go-builder-data/gobootstrap-linux-arm.tar.gz | \
18+
tar -C /usr/local/go-bootstrap -zxv
19+
20+
ENV GOROOT_BOOTSTRAP /usr/local/go-bootstrap
21+
RUN curl -o /usr/local/bin/stage0 https://storage.googleapis.com/go-builder-data/buildlet-stage0.linux-arm && \
22+
chmod +x /usr/local/bin/stage0
23+
24+
ENV GO_BUILDER_ENV host-linux-arm-aws
25+
26+
CMD ["/usr/local/bin/stage0"]

env/linux-arm/aws/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2020 The Go Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style
3+
# license that can be found in the LICENSE file.
4+
5+
# Run on a arm64 or arm instance.
6+
prod-build: Dockerfile
7+
sudo docker build -t gcr.io/symbolic-datum-552/gobuilder-arm-aws:latest .
8+
9+
# Run on a arm64 or arm instance.
10+
prod-push: prod-build
11+
sudo docker login -u oauth2accesstoken https://gcr.io
12+
sudo docker push gcr.io/symbolic-datum-552/gobuilder-arm-aws:latest
13+
sudo rm /root/.docker/config.json
14+
15+
env-var-check:
16+
ifndef AWS_ACCESS_KEY_ID
17+
$(error AWS_ACCESS_KEY_ID env var is not set)
18+
endif
19+
20+
ifndef AWS_SECRET_ACCESS_KEY
21+
$(error AWS_SECRET_ACCESS_KEY env var is not set)
22+
endif
23+
24+
create-aws-image: env-var-check
25+
packer build packer_image_aws_arm.json

env/linux-arm/aws/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# AWS Linux ARM Builder
2+
3+
## Machines
4+
5+
The AWS builders use the m6 instance types which are arm64 based machines of varying specifications.
6+
The base type used will be m6g.xlarge 4 vCPUs, 16384 MiB.
7+
8+
## Machine Image
9+
10+
Machine images are stored on AWS EBS service as a snapshot. New VMs can use the snapshot as an image
11+
by providing the AMI ID as the base image when a new VM is created. The machine image will be configured
12+
to install and initialize rundockerbuildlet.
13+
14+
## Buildlet Container Image
15+
16+
Buildlet container images must be build on an arm/arm64 instance with the proper credentials. The instructions
17+
are as follows:
18+
19+
* In your normal gcloud dev environment, retrieve a short-lived access token:
20+
21+
`you@dev:~$ gcloud auth print-access-token`
22+
23+
* On an arm64 instance, clone the build repository.
24+
25+
* cd into the `env/linux-arm/aws` directory.
26+
27+
* Execute: `make prod-push`
28+
29+
* When prompted for your password, paste in the access token from the first step.
30+
31+
* Ensure `/root/.docker/config.json` has been deleted.

env/linux-arm/aws/containerd.service

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# overwrite containerd.service
2+
# /etc/systemd/system/containerd.service.d/override.conf
3+
[Service]
4+
ExecStart=
5+
ExecStart=/usr/bin/setarch linux32 -B /usr/bin/containerd
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"variables": {
3+
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
4+
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
5+
"region": "us-east-2"
6+
},
7+
"builders": [
8+
{
9+
"type": "amazon-ebs",
10+
"access_key": "{{user `aws_access_key`}}",
11+
"ami_name": "go-linux-arm-{{timestamp}}",
12+
"ami_description": "Image for linux-arm Go builder",
13+
"instance_type": "a1.medium",
14+
"region": "{{user `region`}}",
15+
"secret_key": "{{user `aws_secret_key`}}",
16+
"source_ami_filter": {
17+
"filters": {
18+
"architecture": "arm64",
19+
"virtualization-type": "hvm",
20+
"name": "debian-10-arm64-*",
21+
"root-device-type": "ebs"
22+
},
23+
"owners": ["136693071363"],
24+
"most_recent": true
25+
},
26+
"decode_authorization_messages": true,
27+
"ssh_username": "admin",
28+
"tags": {
29+
"Name": "Debian",
30+
"Created": "{{isotime \"2006-01-02\"}}",
31+
"OS": "Debian 10 Buster",
32+
"Release": "Latest",
33+
"Base_AMI_Name": "{{ .SourceAMIName }}",
34+
"Extra": "{{ .SourceAMITags.TagName }}",
35+
"Description": "{{user `description`}}"
36+
},
37+
"launch_block_device_mappings": [
38+
{
39+
"device_name": "/dev/xvda",
40+
"volume_size": 10,
41+
"volume_type": "gp2",
42+
"delete_on_termination": true
43+
}
44+
]
45+
}
46+
],
47+
"provisioners": [
48+
{
49+
"type": "file",
50+
"source": "./rundockerbuildlet.service",
51+
"destination": "/tmp/rundockerbuildlet.service"
52+
},
53+
{
54+
"type": "file",
55+
"source": "./containerd.service",
56+
"destination": "/tmp/containerd.service"
57+
},
58+
{
59+
"type": "shell",
60+
"script": "./prepare_image.sh"
61+
}
62+
]
63+
}

env/linux-arm/aws/prepare_image.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2020 The Go Authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style
5+
# license that can be found in the LICENSE file.
6+
7+
#
8+
# Installs all dependencies for a Debian 10 linux arm64 Host which run arm containers.
9+
#
10+
11+
set -euxo pipefail
12+
13+
TMP_DIR="$(mktemp -d)"
14+
GO_PATH="$TMP_DIR/gopath"
15+
16+
sudo apt-get update && sudo apt-get upgrade -y
17+
18+
sudo apt-get install -y \
19+
apt-transport-https \
20+
ca-certificates \
21+
curl \
22+
gnupg-agent \
23+
gnupg2 \
24+
jq \
25+
software-properties-common
26+
27+
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
28+
29+
sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
30+
31+
sudo apt-get update
32+
33+
sudo apt-get install -y \
34+
docker-ce \
35+
docker-ce-cli \
36+
containerd.io
37+
38+
sudo usermod -aG docker "$USER"
39+
40+
# retrieve the latest version of Go
41+
GO_VERSION="$(curl -s https://golang.org/dl/?mode=json | jq --raw-output '.[0].version')"
42+
GO_PACKAGE="$GO_VERSION.linux-arm64.tar.gz"
43+
GO_SHA="$(curl -s https://golang.org/dl/?mode=json | jq --raw-output '.[0].files | map(select(.arch == "arm64")) | .[0].sha256')"
44+
45+
# download Go package
46+
curl -o "$TMP_DIR/$GO_PACKAGE" -L "https://golang.org/dl/$GO_PACKAGE"
47+
48+
# verify sha256 shasum"
49+
echo "$GO_SHA $TMP_DIR/$GO_PACKAGE" | sha256sum --check --status
50+
51+
# unzip Go package
52+
tar -xvf "$TMP_DIR/$GO_PACKAGE" -C "$TMP_DIR"
53+
54+
# build rundockerbuildlet
55+
mkdir -p "$GO_PATH"
56+
GOPATH="$GO_PATH" "$TMP_DIR/go/bin/go" get -u golang.org/x/build/cmd/rundockerbuildlet
57+
GOPATH="$GO_PATH" "$TMP_DIR/go/bin/go" build -o "$TMP_DIR/rundockerbuildlet" golang.org/x/build/cmd/rundockerbuildlet
58+
sudo mv "$TMP_DIR/rundockerbuildlet" /usr/local/bin/rundockerbuildlet
59+
60+
sudo mkdir -p /etc/systemd/system/containerd.service.d/
61+
sudo mv /tmp/containerd.service /etc/systemd/system/containerd.service.d/override.conf
62+
sudo systemctl daemon-reload
63+
sudo systemctl restart docker
64+
65+
sudo mv /tmp/rundockerbuildlet.service /etc/systemd/user/rundockerbuildlet.service
66+
sudo systemctl enable /etc/systemd/user/rundockerbuildlet.service
67+
sudo systemctl start rundockerbuildlet
68+
69+
# remove temporary directory
70+
rm -fr "$TMP_DIR"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Run Buildlets in Docker
3+
After=network.target
4+
5+
[Install]
6+
WantedBy=network-online.target
7+
8+
[Service]
9+
Type=simple
10+
RemainAfterExit=true
11+
ExecStart=/usr/local/bin/rundockerbuildlet \
12+
-env=host-linux-arm-aws \
13+
-image=gobuilder-arm-aws

0 commit comments

Comments
 (0)