Skip to content

Commit 12b65eb

Browse files
authored
[smf] Allow Crucible Zones to be self-assembling (#498)
* [smf] Allow Crucible Zones to be self-assembling * linklocal -> ll is the convention * Review feedback
1 parent 3a3e806 commit 12b65eb

6 files changed

+81
-17
lines changed

agent/agent_method_script.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -o xtrace
6+
7+
. /lib/svc/share/smf_include.sh
8+
9+
DATALINK="$(svcprop -c -p config/datalink "${SMF_FMRI}")"
10+
GATEWAY="$(svcprop -c -p config/gateway "${SMF_FMRI}")"
11+
DATASET="$(svcprop -c -p config/dataset "${SMF_FMRI}")"
12+
LISTEN_ADDR="$(svcprop -c -p config/listen_addr "${SMF_FMRI}")"
13+
LISTEN_PORT="$(svcprop -c -p config/listen_port "${SMF_FMRI}")"
14+
PORTBASE="$(svcprop -c -p config/portbase "${SMF_FMRI}")"
15+
DOWNSTAIRS_PREFIX="$(svcprop -c -p config/downstairs_prefix "${SMF_FMRI}")"
16+
SNAPSHOT_PREFIX="$(svcprop -c -p config/snapshot_prefix "${SMF_FMRI}")"
17+
18+
if [[ $DATALINK == unknown ]] || [[ $GATEWAY == unknown ]]; then
19+
printf 'ERROR: missing datalink or gateway' >&2
20+
exit "$SMF_EXIT_ERR_CONFIG"
21+
fi
22+
23+
ipadm show-addr "$DATALINK/ll" || ipadm create-addr -t -T addrconf "$DATALINK/ll"
24+
ipadm show-addr "$DATALINK/omicron6" || ipadm create-addr -t -T static -a "$LISTEN_ADDR" "$DATALINK/omicron6"
25+
route get -inet6 default -inet6 "$GATEWAY" || route add -inet6 default -inet6 "$GATEWAY"
26+
27+
args=(
28+
'-D' '/opt/oxide/crucible/bin/crucible-downstairs'
29+
'--dataset' "$DATASET"
30+
'-l' "[$LISTEN_ADDR]:$LISTEN_PORT"
31+
'-P' "$PORTBASE"
32+
'-p' "$DOWNSTAIRS_PREFIX"
33+
'-s' "$SNAPSHOT_PREFIX"
34+
)
35+
36+
exec /opt/oxide/crucible/bin/crucible-agent run "${args[@]}"

agent/smf/agent.xml

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<service_bundle type='manifest' name='oxide-crucible-agent'>
55

66
<service name='oxide/crucible/agent' type='service' version='1'>
7-
<create_default_instance enabled='false' />
7+
<create_default_instance enabled='true' />
88

99
<!-- Run once we hit multi-user, so that the network and file systems have
1010
been set up. -->
@@ -14,13 +14,7 @@
1414
</dependency>
1515

1616
<exec_method type='method' name='start'
17-
exec='/opt/oxide/crucible/bin/crucible-agent run
18-
-D /opt/oxide/crucible/bin/crucible-downstairs
19-
--dataset %{config/dataset}
20-
-l %{config/listen}
21-
-P %{config/portbase}
22-
-p %{config/downstairs_prefix}
23-
-s %{config/snapshot_prefix}'
17+
exec='/opt/oxide/lib/svc/manifest/crucible/agent.sh'
2418
timeout_seconds='30'
2519
/>
2620

@@ -31,8 +25,11 @@
3125
</property_group>
3226

3327
<property_group name='config' type='application'>
28+
<propval name='datalink' type='astring' value='unknown' />
29+
<propval name='gateway' type='astring' value='unknown' />
3430
<propval name='dataset' type='astring' value='' />
35-
<propval name='listen' type='astring' value='127.0.0.1:17000' />
31+
<propval name='listen_addr' type='astring' value='127.0.0.1' />
32+
<propval name='listen_port' type='astring' value='17000' />
3633
<propval name='uuid' type='astring' value='' />
3734
<propval name='nexus' type='astring' value='127.0.0.1:12221' />
3835
<propval name='portbase' type='astring' value='19000' />

agent/smf/downstairs.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</dependency>
1515

1616
<exec_method type='method' name='start'
17-
exec='/opt/oxide/crucible/bin/downstairs_method_script.sh'
17+
exec='/opt/oxide/lib/svc/manifest/crucible/downstairs.sh'
1818
timeout_seconds='30'
1919
/>
2020

package-manifest.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ source.rust.binary_names = ["crucible-agent", "crucible-downstairs"]
55
source.rust.release = true
66
source.paths = [
77
{ from = "agent/smf", to = "/var/svc/manifest/site/crucible" },
8-
{ from = "agent/downstairs_method_script.sh", to = "/opt/oxide/crucible/bin/downstairs_method_script.sh" }
8+
{ from = "agent/downstairs_method_script.sh", to = "/opt/oxide/lib/svc/manifest/crucible/downstairs.sh" },
9+
{ from = "agent/agent_method_script.sh", to = "/opt/oxide/lib/svc/manifest/crucible/agent.sh" }
910
]
1011
output.type = "zone"
1112

1213
[package.crucible-pantry]
13-
service_name = "crucible_pantry"
14+
service_name = "pantry"
1415
source.type = "local"
1516
source.rust.binary_names = ["crucible-pantry"]
1617
source.rust.release = true
1718
source.paths = [
18-
{ from = "pantry/smf", to = "/var/svc/manifest/site/crucible_pantry" }
19+
{ from = "pantry/smf/pantry.xml", to = "/var/svc/manifest/site/crucible/pantry.xml" },
20+
{ from = "pantry/pantry_method_script.sh", to = "/opt/oxide/lib/svc/manifest/crucible/pantry.sh" }
1921
]
2022
output.type = "zone"

pantry/pantry_method_script.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -o xtrace
6+
7+
. /lib/svc/share/smf_include.sh
8+
9+
DATALINK="$(svcprop -c -p config/datalink "${SMF_FMRI}")"
10+
GATEWAY="$(svcprop -c -p config/gateway "${SMF_FMRI}")"
11+
LISTEN_ADDR="$(svcprop -c -p config/listen_addr "${SMF_FMRI}")"
12+
LISTEN_PORT="$(svcprop -c -p config/listen_port "${SMF_FMRI}")"
13+
14+
if [[ $DATALINK == unknown ]] || [[ $GATEWAY == unknown ]]; then
15+
printf 'ERROR: missing datalink or gateway' >&2
16+
exit "$SMF_EXIT_ERR_CONFIG"
17+
fi
18+
19+
ipadm show-addr "$DATALINK/ll" || ipadm create-addr -t -T addrconf "$DATALINK/ll"
20+
ipadm show-addr "$DATALINK/omicron6" || ipadm create-addr -t -T static -a "$LISTEN_ADDR" "$DATALINK/omicron6"
21+
route get -inet6 default -inet6 "$GATEWAY" || route add -inet6 default -inet6 "$GATEWAY"
22+
23+
args=(
24+
'-l' "[$LISTEN_ADDR]:$LISTEN_PORT"
25+
)
26+
27+
exec /opt/oxide/crucible_pantry/bin/crucible-pantry run "${args[@]}"

pantry/smf/manifest.xml pantry/smf/pantry.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<service_bundle type='manifest' name='oxide-crucible-pantry'>
55

6-
<service name='system/illumos/crucible_pantry' type='service' version='1'>
6+
<service name='oxide/crucible/pantry' type='service' version='1'>
77
<create_default_instance enabled='false' />
88

99
<!-- Run once we hit multi-user, so that the network and file systems have
@@ -14,8 +14,7 @@
1414
</dependency>
1515

1616
<exec_method type='method' name='start'
17-
exec='/opt/oxide/crucible_pantry/bin/crucible-pantry run
18-
-l %{config/listen}'
17+
exec='/opt/oxide/lib/svc/manifest/crucible/pantry.sh'
1918
timeout_seconds='30'
2019
/>
2120

@@ -26,7 +25,10 @@
2625
</property_group>
2726

2827
<property_group name='config' type='application'>
29-
<propval name='listen' type='astring' value='127.0.0.1:17000' />
28+
<propval name='datalink' type='astring' value='unknown' />
29+
<propval name='gateway' type='astring' value='unknown' />
30+
<propval name='listen_addr' type='astring' value='127.0.0.1' />
31+
<propval name='listen_port' type='astring' value='17000' />
3032
</property_group>
3133

3234
<stability value='Unstable' />

0 commit comments

Comments
 (0)