Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sled-diagnostics] Output for support bundles should be structured #7228

Open
wants to merge 4 commits into
base: spr/papertigers/main.sled-diagnostics-output-for-support-bundles-should-be-structured
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

118 changes: 103 additions & 15 deletions openapi/sled-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,16 @@
"operationId": "support_dladm_info",
"responses": {
"200": {
"description": "",
"description": "successful operation",
"content": {
"*/*": {
"schema": {}
"application/json": {
"schema": {
"title": "Array_of_SledDiagnosticsQueryOutput",
"type": "array",
"items": {
"$ref": "#/components/schemas/SledDiagnosticsQueryOutput"
}
}
}
}
},
Expand All @@ -699,10 +705,16 @@
"operationId": "support_ipadm_info",
"responses": {
"200": {
"description": "",
"description": "successful operation",
"content": {
"*/*": {
"schema": {}
"application/json": {
"schema": {
"title": "Array_of_SledDiagnosticsQueryOutput",
"type": "array",
"items": {
"$ref": "#/components/schemas/SledDiagnosticsQueryOutput"
}
}
}
}
},
Expand All @@ -720,10 +732,16 @@
"operationId": "support_pargs_info",
"responses": {
"200": {
"description": "",
"description": "successful operation",
"content": {
"*/*": {
"schema": {}
"application/json": {
"schema": {
"title": "Array_of_SledDiagnosticsQueryOutput",
"type": "array",
"items": {
"$ref": "#/components/schemas/SledDiagnosticsQueryOutput"
}
}
}
}
},
Expand All @@ -741,10 +759,16 @@
"operationId": "support_pstack_info",
"responses": {
"200": {
"description": "",
"description": "successful operation",
"content": {
"*/*": {
"schema": {}
"application/json": {
"schema": {
"title": "Array_of_SledDiagnosticsQueryOutput",
"type": "array",
"items": {
"$ref": "#/components/schemas/SledDiagnosticsQueryOutput"
}
}
}
}
},
Expand All @@ -762,10 +786,12 @@
"operationId": "support_zoneadm_info",
"responses": {
"200": {
"description": "",
"description": "successful operation",
"content": {
"*/*": {
"schema": {}
"application/json": {
"schema": {
"$ref": "#/components/schemas/SledDiagnosticsQueryOutput"
}
}
}
},
Expand Down Expand Up @@ -5457,6 +5483,68 @@
"type": "string",
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"SledDiagnosticsQueryOutput": {
"oneOf": [
{
"type": "object",
"properties": {
"success": {
"type": "object",
"properties": {
"command": {
"description": "The command and it's arguments.",
"type": "string"
},
"exit_code": {
"nullable": true,
"description": "The exit code if one was present when the comman exited.",
"type": "integer",
"format": "int32"
},
"exit_status": {
"description": "The exit status of the command. This will be the exit code (if any) and exit reason such as from a signal.",
"type": "string"
},
"stdio": {
"description": "Any stdout/stderr produced by the command.",
"type": "string"
}
},
"required": [
"command",
"exit_status",
"stdio"
]
}
},
"required": [
"success"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"failure": {
"type": "object",
"properties": {
"error": {
"description": "The reason the command failed to execute.",
"type": "string"
}
},
"required": [
"error"
]
}
},
"required": [
"failure"
],
"additionalProperties": false
}
]
},
"SledIdentifiers": {
"description": "Identifiers for a single sled.\n\nThis is intended primarily to be used in timeseries, to identify sled from which metric data originates.",
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions sled-agent/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ schemars.workspace = true
serde.workspace = true
sled-agent-types.workspace = true
sled-hardware-types.workspace = true
sled-diagnostics.workspace = true
uuid.workspace = true
11 changes: 6 additions & 5 deletions sled-agent/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ use sled_agent_types::{
ZoneBundleId, ZoneBundleMetadata,
},
};
use sled_diagnostics::SledDiagnosticsQueryOutput;
use uuid::Uuid;

#[dropshot::api_description]
Expand Down Expand Up @@ -592,39 +593,39 @@ pub trait SledAgentApi {
}]
async fn support_zoneadm_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError>;
) -> Result<HttpResponseOk<SledDiagnosticsQueryOutput>, HttpError>;

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

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

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

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

#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)]
Expand Down
88 changes: 41 additions & 47 deletions sled-agent/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ use sled_agent_types::zone_bundle::{
BundleUtilization, CleanupContext, CleanupCount, CleanupPeriod,
StorageLimit, ZoneBundleId, ZoneBundleMetadata,
};
use sled_diagnostics::SledDiagnosticsCommandHttpOutput;
use sled_diagnostics::{
SledDiagnosticsCommandHttpOutput, SledDiagnosticsQueryOutput,
};
use std::collections::BTreeMap;

type SledApiDescription = ApiDescription<SledAgent>;
Expand Down Expand Up @@ -865,73 +867,65 @@ impl SledAgentApi for SledAgentImpl {

async fn support_zoneadm_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
) -> Result<HttpResponseOk<SledDiagnosticsQueryOutput>, HttpError> {
let sa = request_context.context();
let res = sa.support_zoneadm_info().await;
Ok(HttpResponseOk(FreeformBody(res.get_output().into())))
Ok(HttpResponseOk(res.get_output()))
}

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

Ok(HttpResponseOk(FreeformBody(output.into())))
Ok(HttpResponseOk(
sa.support_ipadm_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>(),
))
}

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

Ok(HttpResponseOk(FreeformBody(output.into())))
Ok(HttpResponseOk(
sa.support_dladm_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>(),
))
}

async fn support_pargs_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
) -> Result<HttpResponseOk<Vec<SledDiagnosticsQueryOutput>>, 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())))
Ok(HttpResponseOk(
sa.support_pargs_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>(),
))
}

async fn support_pstack_info(
request_context: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
) -> Result<HttpResponseOk<Vec<SledDiagnosticsQueryOutput>>, 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())))
Ok(HttpResponseOk(
sa.support_pstack_info()
.await
.into_iter()
.map(|cmd| cmd.get_output())
.collect::<Vec<_>>(),
))
}
}
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.