Skip to content

Commit

Permalink
[spr] initial version
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
papertigers committed Dec 2, 2024
2 parents 41d7c9b + 3ecbb50 commit 291f17f
Show file tree
Hide file tree
Showing 14 changed files with 466 additions and 84 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ members = [
"sled-agent/bootstrap-agent-api",
"sled-agent/repo-depot-api",
"sled-agent/types",
"sled-diagnostics",
"sled-hardware",
"sled-hardware/types",
"sled-storage",
Expand Down Expand Up @@ -240,6 +241,7 @@ default-members = [
"sled-agent/bootstrap-agent-api",
"sled-agent/repo-depot-api",
"sled-agent/types",
"sled-diagnostics",
"sled-hardware",
"sled-hardware/types",
"sled-storage",
Expand Down Expand Up @@ -596,6 +598,7 @@ sled = "=0.34.7"
sled-agent-api = { path = "sled-agent/api" }
sled-agent-client = { path = "clients/sled-agent-client" }
sled-agent-types = { path = "sled-agent/types" }
sled-diagnostics = { path = "sled-diagnostics" }
sled-hardware = { path = "sled-hardware" }
sled-hardware-types = { path = "sled-hardware/types" }
sled-storage = { path = "sled-storage" }
Expand Down
42 changes: 42 additions & 0 deletions openapi/sled-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,48 @@
}
}
},
"/support/pargs-info": {
"get": {
"operationId": "support_pargs_info",
"responses": {
"200": {
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/support/pstack-info": {
"get": {
"operationId": "support_pstack_info",
"responses": {
"200": {
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/support/zoneadm-info": {
"get": {
"operationId": "support_zoneadm_info",
Expand Down
1 change: 1 addition & 0 deletions sled-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ sha3.workspace = true
sled-agent-api.workspace = true
sled-agent-client.workspace = true
sled-agent-types.workspace = true
sled-diagnostics.workspace = true
sled-hardware.workspace = true
sled-hardware-types.workspace = true
sled-storage.workspace = true
Expand Down
16 changes: 16 additions & 0 deletions sled-agent/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,22 @@ pub trait SledAgentApi {
async fn support_dladm_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError>;

#[endpoint {
method = GET,
path = "/support/pargs-info",
}]
async fn support_pargs_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError>;

#[endpoint {
method = GET,
path = "/support/pstack-info",
}]
async fn support_pstack_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError>;
}

#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)]
Expand Down
34 changes: 33 additions & 1 deletion sled-agent/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use super::sled_agent::SledAgent;
use crate::sled_agent::Error as SledAgentError;
use crate::support_bundle::queries::SupportBundleCommandHttpOutput;
use crate::zone_bundle::BundleError;
use bootstore::schemes::v0::NetworkConfig;
use camino::Utf8PathBuf;
Expand Down Expand Up @@ -53,6 +52,7 @@ use sled_agent_types::zone_bundle::{
BundleUtilization, CleanupContext, CleanupCount, CleanupPeriod,
StorageLimit, ZoneBundleId, ZoneBundleMetadata,
};
use sled_diagnostics::SledDiagnosticsCommandHttpOutput;
use std::collections::BTreeMap;

type SledApiDescription = ApiDescription<SledAgent>;
Expand Down Expand Up @@ -902,4 +902,36 @@ impl SledAgentApi for SledAgentImpl {

Ok(HttpResponseOk(FreeformBody(output.into())))
}

async fn support_pargs_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
let sa = request_context.context();
let output = sa
.support_pargs_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>()
.as_slice()
.join("\n\n");

Ok(HttpResponseOk(FreeformBody(output.into())))
}

async fn support_pstack_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
let sa = request_context.context();
let output = sa
.support_pstack_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>()
.as_slice()
.join("\n\n");

Ok(HttpResponseOk(FreeformBody(output.into())))
}
}
12 changes: 12 additions & 0 deletions sled-agent/src/sim/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,18 @@ impl SledAgentApi for SledAgentSimImpl {
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
method_unimplemented()
}

async fn support_pargs_info(
_request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
method_unimplemented()
}

async fn support_pstack_info(
_request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
method_unimplemented()
}
}

fn method_unimplemented<T>() -> Result<T, HttpError> {
Expand Down
29 changes: 19 additions & 10 deletions sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ use crate::params::OmicronZoneTypeExt;
use crate::probe_manager::ProbeManager;
use crate::services::{self, ServiceManager};
use crate::storage_monitor::StorageMonitorHandle;
use crate::support_bundle::queries::{
dladm_info, ipadm_info, zoneadm_info, SupportBundleCmdError,
SupportBundleCmdOutput,
};
use crate::support_bundle::storage::SupportBundleManager;
use crate::updates::{ConfigUpdates, UpdateManager};
use crate::vmm_reservoir::{ReservoirMode, VmmReservoirManager};
Expand Down Expand Up @@ -76,6 +72,7 @@ use sled_agent_types::zone_bundle::{
BundleUtilization, CleanupContext, CleanupCount, CleanupPeriod,
PriorityOrder, StorageLimit, ZoneBundleMetadata,
};
use sled_diagnostics::{SledDiagnosticsCmdError, SledDiagnosticsCmdOutput};
use sled_hardware::{underlay, HardwareManager};
use sled_hardware_types::underlay::BootstrapInterface;
use sled_hardware_types::Baseboard;
Expand Down Expand Up @@ -1367,20 +1364,32 @@ impl SledAgent {

pub(crate) async fn support_zoneadm_info(
&self,
) -> Result<SupportBundleCmdOutput, SupportBundleCmdError> {
zoneadm_info().await
) -> Result<SledDiagnosticsCmdOutput, SledDiagnosticsCmdError> {
sled_diagnostics::zoneadm_info().await
}

pub(crate) async fn support_ipadm_info(
&self,
) -> Vec<Result<SupportBundleCmdOutput, SupportBundleCmdError>> {
ipadm_info().await
) -> Vec<Result<SledDiagnosticsCmdOutput, SledDiagnosticsCmdError>> {
sled_diagnostics::ipadm_info().await
}

pub(crate) async fn support_dladm_info(
&self,
) -> Vec<Result<SupportBundleCmdOutput, SupportBundleCmdError>> {
dladm_info().await
) -> Vec<Result<SledDiagnosticsCmdOutput, SledDiagnosticsCmdError>> {
sled_diagnostics::dladm_info().await
}

pub(crate) async fn support_pargs_info(
&self,
) -> Vec<Result<SledDiagnosticsCmdOutput, SledDiagnosticsCmdError>> {
sled_diagnostics::pargs_oxide_processes(&self.log).await
}

pub(crate) async fn support_pstack_info(
&self,
) -> Vec<Result<SledDiagnosticsCmdOutput, SledDiagnosticsCmdError>> {
sled_diagnostics::pargs_oxide_processes(&self.log).await
}
}

Expand Down
1 change: 0 additions & 1 deletion sled-agent/src/support_bundle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub mod queries;
pub mod storage;
1 change: 1 addition & 0 deletions sled-diagnostics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
12 changes: 12 additions & 0 deletions sled-diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "sled-diagnostics"
version = "0.1.0"
edition = "2021"

[dependencies]
fs-err.workspace = true
futures.workspace = true
libc.workspace = true
slog.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["full"] }
Loading

0 comments on commit 291f17f

Please sign in to comment.