Skip to content

Commit 4851d2e

Browse files
committed
gimlet: add "gimlet" factory to manage bare metal bench Gimlet jobs
1 parent 853772f commit 4851d2e

File tree

22 files changed

+3756
-39
lines changed

22 files changed

+3756
-39
lines changed

Cargo.lock

Lines changed: 121 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"database",
99
"download",
1010
"factory/aws",
11+
"factory/gimlet",
1112
"factory/lab",
1213
"factory/propolis",
1314
"github/client",
@@ -36,6 +37,8 @@ aws-types = "1"
3637
base64 = "0.22"
3738
bytes = "1.1"
3839
chrono = { version = "0.4", features = [ "serde" ] }
40+
debug_parser = "0.1"
41+
devinfo = { version = "0.1", features = [ "private" ] }
3942
dirs-next = "2"
4043
dropshot = { git = "https://github.com/oxidecomputer/dropshot" }
4144
futures = "0.3"
@@ -49,6 +52,7 @@ http = "1"
4952
http-body-util = "0.1"
5053
http-range = "0.1"
5154
hyper = "1"
55+
iddqd = "0.3"
5256
ipnet = "2.8"
5357
jmclib = { git = "https://github.com/jclulow/rust-jmclib", features = ["sqlite"] }
5458
libc = "0.2.113"
@@ -89,4 +93,5 @@ tokio-stream = "0.1"
8993
tokio-util = { version = "0.7", features = [ "io" ] }
9094
toml = "0.8"
9195
usdt = "0.5"
96+
uuid = { version = "1", features = [ "v4" ] }
9297
zone = { version = "0.3", features = [ "async" ], default-features = false }

common/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub fn guess_mime_type(filename: &str) -> String {
118118

119119
pub trait OutputExt {
120120
fn info(&self) -> String;
121+
fn stdout_string(&self) -> Result<String>;
121122
}
122123

123124
impl OutputExt for std::process::Output {
@@ -151,6 +152,10 @@ impl OutputExt for std::process::Output {
151152

152153
out
153154
}
155+
156+
fn stdout_string(&self) -> Result<String> {
157+
Ok(String::from_utf8(self.stdout.clone())?)
158+
}
154159
}
155160

156161
pub trait DurationExt {

factory/gimlet/Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "buildomat-factory-gimlet"
3+
version = "0.0.0"
4+
edition = "2021"
5+
license = "MPL-2.0"
6+
7+
[dependencies]
8+
buildomat-common = { path = "../../common" }
9+
buildomat-database = { path = "../../database" }
10+
#buildomat-download = { path = "../../download" }
11+
buildomat-client = { path = "../../client" }
12+
buildomat-types = { path = "../../types" }
13+
14+
anyhow = { workspace = true }
15+
chrono = { workspace = true }
16+
debug_parser = { workspace = true }
17+
devinfo = { workspace = true }
18+
dropshot = { workspace = true }
19+
getopts = { workspace = true }
20+
hyper = { workspace = true }
21+
iddqd = { workspace = true }
22+
libc = { workspace = true }
23+
rand = { workspace = true }
24+
schemars = { workspace = true }
25+
sea-query = { workspace = true }
26+
semver = { workspace = true }
27+
serde = { workspace = true }
28+
slog = { workspace = true }
29+
slog-term = { workspace = true }
30+
strum = { workspace = true }
31+
tlvc = { workspace = true }
32+
tokio = { workspace = true }
33+
toml = { workspace = true }
34+
usdt = { workspace = true }
35+
uuid = { workspace = true }

factory/gimlet/schema.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- v 1
2+
CREATE TABLE instance (
3+
model TEXT NOT NULL,
4+
serial TEXT NOT NULL,
5+
seq INTEGER NOT NULL,
6+
7+
worker TEXT NOT NULL,
8+
lease TEXT NOT NULL,
9+
target TEXT NOT NULL,
10+
state TEXT NOT NULL,
11+
bootstrap TEXT NOT NULL,
12+
13+
PRIMARY KEY (model, serial, seq)
14+
)
15+
16+
-- v 2
17+
CREATE INDEX instance_active ON instance (state)
18+
WHERE state <> 'destroyed';

factory/gimlet/scripts/install.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
function os_release {
7+
if [[ ! -f /etc/os-release ]]; then
8+
printf '\n'
9+
else
10+
local r=$( ( . /etc/os-release ; eval "echo \$$1" ) )
11+
printf '%s\n' "${r// /+}"
12+
fi
13+
}
14+
15+
#
16+
# Give the server some hints as to what OS we're running so that it can give us
17+
# the most appropriate agent binary:
18+
#
19+
q="?kernel=$(uname -s)"
20+
q+="&proc=$(uname -p)"
21+
q+="&mach=$(uname -m)"
22+
q+="&plat=$(uname -i)"
23+
q+="&id=$(os_release ID)"
24+
q+="&id_like=$(os_release ID_LIKE)"
25+
q+="&version_id=$(os_release VERSION_ID)"
26+
27+
if [[ $(uname -s) == SunOS ]]; then
28+
#
29+
# The Internet at the office does not have consistently fantastic
30+
# peering, so make sure we're putting our best foot forward with TCP:
31+
#
32+
ipadm set-prop -p send_buf=512000 tcp || true
33+
ipadm set-prop -p recv_buf=512000 tcp || true
34+
ipadm set-prop -p congestion_control=cubic tcp || true
35+
fi
36+
37+
while :; do
38+
rm -f /var/tmp/agent
39+
rm -f /var/tmp/agent.gz
40+
41+
#
42+
# First, try the gzip-compressed agent URL:
43+
#
44+
if curl -sSf -o /var/tmp/agent.gz '%URL%/file/agent.gz'"$q"; then
45+
if ! gunzip < /var/tmp/agent.gz > /var/tmp/agent; then
46+
sleep 1
47+
continue
48+
fi
49+
#
50+
# If that doesn't work, fall back to the old uncompressed URL:
51+
#
52+
elif ! curl -sSf -o /var/tmp/agent '%URL%/file/agent'"$q"; then
53+
sleep 1
54+
continue
55+
fi
56+
57+
chmod +rx /var/tmp/agent
58+
if ! /var/tmp/agent install '%URL%' '%STRAP%'; then
59+
sleep 1
60+
continue
61+
fi
62+
break
63+
done
64+
65+
exit 0

0 commit comments

Comments
 (0)