Skip to content

Commit 8ad59a1

Browse files
committed
Create a new NTP-admin service
1 parent 248e7ed commit 8ad59a1

File tree

28 files changed

+1069
-1
lines changed

28 files changed

+1069
-1
lines changed

Cargo.lock

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616
"clients/gateway-client",
1717
"clients/installinator-client",
1818
"clients/nexus-client",
19+
"clients/ntp-admin-client",
1920
"clients/oxide-client",
2021
"clients/oximeter-client",
2122
"clients/repo-depot-client",
@@ -104,6 +105,9 @@ members = [
104105
"nexus/test-utils-macros",
105106
"nexus/test-utils",
106107
"nexus/types",
108+
"ntp-admin",
109+
"ntp-admin/api",
110+
"ntp-admin/types",
107111
"oximeter/api",
108112
"oximeter/collector",
109113
"oximeter/db",
@@ -168,6 +172,7 @@ default-members = [
168172
"clients/gateway-client",
169173
"clients/installinator-client",
170174
"clients/nexus-client",
175+
"clients/ntp-admin-client",
171176
"clients/oxide-client",
172177
"clients/oximeter-client",
173178
"clients/repo-depot-client",
@@ -258,6 +263,9 @@ default-members = [
258263
"nexus/test-utils-macros",
259264
"nexus/test-utils",
260265
"nexus/types",
266+
"ntp-admin",
267+
"ntp-admin/api",
268+
"ntp-admin/types",
261269
"oximeter/api",
262270
"oximeter/collector",
263271
"oximeter/db",
@@ -511,6 +519,9 @@ lldp_protocol = { git = "https://github.com/oxidecomputer/lldp", package = "prot
511519
macaddr = { version = "1.0.1", features = ["serde_std"] }
512520
maplit = "1.0.2"
513521
newtype_derive = "0.1.6"
522+
ntp-admin-api = { path = "ntp-admin/api" }
523+
ntp-admin-client = { path = "clients/ntp-admin-client" }
524+
ntp-admin-types = { path = "ntp-admin/types" }
514525
mg-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "fa5f15cdcd5864161a929e2ec01534f70dfba216" }
515526
ddm-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "fa5f15cdcd5864161a929e2ec01534f70dfba216" }
516527
multimap = "0.10.1"
@@ -556,6 +567,7 @@ omicron-common = { path = "common" }
556567
omicron-dev-lib = { path = "dev-tools/omicron-dev-lib" }
557568
omicron-gateway = { path = "gateway" }
558569
omicron-nexus = { path = "nexus" }
570+
omicron-ntp-admin = { path = "ntp-admin" }
559571
omicron-omdb = { path = "dev-tools/omdb" }
560572
omicron-package = { path = "package" }
561573
omicron-passwords = { path = "passwords" }

clients/ntp-admin-client/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "ntp-admin-client"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MPL-2.0"
6+
7+
[lints]
8+
workspace = true
9+
10+
[dependencies]
11+
chrono.workspace = true
12+
progenitor.workspace = true
13+
reqwest = { workspace = true, features = [ "json", "rustls-tls", "stream" ] }
14+
schemars.workspace = true
15+
serde.workspace = true
16+
slog.workspace = true
17+
omicron-workspace-hack.workspace = true

clients/ntp-admin-client/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
//! Interface for making API requests to an Omicron NTP admin server
6+
7+
progenitor::generate_api!(
8+
spec = "../../openapi/ntp-admin.json",
9+
interface = Positional,
10+
inner_type = slog::Logger,
11+
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {
12+
slog::debug!(log, "client request";
13+
"method" => %request.method(),
14+
"uri" => %request.url(),
15+
"body" => ?&request.body(),
16+
);
17+
}),
18+
post_hook = (|log: &slog::Logger, result: &Result<_, _>| {
19+
slog::debug!(log, "client response"; "result" => ?result);
20+
}),
21+
derives = [schemars::JsonSchema],
22+
);

common/src/address.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ pub const NEXUS_TECHPORT_EXTERNAL_PORT: u16 = 12228;
6464
/// interface(s).
6565
pub const WICKETD_NEXUS_PROXY_PORT: u16 = 12229;
6666

67+
/// The port on which NTP runs
6768
pub const NTP_PORT: u16 = 123;
6869

70+
/// The port on which the NTP admin service exposes an HTTP interface
71+
pub const NTP_ADMIN_PORT: u16 = 10123;
72+
6973
/// The length for all VPC IPv6 prefixes
7074
pub const VPC_IPV6_PREFIX_LENGTH: u8 = 48;
7175

dev-tools/ls-apis/api-manifest.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ packages = [ "dns-server" ]
114114
label = "Nexus"
115115
packages = [ "omicron-nexus" ]
116116

117+
[[deployment_units]]
118+
label = "NTP"
119+
packages = [ "omicron-ntp-admin" ]
120+
117121
[[deployment_units]]
118122
label = "Oximeter"
119123
packages = [ "oximeter-collector" ]
@@ -212,6 +216,17 @@ This is the server running inside CockroachDB zones that performs \
212216
configuration and monitoring that requires the `cockroach` CLI.
213217
"""
214218

219+
[[apis]]
220+
client_package_name = "ntp-admin-client"
221+
label = "NTP Admin"
222+
server_package_name = "ntp-admin-api"
223+
versioned_how = "server"
224+
notes = """
225+
This is the server running inside NTP zones that performs \
226+
monitoring on 'chrony'.
227+
"""
228+
229+
215230
[[apis]]
216231
client_package_name = "crucible-agent-client"
217232
label = "Crucible Agent"

dev-tools/ls-apis/tests/api_dependencies.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Nexus Internal API (client: nexus-client)
7070
consumed by: oximeter-collector (omicron/oximeter/collector) via 1 path
7171
consumed by: propolis-server (propolis/bin/propolis-server) via 3 paths
7272

73+
NTP Admin (client: ntp-admin-client)
74+
7375
External API (client: oxide-client)
7476

7577
Oximeter (client: oximeter-client)

dev-tools/openapi-manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ itertools.workspace = true
2727
nexus-external-api.workspace = true
2828
nexus-internal-api.workspace = true
2929
newtype_derive.workspace = true
30+
ntp-admin-api.workspace = true
3031
omicron-workspace-hack.workspace = true
3132
openapi-lint.workspace = true
3233
openapi-manager-types.workspace = true

dev-tools/openapi-manager/src/omicron.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use gateway_api::gateway_api_mod;
1313
use installinator_api::installinator_api_mod;
1414
use nexus_external_api::nexus_external_api_mod;
1515
use nexus_internal_api::nexus_internal_api_mod;
16+
use ntp_admin_api::ntp_admin_api_mod;
1617
use oximeter_api::oximeter_api_mod;
1718
use repo_depot_api::repo_depot_api_mod;
1819
use sled_agent_api::sled_agent_api_mod;
@@ -127,6 +128,15 @@ pub fn all_apis() -> Vec<ManagedApiConfig> {
127128
ident: "nexus-internal",
128129
extra_validation: None,
129130
},
131+
ManagedApiConfig {
132+
title: "NTP Admin API",
133+
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
134+
description: "API for interacting with NTP",
135+
boundary: ApiBoundary::Internal,
136+
api_description: ntp_admin_api_mod::stub_api_description,
137+
ident: "ntp-admin",
138+
extra_validation: None,
139+
},
130140
ManagedApiConfig {
131141
title: "Oxide Oximeter API",
132142
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),

nexus/inventory/src/collector.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ impl<'a> Collector<'a> {
7676
self.collect_all_keepers().await;
7777
self.collect_all_cockroach().await;
7878

79+
// TODO(https://github.com/oxidecomputer/omicron/issues/8546): Collect
80+
// NTP timesync statuses
81+
82+
// TODO(https://github.com/oxidecomputer/omicron/issues/8544): Collect
83+
// DNS generations
84+
7985
debug!(&self.log, "finished collection");
8086

8187
Ok(self.in_progress.build())

0 commit comments

Comments
 (0)