Skip to content

Commit f541cab

Browse files
karencfvcitrus-it
andauthored
[sled-agent] NTP zone config set up via zone-setup CLI (#5440)
## Overview This PR repurposes the zone-network CLI into a zone-setup CLI, in order to remove as many zone start-up scripts as possible. This is also in preparation to use this zone-setup CLI with the self assembling switch zone. Related: #1898 --------- Co-authored-by: Andy Fiddaman <[email protected]>
1 parent 84e9c27 commit f541cab

File tree

17 files changed

+618
-448
lines changed

17 files changed

+618
-448
lines changed

Cargo.lock

Lines changed: 12 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ members = [
7979
"wicket",
8080
"wicketd",
8181
"workspace-hack",
82-
"zone-network-setup",
82+
"zone-setup",
8383
]
8484

8585
default-members = [
@@ -158,7 +158,7 @@ default-members = [
158158
"wicket-dbg",
159159
"wicket",
160160
"wicketd",
161-
"zone-network-setup",
161+
"zone-setup",
162162
]
163163
resolver = "2"
164164

@@ -442,6 +442,7 @@ update-common = { path = "update-common" }
442442
update-engine = { path = "update-engine" }
443443
usdt = "0.5.0"
444444
uuid = { version = "1.8.0", features = ["serde", "v4"] }
445+
uzers = "0.11"
445446
walkdir = "2.5"
446447
whoami = "1.5"
447448
wicket = { path = "wicket" }

illumos-utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub mod route;
2424
pub mod running_zone;
2525
pub mod scf;
2626
pub mod svc;
27+
pub mod svcadm;
2728
pub mod vmm_reservoir;
2829
pub mod zfs;
2930
pub mod zone;

illumos-utils/src/svcadm.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Utilities for manipulating SMF services.
6+
7+
use crate::zone::SVCADM;
8+
use crate::{execute, ExecutionError, PFEXEC};
9+
10+
/// Wraps commands for interacting with svcadm.
11+
pub struct Svcadm {}
12+
13+
#[cfg_attr(any(test, feature = "testing"), mockall::automock)]
14+
impl Svcadm {
15+
pub fn refresh_logadm_upgrade() -> Result<(), ExecutionError> {
16+
let mut cmd = std::process::Command::new(PFEXEC);
17+
let cmd = cmd.args(&[SVCADM, "refresh", "logadm-upgrade"]);
18+
execute(cmd)?;
19+
Ok(())
20+
}
21+
}

package-manifest.toml

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ only_for_targets.image = "standard"
100100
source.type = "composite"
101101
source.packages = [
102102
"omicron-nexus.tar.gz",
103-
"zone-network-setup.tar.gz",
103+
"zone-setup.tar.gz",
104104
"zone-network-install.tar.gz",
105105
"opte-interface-setup.tar.gz",
106106
]
@@ -130,11 +130,7 @@ output.intermediate_only = true
130130
service_name = "oximeter"
131131
only_for_targets.image = "standard"
132132
source.type = "composite"
133-
source.packages = [
134-
"oximeter-collector.tar.gz",
135-
"zone-network-setup.tar.gz",
136-
"zone-network-install.tar.gz",
137-
]
133+
source.packages = [ "oximeter-collector.tar.gz", "zone-setup.tar.gz", "zone-network-install.tar.gz" ]
138134
output.type = "zone"
139135

140136
[package.oximeter-collector]
@@ -157,8 +153,8 @@ source.type = "composite"
157153
source.packages = [
158154
"clickhouse_svc.tar.gz",
159155
"internal-dns-cli.tar.gz",
160-
"zone-network-setup.tar.gz",
161-
"zone-network-install.tar.gz",
156+
"zone-setup.tar.gz",
157+
"zone-network-install.tar.gz"
162158
]
163159
output.type = "zone"
164160

@@ -183,8 +179,8 @@ source.type = "composite"
183179
source.packages = [
184180
"clickhouse_keeper_svc.tar.gz",
185181
"internal-dns-cli.tar.gz",
186-
"zone-network-setup.tar.gz",
187-
"zone-network-install.tar.gz",
182+
"zone-setup.tar.gz",
183+
"zone-network-install.tar.gz"
188184
]
189185
output.type = "zone"
190186

@@ -209,8 +205,8 @@ source.type = "composite"
209205
source.packages = [
210206
"cockroachdb-service.tar.gz",
211207
"internal-dns-cli.tar.gz",
212-
"zone-network-setup.tar.gz",
213-
"zone-network-install.tar.gz",
208+
"zone-setup.tar.gz",
209+
"zone-network-install.tar.gz"
214210
]
215211
output.type = "zone"
216212

@@ -245,8 +241,8 @@ source.type = "composite"
245241
source.packages = [
246242
"dns-server.tar.gz",
247243
"internal-dns-customizations.tar.gz",
248-
"zone-network-setup.tar.gz",
249-
"zone-network-install.tar.gz",
244+
"zone-setup.tar.gz",
245+
"zone-network-install.tar.gz"
250246
]
251247
output.type = "zone"
252248

@@ -257,7 +253,7 @@ source.type = "composite"
257253
source.packages = [
258254
"dns-server.tar.gz",
259255
"external-dns-customizations.tar.gz",
260-
"zone-network-setup.tar.gz",
256+
"zone-setup.tar.gz",
261257
"zone-network-install.tar.gz",
262258
"opte-interface-setup.tar.gz",
263259
]
@@ -298,10 +294,11 @@ service_name = "ntp"
298294
only_for_targets.image = "standard"
299295
source.type = "composite"
300296
source.packages = [
297+
"chrony-setup.tar.gz",
301298
"ntp-svc.tar.gz",
302299
"opte-interface-setup.tar.gz",
303-
"zone-network-setup.tar.gz",
304-
"zone-network-install.tar.gz",
300+
"zone-setup.tar.gz",
301+
"zone-network-install.tar.gz"
305302
]
306303
output.type = "zone"
307304

@@ -311,8 +308,17 @@ only_for_targets.image = "standard"
311308
source.type = "local"
312309
source.paths = [
313310
{ from = "smf/ntp/manifest", to = "/var/svc/manifest/site/ntp" },
314-
{ from = "smf/ntp/method", to = "/var/svc/method" },
315-
{ from = "smf/ntp/etc", to = "/etc" },
311+
]
312+
output.intermediate_only = true
313+
output.type = "zone"
314+
315+
[package.chrony-setup]
316+
service_name = "chrony-setup"
317+
only_for_targets.image = "standard"
318+
source.type = "local"
319+
source.paths = [
320+
{ from = "smf/chrony-setup/manifest.xml", to = "/var/svc/manifest/site/chrony-setup/manifest.xml" },
321+
{ from = "smf/chrony-setup/etc", to = "/etc" },
316322
]
317323
output.intermediate_only = true
318324
output.type = "zone"
@@ -457,23 +463,15 @@ output.intermediate_only = true
457463
service_name = "crucible"
458464
only_for_targets.image = "standard"
459465
source.type = "composite"
460-
source.packages = [
461-
"crucible.tar.gz",
462-
"zone-network-setup.tar.gz",
463-
"zone-network-install.tar.gz",
464-
]
466+
source.packages = [ "crucible.tar.gz", "zone-setup.tar.gz", "zone-network-install.tar.gz" ]
465467
output.type = "zone"
466468

467469

468470
[package.crucible-pantry-zone]
469471
service_name = "crucible_pantry"
470472
only_for_targets.image = "standard"
471473
source.type = "composite"
472-
source.packages = [
473-
"crucible-pantry.tar.gz",
474-
"zone-network-setup.tar.gz",
475-
"zone-network-install.tar.gz",
476-
]
474+
source.packages = [ "crucible-pantry.tar.gz", "zone-setup.tar.gz", "zone-network-install.tar.gz" ]
477475
output.type = "zone"
478476

479477
# Packages not built within Omicron, but which must be imported.
@@ -746,11 +744,11 @@ source.paths = [
746744
output.type = "zone"
747745
output.intermediate_only = true
748746

749-
[package.zone-network-setup]
750-
service_name = "zone-network-cli"
747+
[package.zone-setup]
748+
service_name = "zone-setup-cli"
751749
only_for_targets.image = "standard"
752750
source.type = "local"
753-
source.rust.binary_names = ["zone-networking"]
751+
source.rust.binary_names = ["zone-setup"]
754752
source.rust.release = true
755753
output.type = "zone"
756754
output.intermediate_only = true

sled-agent/src/services.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ impl ServiceManager {
20062006
Self::dns_install(info, Some(dns_servers.to_vec()), domain)
20072007
.await?;
20082008

2009-
let mut ntp_config = PropertyGroupBuilder::new("config")
2009+
let mut chrony_config = PropertyGroupBuilder::new("config")
20102010
.add_property("allow", "astring", &rack_net)
20112011
.add_property(
20122012
"boundary",
@@ -2015,7 +2015,7 @@ impl ServiceManager {
20152015
);
20162016

20172017
for s in ntp_servers {
2018-
ntp_config = ntp_config.add_property(
2018+
chrony_config = chrony_config.add_property(
20192019
"server",
20202020
"astring",
20212021
&s.to_string(),
@@ -2030,13 +2030,17 @@ impl ServiceManager {
20302030
}
20312031

20322032
let ntp_service = ServiceBuilder::new("oxide/ntp")
2033-
.add_instance(
2033+
.add_instance(ServiceInstanceBuilder::new("default"));
2034+
2035+
let chrony_setup_service =
2036+
ServiceBuilder::new("oxide/chrony-setup").add_instance(
20342037
ServiceInstanceBuilder::new("default")
2035-
.add_property_group(ntp_config),
2038+
.add_property_group(chrony_config),
20362039
);
20372040

20382041
let mut profile = ProfileBuilder::new("omicron")
20392042
.add_service(nw_setup_service)
2043+
.add_service(chrony_setup_service)
20402044
.add_service(disabled_ssh_service)
20412045
.add_service(dns_install_service)
20422046
.add_service(dns_client_service)

smf/chrony-setup/manifest.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
3+
4+
<service_bundle type='manifest' name='chrony-setup'>
5+
6+
<service name='oxide/chrony-setup' type='service' version='1'>
7+
<create_default_instance enabled='true' />
8+
9+
<dependency name='multi_user' grouping='require_all' restart_on='none'
10+
type='service'>
11+
<service_fmri value='svc:/milestone/multi-user:default' />
12+
</dependency>
13+
14+
<exec_method type='method' name='start'
15+
exec='/opt/oxide/zone-setup-cli/bin/zone-setup chrony-setup -b %{config/boundary} -s %{config/server} -a %{config/allow}'
16+
timeout_seconds='0'>
17+
<method_context security_flags="aslr">
18+
<method_credential user="root" group="root"
19+
privileges="basic,file_chown" />
20+
</method_context>
21+
</exec_method>
22+
23+
24+
<property_group name='startd' type='framework'>
25+
<propval name='duration' type='astring' value='transient' />
26+
</property_group>
27+
28+
<property_group name="config" type="application">
29+
<propval name="boundary" type="boolean" value="false" />
30+
<propval name="server" type="astring" value="" />
31+
<propval name="allow" type="astring" value="" />
32+
</property_group>
33+
34+
<stability value='Unstable' />
35+
36+
<template>
37+
<common_name>
38+
<loctext xml:lang='C'>Oxide Chrony Setup</loctext>
39+
</common_name>
40+
<description>
41+
<loctext xml:lang='C'>Configures chronyd for the NTP zone</loctext>
42+
</description>
43+
</template>
44+
</service>
45+
46+
</service_bundle>

smf/ntp/etc/inet/chrony.conf.boundary

Lines changed: 0 additions & 32 deletions
This file was deleted.

smf/ntp/etc/inet/chrony.conf.internal

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)