Skip to content

Commit

Permalink
⬆️ Bump LRE toolchains (#257)
Browse files Browse the repository at this point in the history
This adapts the new overlay logic.
  • Loading branch information
aaronmondal authored Dec 29, 2024
1 parent bf16e6a commit d5b32e4
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.0-pre.20240516.1
8.0.0
10 changes: 7 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ register_toolchains("@rules_ll//ll:ll_toolchain")

# Platform support.
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_cc", version = "0.0.17")

# Various utility functions such as path manipulations and templating.
bazel_dep(name = "bazel_skylib", version = "1.7.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")

# Documentation. These should be dev_dependencies, but that doesn't work at the
# moment. This is a bug.
bazel_dep(name = "rules_java", version = "7.6.1", dev_dependency = False)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = False)
bazel_dep(name = "stardoc", version = "0.7.2", dev_dependency = False)

# TODO(aaronmondal): We don't actually use this. Fix LRE upstream to make this
# import optional.
bazel_dep(name = "rules_rust", version = "0.56.0")

# The LLVM project. We override the specific commit below.
bazel_dep(name = "llvm-project-overlay", version = "17-init-bcr.3")
Expand Down
4 changes: 2 additions & 2 deletions devtools/ll.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
opt = (string: "\\E[33m" + string + "\\033[0m");


ll_up = import ./up.nix { inherit pkgs native; };
ll_up = pkgs.callPackage ./up.nix { inherit native; };
ll_docs = llScript "docs" ./docs.sh;
ll_patch = llScript "overlay" ./overlay.sh;
ll_release = llScript "module" ./module.sh;
Expand All @@ -33,7 +33,7 @@ elif [[ "$1" == "module" ]]; then
elif [[ "$1" == "up" ]]; then
${ll_up}/bin/up
elif [[ "$1" == "down" ]]; then
native down
${native}/bin/native down
else
printf '
Expand Down
88 changes: 66 additions & 22 deletions devtools/up.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{ pkgs, native, ... }:
{ lib
, curl
, fluxcd
, kubectl
, kustomize
, native
, nix
, writeShellScriptBin
, ...
}:

let
# Packages needed for the script
kubectl = pkgs.kubectl;
curl = pkgs.curl;
git = pkgs.git;
kustomize = pkgs.kustomize;
nix = pkgs.nix;
inherit (lib.meta) getExe;

# The specific commit to use
nativelinkCommit = "481226be52a84ad5a6b990cc48e9f97512d8ccd2";
nativelinkCommit = "b1df876fd64d60d5d1b6cb15a50e934923ab82bf";

# Base URL for GitHub access
githubBaseUrl = "github:TraceMachina/nativelink/";

in

