-
Notifications
You must be signed in to change notification settings - Fork 61
[ereport] intial types and dropshot API crate #7833
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ef473d4
[ereport] intial types and dropshot API crate
hawkw 451dd1e
Cargo.toml seating arrangements
hawkw 2486745
oh right i removed that part
hawkw e542817
api_versions! macro requires you depend on semver
hawkw 992c6d4
workspace hack
hawkw 0c2a0bc
actually generate the api
hawkw e72858e
add client
hawkw 1c01fbd
actually i DO want ENAs newtyped...
hawkw 683e983
add to ls-apis and add (currently unused) deps
hawkw f42577c
gateway should also expose ereporter-api
hawkw ab921b7
Update dev-tools/openapi-manager/src/omicron.rs
hawkw 48e14ec
remove most of the replace directives
hawkw f75b9d4
address @davepacheco's suggestions
hawkw 3febae6
add missing import
hawkw cb1d89c
update ls-apis output
hawkw b8f9d50
typo fix from @andrewjstone
hawkw 3c5eb13
replace option with an enum
hawkw b70751d
s/ereporter/ereport
hawkw a266732
whoopsie
hawkw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "ereporter-client" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [dependencies] | ||
| chrono.workspace = true | ||
| expectorate.workspace = true | ||
| ereport-types.workspace = true | ||
| http.workspace = true | ||
| progenitor.workspace = true | ||
| reqwest = { workspace = true, features = ["json", "rustls-tls", "stream"] } | ||
| schemars.workspace = true | ||
| serde.workspace = true | ||
| slog.workspace = true | ||
| omicron-uuid-kinds.workspace = true | ||
| omicron-workspace-hack.workspace = true | ||
| uuid.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // 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/. | ||
|
|
||
| progenitor::generate_api!( | ||
| spec = "../../openapi/ereporter/ereporter-latest.json", | ||
| inner_type = slog::Logger, | ||
| derives = [schemars::JsonSchema, Clone, Eq, PartialEq], | ||
| 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); | ||
| }), | ||
| replace = { | ||
| Ena = ereport_types::Ena, | ||
| Ereport = ereport_types::Ereport, | ||
| Event = ereport_types::Event, | ||
| ReportKind = ereport_types::ReportKind, | ||
hawkw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TypedUuidForEreporterGenerationKind = omicron_uuid_kinds::EreporterGenerationUuid, | ||
| } | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [package] | ||
| name = "ereporter-api" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| ereport-types.workspace = true | ||
| dropshot.workspace = true | ||
| openapi-manager-types.workspace = true | ||
| schemars.workspace = true | ||
| semver.workspace = true | ||
| serde.workspace = true | ||
| serde_json.workspace = true | ||
| thiserror.workspace = true | ||
| uuid.workspace = true | ||
| omicron-workspace-hack.workspace = true | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // 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/. | ||
|
|
||
| //! HTTP API for ereport producers. | ||
| use dropshot::HttpError; | ||
| use dropshot::HttpResponseOk; | ||
| use dropshot::Path; | ||
| use dropshot::Query; | ||
| use dropshot::RequestContext; | ||
| pub use ereport_types::Ena; | ||
| pub use ereport_types::Ereport; | ||
| pub use ereport_types::EreporterGenerationUuid; | ||
| pub use ereport_types::Reporter; | ||
| use openapi_manager_types::{ | ||
| SupportedVersion, SupportedVersions, api_versions, | ||
| }; | ||
| use schemars::JsonSchema; | ||
| use serde::Deserialize; | ||
| use serde::Serialize; | ||
| use std::num::NonZeroU32; | ||
| use uuid::Uuid; | ||
|
|
||
| api_versions!([ | ||
hawkw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // WHEN CHANGING THE API (part 1 of 2): | ||
| // | ||
| // +- Pick a new semver and define it in the list below. The list MUST | ||
| // | remain sorted, which generally means that your version should go at | ||
| // | the very top. | ||
| // | | ||
| // | Duplicate this line, uncomment the *second* copy, update that copy for | ||
| // | your new API version, and leave the first copy commented out as an | ||
| // | example for the next person. | ||
| // v | ||
| // (next_int, IDENT), | ||
| (1, INITIAL), | ||
| ]); | ||
|
|
||
| // WHEN CHANGING THE API (part 2 of 2): | ||
| // | ||
| // The call to `api_versions!` above defines constants of type | ||
| // `semver::Version` that you can use in your Dropshot API definition to specify | ||
| // the version when a particular endpoint was added or removed. For example, if | ||
| // you used: | ||
| // | ||
| // (2, ADD_FOOBAR) | ||
| // | ||
| // Then you could use `VERSION_ADD_FOOBAR` as the version in which endpoints | ||
| // were added or removed. | ||
|
|
||
| /// API for ereport producers. | ||
| #[dropshot::api_description] | ||
| pub trait EreporterApi { | ||
| type Context; | ||
|
|
||
| /// Collect a tranche of ereports from this reporter. | ||
| #[endpoint { | ||
| method = GET, | ||
hawkw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| path = "/ereports/{reporter_id}", | ||
| }] | ||
| async fn ereports_get( | ||
| rqctx: RequestContext<Self::Context>, | ||
| path: Path<ReporterPath>, | ||
| query: Query<EreportQuery>, | ||
| ) -> Result<HttpResponseOk<Ereports>, HttpError>; | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] | ||
| pub struct ReporterPath { | ||
| /// The UUID of the reporter from which to collct ereports. | ||
| pub reporter_id: Uuid, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] | ||
| pub struct EreportQuery { | ||
| /// The generation (restart nonce) of the reporter at which all other query | ||
| /// parameters are valid. | ||
| /// | ||
| /// If this value does not match the reporter's current generation, the | ||
| /// reporter's response will include the current generation, and will start | ||
| /// at the earliest known ENA, rather than the provided `last_seen` ENA.` | ||
| pub generation: EreporterGenerationUuid, | ||
|
|
||
| /// If present, the reporter should not include ENAs earlier than this one | ||
| /// in its response, provided that the query's requested generation matches | ||
| /// the current generation. | ||
| pub start_at: Option<Ena>, | ||
|
|
||
| /// The ENA of the last ereport committed to persistent storage from the | ||
| /// requested reporter generation. | ||
| /// | ||
| /// If the generation parameter matches the reporter's current generation, | ||
| /// it is permitted to discard any ereports with ENAs up to and including | ||
| /// this value. If the generation has changed from the provided generation, | ||
| /// the reporter will not discard data. | ||
| pub committed: Option<Ena>, | ||
hawkw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Maximum number of ereports to return in this tranche. | ||
| pub limit: NonZeroU32, | ||
| } | ||
|
|
||
| /// A tranche of ereports received from a reporter. | ||
hawkw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] | ||
| pub struct Ereports { | ||
| /// The reporter's current generation ID. | ||
| /// | ||
| /// If this is not equal to the current known generation, then the reporter | ||
| /// has restarted. | ||
| pub generation: EreporterGenerationUuid, | ||
| /// The values of the ereports in this tranche. | ||
| pub reports: Vec<Ereport>, | ||
| /// If more ereports are present, this value contains the ENA of the ereport | ||
| /// immediately after the last report in this tranche. If this is None, no | ||
| /// more ereports are currently avaialble. | ||
| pub next_page: Option<Ena>, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [package] | ||
| name = "ereport-types" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| omicron-uuid-kinds.workspace = true | ||
| schemars.workspace = true | ||
| serde.workspace = true | ||
| serde_json.workspace = true | ||
| uuid.workspace = true | ||
| omicron-workspace-hack.workspace = true | ||
|
|
||
| [lints] | ||
| workspace = true |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.