Skip to content

Commit b231a80

Browse files
authored
Wicket packaging (#2245)
Package up `wicketd` and `wicket` with omicron-package. There are a couple things remaining to do: * We need to be able to have the `BOOTSTRAP_ARTIFACT_PORT` listen on a bootstrap address. It's currently hardcoded to use localhost which is wrong. * Should sled-agent construct a config file for wicket so it knows how to contact wicketd? Currently the wicketd port is just hardcoded inside wicket. Both of these will come in follow ups.
1 parent cdda0d6 commit b231a80

File tree

13 files changed

+143
-11
lines changed

13 files changed

+143
-11
lines changed

common/src/address.rs

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub const CLICKHOUSE_PORT: u16 = 8123;
3939
pub const OXIMETER_PORT: u16 = 12223;
4040
pub const DENDRITE_PORT: u16 = 12224;
4141
pub const MGS_PORT: u16 = 12225;
42+
pub const WICKETD_PORT: u16 = 12226;
43+
pub const BOOTSTRAP_ARTIFACT_PORT: u16 = 12227;
4244

4345
pub const NEXUS_INTERNAL_PORT: u16 = 12221;
4446

internal-dns-client/src/names.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum ServiceName {
1818
Nexus,
1919
Oximeter,
2020
ManagementGatewayService,
21+
Wicketd,
2122
Dendrite,
2223
Tfport,
2324
}
@@ -31,6 +32,7 @@ impl fmt::Display for ServiceName {
3132
ServiceName::Nexus => write!(f, "nexus"),
3233
ServiceName::Oximeter => write!(f, "oximeter"),
3334
ServiceName::ManagementGatewayService => write!(f, "mgs"),
35+
ServiceName::Wicketd => write!(f, "wicketd"),
3436
ServiceName::Dendrite => write!(f, "dendrite"),
3537
ServiceName::Tfport => write!(f, "tfport"),
3638
}

openapi/sled-agent.json

+14
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,20 @@
14831483
"type"
14841484
]
14851485
},
1486+
{
1487+
"type": "object",
1488+
"properties": {
1489+
"type": {
1490+
"type": "string",
1491+
"enum": [
1492+
"wicketd"
1493+
]
1494+
}
1495+
},
1496+
"required": [
1497+
"type"
1498+
]
1499+
},
14861500
{
14871501
"type": "object",
14881502
"properties": {

package-manifest.toml

+20-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ source.paths = [ { from = "smf/mgs", to = "/var/svc/manifest/site/mgs" } ]
7272
output.type = "zone"
7373
output.intermediate_only = true
7474

75+
[package.wicketd]
76+
service_name = "wicketd"
77+
source.type = "local"
78+
source.rust.binary_names = ["wicketd"]
79+
source.rust.release = true
80+
source.paths = [ { from = "smf/wicketd", to = "/var/svc/manifest/site/wicketd" } ]
81+
output.type = "zone"
82+
output.intermediate_only = true
83+
84+
[package.wicket]
85+
service_name = "wicket"
86+
source.type = "local"
87+
source.rust.binary_names = ["wicket"]
88+
source.rust.release = true
89+
output.type = "zone"
90+
output.intermediate_only = true
91+
92+
7593
# Packages not built within Omicron, but which must be imported.
7694

7795
# Refer to
@@ -164,7 +182,7 @@ output.intermediate_only = true
164182
service_name = "switch"
165183
only_for_targets.switch_variant = "asic"
166184
source.type = "composite"
167-
source.packages = [ "omicron-gateway.tar.gz", "dendrite-asic.tar.gz" ]
185+
source.packages = [ "omicron-gateway.tar.gz", "dendrite-asic.tar.gz", "wicketd.tar.gz", "wicket.tar.gz" ]
168186
output.type = "zone"
169187

170188
# To package and install the stub variant of the switch, do the following:
@@ -177,5 +195,5 @@ output.type = "zone"
177195
service_name = "switch"
178196
only_for_targets.switch_variant = "stub"
179197
source.type = "composite"
180-
source.packages = [ "omicron-gateway.tar.gz", "dendrite-stub.tar.gz" ]
198+
source.packages = [ "omicron-gateway.tar.gz", "dendrite-stub.tar.gz", "wicketd.tar.gz", "wicket.tar.gz" ]
181199
output.type = "zone"

sled-agent/src/params.rs

+6
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ pub enum ServiceType {
378378
InternalDns { server_address: SocketAddrV6, dns_address: SocketAddrV6 },
379379
Oximeter,
380380
ManagementGatewayService,
381+
Wicketd,
381382
Dendrite { asic: DendriteAsic },
382383
Tfport { pkt_source: String },
383384
}
@@ -389,6 +390,7 @@ impl std::fmt::Display for ServiceType {
389390
ServiceType::InternalDns { .. } => write!(f, "internal_dns"),
390391
ServiceType::Oximeter => write!(f, "oximeter"),
391392
ServiceType::ManagementGatewayService => write!(f, "mgs"),
393+
ServiceType::Wicketd => write!(f, "wicketd"),
392394
ServiceType::Dendrite { .. } => write!(f, "dendrite"),
393395
ServiceType::Tfport { .. } => write!(f, "tfport"),
394396
}
@@ -412,6 +414,7 @@ impl From<ServiceType> for sled_agent_client::types::ServiceType {
412414
}
413415
St::Oximeter => AutoSt::Oximeter,
414416
St::ManagementGatewayService => AutoSt::ManagementGatewayService,
417+
St::Wicketd => AutoSt::Wicketd,
415418
St::Dendrite { asic } => AutoSt::Dendrite { asic: asic.into() },
416419
St::Tfport { pkt_source } => AutoSt::Tfport { pkt_source },
417420
}
@@ -497,6 +500,7 @@ impl ServiceZoneRequest {
497500
ServiceType::ManagementGatewayService => {
498501
SRV::Service(ServiceName::ManagementGatewayService)
499502
}
503+
ServiceType::Wicketd => SRV::Service(ServiceName::Wicketd),
500504
ServiceType::Dendrite { .. } => SRV::Service(ServiceName::Dendrite),
501505
ServiceType::Tfport { .. } => SRV::Service(ServiceName::Tfport),
502506
}
@@ -516,6 +520,8 @@ impl ServiceZoneRequest {
516520
ServiceType::ManagementGatewayService => {
517521
Some(SocketAddrV6::new(self.addresses[0], MGS_PORT, 0, 0))
518522
}
523+
// TODO: Is this correct?
524+
ServiceType::Wicketd => None,
519525
ServiceType::Dendrite { .. } => {
520526
Some(SocketAddrV6::new(self.addresses[0], DENDRITE_PORT, 0, 0))
521527
}

sled-agent/src/services.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ use crate::params::{
3838
use crate::smf_helper::SmfHelper;
3939
use crate::zone::Zones;
4040
use omicron_common::address::Ipv6Subnet;
41+
use omicron_common::address::BOOTSTRAP_ARTIFACT_PORT;
4142
use omicron_common::address::DENDRITE_PORT;
4243
use omicron_common::address::MGS_PORT;
4344
use omicron_common::address::NEXUS_INTERNAL_PORT;
4445
use omicron_common::address::OXIMETER_PORT;
4546
use omicron_common::address::RACK_PREFIX;
4647
use omicron_common::address::SLED_PREFIX;
48+
use omicron_common::address::WICKETD_PORT;
4749
use omicron_common::nexus_config::{
4850
self, DeploymentConfig as NexusDeploymentConfig,
4951
};
@@ -741,6 +743,26 @@ impl ServiceManager {
741743

742744
smfh.refresh()?;
743745
}
746+
ServiceType::Wicketd => {
747+
info!(self.inner.log, "Setting up wicketd service");
748+
749+
smfh.setprop(
750+
"config/address",
751+
&format!("[::1]:{WICKETD_PORT}"),
752+
)?;
753+
754+
// TODO: Use bootstrap address
755+
smfh.setprop(
756+
"config/artifact-address",
757+
&format!("[::1]:{BOOTSTRAP_ARTIFACT_PORT}"),
758+
)?;
759+
760+
smfh.setprop(
761+
"config/mgs-address",
762+
&format!("[::1]:{MGS_PORT}"),
763+
)?;
764+
smfh.refresh()?;
765+
}
744766
ServiceType::Dendrite { asic } => {
745767
info!(self.inner.log, "Setting up dendrite service");
746768

@@ -906,7 +928,11 @@ impl ServiceManager {
906928

907929
let services = match self.inner.stub_scrimlet {
908930
Some(_) => {
909-
vec![ServiceType::Dendrite { asic: DendriteAsic::TofinoStub }]
931+
vec![
932+
ServiceType::Dendrite { asic: DendriteAsic::TofinoStub },
933+
ServiceType::ManagementGatewayService,
934+
ServiceType::Wicketd,
935+
]
910936
}
911937
None => {
912938
vec![

smf/wicketd/config.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Example wicketd config file
3+
#
4+
5+
[log]
6+
# Show log messages of this level and more severe
7+
level = "debug"
8+
# Example output to a terminal (with colors)
9+
mode = "stderr-terminal"
10+
11+

smf/wicketd/manifest.xml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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='wicketd'>
5+
6+
<service name='system/illumos/wicketd' type='service' version='1'>
7+
<create_default_instance enabled='false' />
8+
<single_instance />
9+
10+
<dependency name='multi_user' grouping='require_all' restart_on='none'
11+
type='service'>
12+
<service_fmri value='svc:/milestone/multi-user:default' />
13+
</dependency>
14+
15+
<exec_method type='method' name='start'
16+
exec='ctrun -l child -o noorphan,regent /opt/oxide/wicketd/bin/wicketd run /var/svc/manifest/site/wicketd/config.toml --address %{config/address} --artifact-address %{config/artifact-address} --mgs-address %{config/mgs-address} &amp;'
17+
timeout_seconds='0' />
18+
<exec_method type='method' name='stop' exec=':kill' timeout_seconds='0' />
19+
20+
<property_group name='startd' type='framework'>
21+
<propval name='duration' type='astring' value='contract' />
22+
</property_group>
23+
24+
<property_group name='config' type='application'>
25+
<propval name='address' type='astring' value='unknown' />
26+
<propval name='artifact-address' type='astring' value='unknown' />
27+
<propval name='mgs-address' type='astring' value='unknown' />
28+
</property_group>
29+
30+
<stability value='Unstable' />
31+
32+
<template>
33+
<common_name>
34+
<loctext xml:lang='C'>Wicketd</loctext>
35+
</common_name>
36+
<description>
37+
<loctext xml:lang='C'>Technician Port Management Service</loctext>
38+
</description>
39+
</template>
40+
</service>
41+
42+
</service_bundle>

wicket/src/dispatch.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ impl WicketApp {
3838
/// Executes the command.
3939
pub fn exec(self) -> Result<()> {
4040
// TODO: make this configurable?
41-
let wicketd_addr: SocketAddrV6 = "[::1]:8000".parse().unwrap();
41+
// To launch within the switch zone, and as part of a login shell,
42+
// we likely have to store this in a config file, which may have to be written
43+
// by sled-agent.
44+
//
45+
// We can't just use a command line-arg because we want to act as a login shells
46+
let wicketd_addr: SocketAddrV6 = "[::1]:12226".parse().unwrap();
4247

4348
match self.shell_args {
4449
Some(shell_args) => {

wicketd/examples/config.toml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Example wicketd config file
33
#
44

5-
mgs_addr = "[::1]:9999"
6-
75
[log]
86
# Show log messages of this level and more severe
97
level = "debug"

wicketd/src/bin/wicketd.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ enum Args {
2828
/// The address on the bootstrap network to serve artifacts at
2929
#[clap(long, action)]
3030
artifact_address: SocketAddrV6,
31+
32+
/// The port on localhost for MGS
33+
#[clap(long, action)]
34+
mgs_address: SocketAddrV6,
3135
},
3236
}
3337

@@ -43,7 +47,12 @@ async fn do_run() -> Result<(), CmdError> {
4347

4448
match args {
4549
Args::Openapi => run_openapi().map_err(CmdError::Failure),
46-
Args::Run { config_file_path, address, artifact_address } => {
50+
Args::Run {
51+
config_file_path,
52+
address,
53+
artifact_address,
54+
mgs_address,
55+
} => {
4756
let config = Config::from_file(&config_file_path).map_err(|e| {
4857
CmdError::Failure(format!(
4958
"failed to parse {}: {}",
@@ -52,7 +61,7 @@ async fn do_run() -> Result<(), CmdError> {
5261
))
5362
})?;
5463

55-
let args = wicketd::Args { address, artifact_address };
64+
let args = wicketd::Args { address, artifact_address, mgs_address };
5665
run_server(config, args).await.map_err(CmdError::Failure)
5766
}
5867
}

wicketd/src/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
use dropshot::ConfigLogging;
88
use serde::{Deserialize, Serialize};
99
use snafu::prelude::*;
10-
use std::net::SocketAddrV6;
1110
use std::path::Path;
1211
use std::path::PathBuf;
1312

1413
#[derive(Clone, Debug, Serialize, Deserialize)]
1514
pub struct Config {
16-
pub mgs_addr: SocketAddrV6,
1715
pub log: ConfigLogging,
1816
}
1917

wicketd/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn run_openapi() -> Result<(), String> {
3535
pub struct Args {
3636
pub address: SocketAddrV6,
3737
pub artifact_address: SocketAddrV6,
38+
pub mgs_address: SocketAddrV6,
3839
}
3940

4041
/// Run an instance of the wicketd server
@@ -63,7 +64,7 @@ pub async fn run_server(config: Config, args: Args) -> Result<(), String> {
6364
..Default::default()
6465
};
6566

66-
let mgs_manager = MgsManager::new(&log, config.mgs_addr);
67+
let mgs_manager = MgsManager::new(&log, args.mgs_address);
6768
let mgs_handle = mgs_manager.get_handle();
6869
tokio::spawn(async move {
6970
mgs_manager.run().await;

0 commit comments

Comments
 (0)