diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 76a0a566b4..036dd39a49 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -1368,7 +1368,7 @@ LIMIT 100", download_size } - pub fn install_extension(&self, ext_name: &str, db_name: &str) -> Result<()> { + pub fn install_extension(&self, ext_name: &str, db_name: &str) -> Result { let mut conf = Config::from_str(self.connstr.as_str()).context("Failed to parse connection string")?; conf.dbname(db_name); @@ -1387,7 +1387,17 @@ LIMIT 100", .execute(&query, &[]) .context(format!("Failed to execute query: {}", query))?; - Ok(()) + let version_query = format!( + "SELECT extversion FROM pg_extension WHERE extname = '{}'", + ext_name.to_string().pg_quote() + ); + + let version: String = db_client + .query_one(&version_query, &[]) + .context(format!("Failed to execute query: {}", version_query))? + .get(0); + + Ok(version) } #[tokio::main] diff --git a/compute_tools/src/http/api.rs b/compute_tools/src/http/api.rs index 83e95652b2..947b91a311 100644 --- a/compute_tools/src/http/api.rs +++ b/compute_tools/src/http/api.rs @@ -10,6 +10,7 @@ use crate::catalog::{get_database_schema, get_dbs_and_roles}; use crate::compute::forward_termination_signal; use crate::compute::{ComputeNode, ComputeState, ParsedSpec}; use compute_api::requests::ConfigurationRequest; +use compute_api::responses::ExtensionInstallResult; use compute_api::responses::{ComputeStatus, ComputeStatusResponse, GenericAPIError}; use anyhow::Result; @@ -116,7 +117,13 @@ async fn routes(req: Request, compute: &Arc) -> Response Response::new(Body::from("true")), + Ok(res) => render_json(Body::from( + serde_json::to_string(&ExtensionInstallResult { + extension: extension.to_string(), + version: res, + }) + .unwrap(), + )), Err(e) => { error!("install_extension failed: {}", e); render_json_error(&e.to_string(), StatusCode::INTERNAL_SERVER_ERROR) diff --git a/compute_tools/src/http/openapi_spec.yaml b/compute_tools/src/http/openapi_spec.yaml index 600539d33f..9af406d38f 100644 --- a/compute_tools/src/http/openapi_spec.yaml +++ b/compute_tools/src/http/openapi_spec.yaml @@ -173,11 +173,15 @@ paths: 200: description: Result from extension installation content: - text/plain: + application/json: schema: - type: string - description: Error text or 'true' if extension was installed. - example: "true" + $ref: "#/components/schemas/ExtensionInstallResult" + 500: + description: Error during extension installation. + content: + application/json: + schema: + $ref: "#/components/schemas/GenericError" /configure: post: @@ -444,6 +448,16 @@ components: - configuration example: running + ExtensionInstallResult: + type: object + properties: + extension: + description: Name of the extension. + type: string + version: + description: Version of the extension. + type: string + InstalledExtensions: type: object properties: diff --git a/libs/compute_api/src/responses.rs b/libs/compute_api/src/responses.rs index 5023fce003..7d96975f3f 100644 --- a/libs/compute_api/src/responses.rs +++ b/libs/compute_api/src/responses.rs @@ -168,3 +168,9 @@ pub struct InstalledExtension { pub struct InstalledExtensions { pub extensions: Vec, } + +#[derive(Clone, Debug, Default, Serialize)] +pub struct ExtensionInstallResult { + pub extension: String, + pub version: String, +}