Skip to content

Commit

Permalink
[repo depot 2/n] sled agent APIs to manage update artifact storage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
iliana authored Oct 31, 2024
1 parent 95e84c7 commit d1ff1bb
Show file tree
Hide file tree
Showing 24 changed files with 1,567 additions and 18 deletions.
28 changes: 28 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"clients/nexus-client",
"clients/oxide-client",
"clients/oximeter-client",
"clients/repo-depot-client",
"clients/sled-agent-client",
"clients/wicketd-client",
"cockroach-admin",
Expand Down Expand Up @@ -100,6 +101,7 @@ members = [
"sled-agent",
"sled-agent/api",
"sled-agent/bootstrap-agent-api",
"sled-agent/repo-depot-api",
"sled-agent/types",
"sled-hardware",
"sled-hardware/types",
Expand Down Expand Up @@ -140,6 +142,7 @@ default-members = [
"clients/nexus-client",
"clients/oxide-client",
"clients/oximeter-client",
"clients/repo-depot-client",
"clients/sled-agent-client",
"clients/wicketd-client",
"cockroach-admin",
Expand Down Expand Up @@ -225,6 +228,7 @@ default-members = [
"sled-agent",
"sled-agent/api",
"sled-agent/bootstrap-agent-api",
"sled-agent/repo-depot-api",
"sled-agent/types",
"sled-hardware",
"sled-hardware/types",
Expand Down Expand Up @@ -533,6 +537,8 @@ reedline = "0.35.0"
ref-cast = "1.0"
regex = "1.11.0"
regress = "0.9.1"
repo-depot-api = { path = "sled-agent/repo-depot-api" }
repo-depot-client = { path = "clients/repo-depot-client" }
reqwest = { version = "0.12", default-features = false }
ring = "0.17.8"
rpassword = "7.3.1"
Expand Down
16 changes: 16 additions & 0 deletions clients/repo-depot-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "repo-depot-client"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
omicron-workspace-hack.workspace = true
progenitor.workspace = true
reqwest.workspace = true
schemars.workspace = true
serde.workspace = true
slog.workspace = true
24 changes: 24 additions & 0 deletions clients/repo-depot-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// 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/.

//! Interface for Sled Agent's Repo Depot to make API requests.
progenitor::generate_api!(
spec = "../../openapi/repo-depot.json",
inner_type = slog::Logger,
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {
slog::debug!(log, "client request";
"method" => %request.method(),
"uri" => %request.url(),
"body" => ?&request.body(),
);
}),
post_hook = (|log: &slog::Logger, result: &Result<_, _>| {
slog::debug!(log, "client response"; "result" => ?result);
}),
derives = [schemars::JsonSchema],
);

/// A type alias for errors returned by this crate.
pub type ClientError = crate::Error<crate::types::Error>;
1 change: 1 addition & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub const MIN_PORT: u16 = u16::MIN;
pub const DNS_PORT: u16 = 53;
pub const DNS_HTTP_PORT: u16 = 5353;
pub const SLED_AGENT_PORT: u16 = 12345;
pub const REPO_DEPOT_PORT: u16 = 12348;

pub const COCKROACH_PORT: u16 = 32221;
pub const COCKROACH_ADMIN_PORT: u16 = 32222;
Expand Down
5 changes: 5 additions & 0 deletions dev-tools/ls-apis/api-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ client_package_name = "sled-agent-client"
label = "Sled Agent"
server_package_name = "sled-agent-api"

[[apis]]
client_package_name = "repo-depot-client"
label = "Repo Depot API"
server_package_name = "repo-depot-api"

[[apis]]
client_package_name = "wicketd-client"
label = "Wicketd"
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/ls-apis/tests/api_dependencies.out
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ Propolis (client: propolis-client)
Crucible Repair (client: repair-client)
consumed by: crucible-downstairs (crucible/downstairs) via 1 path

Repo Depot API (client: repo-depot-client)
consumed by: omicron-sled-agent (omicron/sled-agent) via 1 path

Sled Agent (client: sled-agent-client)
consumed by: dpd (dendrite/dpd) via 1 path
consumed by: omicron-nexus (omicron/nexus) via 7 paths
Expand Down
7 changes: 4 additions & 3 deletions dev-tools/openapi-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ anyhow.workspace = true
atomicwrites.workspace = true
bootstrap-agent-api.workspace = true
camino.workspace = true
clap.workspace = true
clickhouse-admin-api.workspace = true
cockroach-admin-api.workspace = true
clap.workspace = true
dns-server-api.workspace = true
dropshot.workspace = true
fs-err.workspace = true
Expand All @@ -24,13 +24,14 @@ installinator-api.workspace = true
nexus-external-api.workspace = true
nexus-internal-api.workspace = true
omicron-workspace-hack.workspace = true
openapiv3.workspace = true
openapi-lint.workspace = true
openapi-manager-types.workspace = true
openapiv3.workspace = true
owo-colors.workspace = true
oximeter-api.workspace = true
repo-depot-api.workspace = true
serde_json.workspace = true
sled-agent-api.workspace = true
similar.workspace = true
sled-agent-api.workspace = true
supports-color.workspace = true
wicketd-api.workspace = true
9 changes: 9 additions & 0 deletions dev-tools/openapi-manager/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ pub fn all_apis() -> Vec<ApiSpec> {
filename: "oximeter.json",
extra_validation: None,
},
ApiSpec {
title: "Oxide TUF Repo Depot API",
version: "0.0.1",
description: "API for fetching update artifacts",
boundary: ApiBoundary::Internal,
api_description: repo_depot_api::repo_depot_api_mod::stub_api_description,
filename: "repo-depot.json",
extra_validation: None,
},
ApiSpec {
title: "Oxide Sled Agent API",
version: "0.0.1",
Expand Down
82 changes: 82 additions & 0 deletions openapi/repo-depot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"openapi": "3.0.3",
"info": {
"title": "Oxide TUF Repo Depot API",
"description": "API for fetching update artifacts",
"contact": {
"url": "https://oxide.computer",
"email": "[email protected]"
},
"version": "0.0.1"
},
"paths": {
"/artifact/sha256/{sha256}": {
"get": {
"summary": "Fetch an artifact from the depot.",
"operationId": "artifact_get_by_sha256",
"parameters": [
{
"in": "path",
"name": "sha256",
"required": true,
"schema": {
"type": "string",
"format": "hex string (32 bytes)"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
}
},
"components": {
"schemas": {
"Error": {
"description": "Error information from a response.",
"type": "object",
"properties": {
"error_code": {
"type": "string"
},
"message": {
"type": "string"
},
"request_id": {
"type": "string"
}
},
"required": [
"message",
"request_id"
]
}
},
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
Loading

0 comments on commit d1ff1bb

Please sign in to comment.