pkgs.writeShellScriptBin "up" ''
writeShellScriptBin "up" ''
set -xeuo pipefail
# Start the native service
Expand All @@ -27,28 +31,68 @@ pkgs.writeShellScriptBin "up" ''
sleep 10
# Wait for the gateway to be ready
${kubectl}/bin/kubectl apply -k \
${getExe kubectl} apply -k \
https://github.com/TraceMachina/nativelink//deploy/kubernetes-example?ref=${nativelinkCommit}
# Wait for PipelineRuns to start
until ${kubectl}/bin/kubectl get pipelinerun \
-l tekton.dev/pipeline=rebuild-nativelink | grep -q 'NAME'; do
echo "Waiting for PipelineRuns to start..."
# Wait for Tekton
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-tekton-resources
# Wait for Flux Alerts
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-alert-core && \
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-alert-worker-init && \
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-alert-lre-cc
${getExe kubectl} apply -f - << 'EOF'
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: dummy-repository
namespace: default
spec:
interval: 2m
url: https://github.com/TraceMachina/nativelink
ref:
branch: main
EOF
# Wait for PipelineRuns
until pr=$(${getExe kubectl} get pipelinerun -o name | \
grep rebuild-nativelink-run-); do
echo "Waiting for pipeline to be created..."
sleep 1
done
echo "Found pipeline: $pr"
${getExe kubectl} wait --for=create $pr
# Wait for the pipeline to succeed
${kubectl}/bin/kubectl wait \
${getExe kubectl} wait \
--for=condition=Succeeded \
--timeout=30m \
--timeout=45m \
pipelinerun \
-l tekton.dev/pipeline=rebuild-nativelink
-l tekton.dev/pipeline=rebuild-nativelink
# TODO(aaronmondal): Find a better solution.
sleep 10
# Wait for NativeLink Kustomization
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-core
# Wait for worker Kustomization
${getExe fluxcd} reconcile kustomization -n default \
--timeout=15m \
nativelink-lre-cc
# Monitor the deployment rollout
${kubectl}/bin/kubectl rollout status deploy/nativelink-cas
${kubectl}/bin/kubectl rollout status deploy/nativelink-scheduler
${kubectl}/bin/kubectl rollout status deploy/nativelink-worker-lre-cc
${getExe kubectl} rollout status deploy/nativelink
${getExe kubectl} rollout status deploy/nativelink-worker-lre-cc
echo "nativelink_ip=$(${getExe kubectl} get gtw nativelink-gateway -o=jsonpath='{.status.addresses[0].value}')"
''
2 changes: 1 addition & 1 deletion examples/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.0-pre.20240516.1
8.0.0
2 changes: 1 addition & 1 deletion examples/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = "bazel_skylib", version = "1.7.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_ll", version = "0")
local_path_override(
module_name = "rules_ll",
Expand Down
34 changes: 24 additions & 10 deletions examples/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
# TODO(aaronmondal): This is currently required by LRE even if we don't use
# Rust. Fix this upstream.
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nativelink = {
url = "github:TraceMachina/nativelink/481226be52a84ad5a6b990cc48e9f97512d8ccd2";
url = "github:TraceMachina/nativelink/b1df876fd64d60d5d1b6cb15a50e934923ab82bf";
inputs.flake-utils.follows = "flake-utils";
inputs.flake-parts.follows = "flake-parts";
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
inputs.rust-overlay.follows = "rust-overlay";
};
rules_ll = {
# If you use this file as template, substitute the line below with this,
Expand All @@ -39,6 +46,7 @@
inputs.flake-parts.follows = "flake-parts";
inputs.nativelink.follows = "nativelink";
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
inputs.rust-overlay.follows = "rust-overlay";
};
};

Expand All @@ -47,6 +55,7 @@
, rules_ll
, flake-parts
, nativelink
, rust-overlay
, ...
} @ inputs:
flake-parts.lib.mkFlake { inherit inputs; }
Expand All @@ -69,6 +78,20 @@
openssl = (pkgs.openssl.override { static = true; });
in
{
_module.args.pkgs = import self.inputs.nixpkgs {
inherit system;
overlays = [
nativelink.overlays.lre
(import ../patches/nixpkgs-disable-ratehammering-pulumi-tests.nix)
(import rust-overlay)
];
# CUDA support
config.allowUnfree = true;
config.cudaSupport = true;
};
local-remote-execution.settings = {
inherit (pkgs.lre.lre-cc.meta) Env;
};
rules_ll.settings.llEnv = rules_ll.lib.defaultLlEnv {
inherit pkgs;
LL_CFLAGS = "-I${openssl.dev}/include";
Expand All @@ -94,15 +117,6 @@
# Has no effect in the examples as it's already handled by the
# top-level flake.
${config.local-remote-execution.installationScript}
# Prevent rules_cc from using anything other than clang.
export CC=clang
# Probably a bug in nix. Setting LD=ld.lld here doesn't work.
export LD=${pkgs.llvmPackages_17.lld}/bin/ld.lld
# Java needs to be the same version as in the Bazel wrapper.
export JAVA_HOME=${pkgs.jdk17_headless}/lib/openjdk
'';
};
};
Expand Down
46 changes: 24 additions & 22 deletions flake.lock

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

Loading

0 comments on commit d5b32e4

Please sign in to comment.