-
Notifications
You must be signed in to change notification settings - Fork 40
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
[reconfigurator] clickhouse-admin endpoints to generate ClickHouse config files #6476
Changes from 12 commits
5ca633c
5888f23
14fe73e
eb25fd4
2c31a80
04c1a94
c128ef9
27ba91f
0412185
112bdc3
3f48362
2f7f8bd
aa1375f
48f8cf9
File filter
Filter by extension
Conversations
Jump to
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
|
||
use crate::context::ServerContext; | ||
use clickhouse_admin_api::*; | ||
use dropshot::HttpError; | ||
use dropshot::HttpResponseOk; | ||
use dropshot::RequestContext; | ||
use clickhouse_admin_types::config::{KeeperConfig, ReplicaConfig}; | ||
use clickhouse_admin_types::{KeeperSettings, ServerSettings}; | ||
use dropshot::{ | ||
HttpError, HttpResponseCreated, Path, RequestContext, TypedBody, | ||
}; | ||
use std::sync::Arc; | ||
|
||
type ClickhouseApiDescription = dropshot::ApiDescription<Arc<ServerContext>>; | ||
|
@@ -21,11 +23,29 @@ enum ClickhouseAdminImpl {} | |
impl ClickhouseAdminApi for ClickhouseAdminImpl { | ||
type Context = Arc<ServerContext>; | ||
|
||
async fn clickhouse_address( | ||
async fn generate_server_config( | ||
rqctx: RequestContext<Self::Context>, | ||
) -> Result<HttpResponseOk<ClickhouseAddress>, HttpError> { | ||
path: Path<GenerationNum>, | ||
body: TypedBody<ServerSettings>, | ||
) -> Result<HttpResponseCreated<ReplicaConfig>, HttpError> { | ||
let ctx = rqctx.context(); | ||
let output = ctx.clickward().clickhouse_address()?; | ||
Ok(HttpResponseOk(output)) | ||
let server_settings = body.into_inner(); | ||
let output = ctx.clickward().generate_server_config(server_settings)?; | ||
// TODO(https://github.com/oxidecomputer/omicron/issues/5999): Do something with the generation number | ||
println!("{path:?}"); | ||
Ok(HttpResponseCreated(output)) | ||
} | ||
|
||
async fn generate_keeper_config( | ||
rqctx: RequestContext<Self::Context>, | ||
path: Path<GenerationNum>, | ||
body: TypedBody<KeeperSettings>, | ||
) -> Result<HttpResponseCreated<KeeperConfig>, HttpError> { | ||
let ctx = rqctx.context(); | ||
let keeper_settings = body.into_inner(); | ||
let output = ctx.clickward().generate_keeper_config(keeper_settings)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the returned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $ curl -X put http://[::1]:8888/keeper/config -H "Content-Type: application/json" -d '{"generation": 3, "settings": {"node_id": 1, "raft_servers": [{"id": 1, "host": {"ipv6": "ff::01"}}, {"id": 2, "host":{"ipv4": "127.0.0.1"}}, {"id": 3, "host":{"domain_name": "hi.there"}}], "config_dir": "./bob/bob", "datastore_path": "./", "listen_addr": "::1" }}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 439 100 175 100 264 67281 99k --:--:-- --:--:-- --:--:-- 214k
{
"request_id": "f79d5187-6ed8-4b55-ab1f-fb1b5aa010c6",
"error_code": "Internal",
"message": "clickward XML generation failure: No such file or directory (os error 2)"
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. That looks pretty good. I'm assuming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// TODO(https://github.com/oxidecomputer/omicron/issues/5999): Do something with the generation number | ||
println!("{path:?}"); | ||
andrewjstone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Ok(HttpResponseCreated(output)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes on the API structure here:
/keeper/config
./node
prefix seems somewhat superfluous. If we need a sharable endpoint for something likestats
we can add it and name it precisely without a prefix.