Skip to content

Commit

Permalink
Merge branch 'eero/cleanup-builds-9' into 'master'
Browse files Browse the repository at this point in the history
Assorted tools around Bazel images

Launch single VM:
```
bazel run --config=systest :launch-single-vm
```
Get Host/SetupOS artifacts:
```
GET_HOST_OS=1 GET_SETUP_OS=1 ./get-artifacts.sh
``` 

See merge request dfinity-lab/public/ic!11616
  • Loading branch information
Bownairo committed Apr 4, 2023
2 parents 0472cf2 + 5ae2e57 commit d4a5433
Show file tree
Hide file tree
Showing 8 changed files with 376 additions and 6 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -106,6 +106,7 @@ members = [
"rs/http_endpoints/public",
"rs/http_endpoints/metrics",
"rs/http_utils",
"rs/ic_os/launch-single-vm",
"rs/ic_os/sev",
"rs/ic_os/sev_interfaces",
"rs/ic_os/sevctl",
Expand Down
2 changes: 2 additions & 0 deletions ic-os/defs.bzl
Expand Up @@ -274,6 +274,7 @@ def icos_build(name, upload_prefix, image_deps, mode = None, malicious = False,
sha256sum(
name = "disk-img.tar.zst.sha256",
srcs = [":disk-img.tar.zst"],
visibility = ["//visibility:public"],
)

gzip_compress(
Expand Down Expand Up @@ -396,6 +397,7 @@ def icos_build(name, upload_prefix, image_deps, mode = None, malicious = False,
name = "disk-img-url",
target = ":upload_disk-img",
basenames = ["upload_disk-img_disk-img.tar.zst.url"],
visibility = ["//visibility:public"],
tags = ["manual"],
)

Expand Down
27 changes: 27 additions & 0 deletions ic-os/guestos/BUILD.bazel
Expand Up @@ -34,6 +34,33 @@ sh_test(
data = [":rootfs/opt/ic/share/ic.json5.template"],
)

genrule(
name = "launch-single-vm",
srcs = [
"//rs/ic_os/launch-single-vm",
"//ic-os/guestos/envs/dev:disk-img-url",
"//ic-os/guestos/envs/dev:disk-img.tar.zst.sha256",
"//ic-os/guestos:scripts/build-bootstrap-config-image.sh",
"//bazel:version.txt",
],
outs = ["launch_single_vm_script"],
cmd = """
BIN="$(location //rs/ic_os/launch-single-vm:launch-single-vm)"
VERSION="$$(cat $(location //bazel:version.txt))"
URL="$$(cat $(location //ic-os/guestos/envs/dev:disk-img-url))"
SHA="$$(cat $(location //ic-os/guestos/envs/dev:disk-img.tar.zst.sha256))"
SCRIPT="$(location //ic-os/guestos:scripts/build-bootstrap-config-image.sh)"
cat <<EOF > $@
#!/usr/bin/env bash
set -euo pipefail
cd "\\$$BUILD_WORKSPACE_DIRECTORY"
$$BIN --version "$$VERSION" --url "$$URL" --sha256 "$$SHA" --build-bootstrap-script "$$SCRIPT"
EOF
""",
executable = True,
tags = ["manual"],
)

# All guest-os targets are named the same, just stay in different submodules.
# To build or run specific target:
#
Expand Down
27 changes: 21 additions & 6 deletions ic-os/scripts/get-artifacts.sh
Expand Up @@ -2,6 +2,10 @@

GET_GUEST_OS_DEFAULT=1
GET_GUEST_OS=${GET_GUEST_OS-$GET_GUEST_OS_DEFAULT}
GET_HOST_OS_DEFAULT=0
GET_HOST_OS=${GET_HOST_OS-$GET_HOST_OS_DEFAULT}
GET_SETUP_OS_DEFAULT=0
GET_SETUP_OS=${GET_SETUP_OS-$GET_SETUP_OS_DEFAULT}

DEFAULT=$(git rev-parse HEAD)
GIT=${GIT-$DEFAULT}
Expand Down Expand Up @@ -32,17 +36,28 @@ if [[ $GET_GUEST_OS -eq 1 ]]; then
cd artifacts/guest-os/disk-img
for f in *.tar; do tar --sparse -xf $f; done
)
fi

if [[ $GET_HOST_OS -eq 1 ]]; then
./gitlab-ci/src/artifacts/rclone_download.py --git-rev $GIT --out=artifacts/host-os --remote-path host-os --latest-to
(
cd artifacts/host-os/disk-img
for f in *.gz; do gunzip -f $f; done
)
(
cd artifacts/host-os/disk-img
for f in *.tar; do tar --sparse -xf $f; done
)
fi

DEFAULT=$(git rev-parse HEAD)
GIT_REV=${GIT_REV-$DEFAULT}
echo "➡️ Downloading artifacts for revision $GIT_REV (as upgrade target)"
./gitlab-ci/src/artifacts/rclone_download.py --git-rev $GIT_REV --out=artifacts/guest-os-master --remote-path guest-os --latest-to
if [[ $GET_SETUP_OS -eq 1 ]]; then
./gitlab-ci/src/artifacts/rclone_download.py --git-rev $GIT --out=artifacts/setup-os --remote-path setup-os --latest-to
(
cd artifacts/guest-os-master/disk-img
cd artifacts/setup-os/disk-img
for f in *.gz; do gunzip -f $f; done
)
(
cd artifacts/guest-os-master/disk-img
cd artifacts/setup-os/disk-img
for f in *.tar; do tar --sparse -xf $f; done
)
fi
35 changes: 35 additions & 0 deletions rs/ic_os/launch-single-vm/BUILD.bazel
@@ -0,0 +1,35 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
"@crate_index//:clap",
"@crate_index//:reqwest",
"@crate_index//:serde",
"@crate_index//:slog-async",
"@crate_index//:slog-term",
"@crate_index//:slog",
"@crate_index//:tempfile",
"@crate_index//:url",
"//rs/tests",
"//rs/prep",
"//rs/registry/subnet_type",
"//rs/types/types",
]

MACRO_DEPENDENCIES = []

ALIASES = {}

rust_binary(
name = "launch-single-vm",
srcs = glob(["src/*.rs"]),
aliases = ALIASES,
crate_name = "launch_single_vm",
edition = "2021",
proc_macro_deps = MACRO_DEPENDENCIES,
target_compatible_with = [
"@platforms//os:linux",
],
deps = DEPENDENCIES,
)
21 changes: 21 additions & 0 deletions rs/ic_os/launch-single-vm/Cargo.toml
@@ -0,0 +1,21 @@
[package]
name = "launch-single-vm"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tests = { path = "../../tests"}
ic-prep = { path = "../../prep"}
ic-registry-subnet-type = { path = "../../registry/subnet_type"}
ic-types = { path = "../../types/types" }

clap = { version = "3.1.6", features = ["derive"] }
reqwest = { version = "0.11.1", features = ["blocking", "multipart", "stream"] }
serde = { version = "1.0.115", features = ["derive"] }
slog-async = { version = "2.5", features = ["nested-values"] }
slog-term = "2.6.0"
slog = { version = "2.5.2", features = ["release_max_level_trace"] }
tempfile = "3.1.0"
url = "2.1.1"

0 comments on commit d4a5433

Please sign in to comment.