mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
tweaks
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3302,6 +3302,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"snow",
|
||||
"spki",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -28,7 +28,10 @@ use crate::{
|
||||
config::core_config,
|
||||
helpers::periphery_client,
|
||||
monitor::{alert::check_alerts, record::record_server_stats},
|
||||
state::{db_client, deployment_status_cache, repo_status_cache},
|
||||
state::{
|
||||
db_client, deployment_status_cache, periphery_connections,
|
||||
repo_status_cache,
|
||||
},
|
||||
};
|
||||
|
||||
use self::helpers::{
|
||||
@@ -174,6 +177,7 @@ pub async fn update_cache_for_server(server: &Server, force: bool) {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
periphery_connections().remove(&server.id).await;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use anyhow::Context;
|
||||
use database::mungos::mongodb::{Collection, bson::doc};
|
||||
use formatting::format_serror;
|
||||
use indexmap::IndexSet;
|
||||
use komodo_client::entities::{
|
||||
Operation, ResourceTarget, ResourceTargetVariant, komodo_timestamp,
|
||||
@@ -18,9 +17,7 @@ use komodo_client::entities::{
|
||||
|
||||
use crate::{
|
||||
config::core_config,
|
||||
connection::PeripheryConnectionArgs,
|
||||
monitor::update_cache_for_server,
|
||||
periphery::PeripheryClient,
|
||||
state::{
|
||||
action_states, db_client, periphery_connections,
|
||||
server_status_cache,
|
||||
@@ -164,29 +161,8 @@ impl super::KomodoResource for Server {
|
||||
|
||||
async fn post_update(
|
||||
updated: &Self,
|
||||
update: &mut Update,
|
||||
_update: &mut Update,
|
||||
) -> anyhow::Result<()> {
|
||||
if updated.config.enabled {
|
||||
// Init periphery client to trigger reconnection
|
||||
// if relevant parameters change.
|
||||
if let Err(e) = PeripheryClient::new(
|
||||
PeripheryConnectionArgs::from_server(updated),
|
||||
&updated.config.passkey,
|
||||
)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Failed to get client handle after update for Server {}",
|
||||
updated.id
|
||||
)
|
||||
}) {
|
||||
warn!("{e:#}");
|
||||
update
|
||||
.push_simple_log("Post Update", format_serror(&e.into()));
|
||||
};
|
||||
} else {
|
||||
periphery_connections().remove(&updated.id).await;
|
||||
}
|
||||
update_cache_for_server(updated, true).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ import { HoverCard, HoverCardContent, HoverCardTrigger } from "@ui/hover-card";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
@@ -435,56 +434,54 @@ export const ServerComponents: RequiredResourceComponents = {
|
||||
if (!server?.info.attempted_public_key) return null;
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger disabled={!canWrite}>
|
||||
<Card className="px-3 py-2 bg-destructive/75 hover:bg-destructive transition-colors cursor-pointer">
|
||||
<div className="text-sm text-nowrap overflow-hidden overflow-ellipsis">
|
||||
Invalid Pubkey
|
||||
</div>
|
||||
</Card>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="w-[90vw] max-w-[700px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Confirm {server.name} public key?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Public Key: {server.info.attempted_public_key}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div></div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
className="w-[200px]"
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
mutate({
|
||||
id,
|
||||
config: {
|
||||
periphery_public_key:
|
||||
server.info.attempted_public_key,
|
||||
},
|
||||
})
|
||||
}
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : (
|
||||
"Confirm"
|
||||
)}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="grid gap-2">
|
||||
Core failed to validate Periphery public key.
|
||||
{canWrite ? " Click to validate." : ""}
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger disabled={!canWrite}>
|
||||
<Card
|
||||
className={cn(
|
||||
"px-3 py-2 bg-destructive/75 hover:bg-destructive transition-colors",
|
||||
canWrite && "cursor-pointer"
|
||||
)}
|
||||
>
|
||||
<div className="text-sm text-nowrap overflow-hidden overflow-ellipsis">
|
||||
Invalid Pubkey
|
||||
</div>
|
||||
</Card>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="w-[90vw] max-w-[700px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Confirm {server.name} public key?</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="text-muted-foreground text-sm">
|
||||
<div>
|
||||
Public Key: <span className="text-foreground">{server.info.attempted_public_key}</span>
|
||||
</div>
|
||||
{!server.info.address && (
|
||||
<div>Note. May take a few moments for status to update.</div>
|
||||
)}
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
className="w-[200px]"
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
mutate({
|
||||
id,
|
||||
config: {
|
||||
periphery_public_key: server.info.attempted_public_key,
|
||||
},
|
||||
})
|
||||
}
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : (
|
||||
"Confirm"
|
||||
)}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@ komodo_client.workspace = true
|
||||
pem-rfc7468.workspace = true
|
||||
serde_json.workspace = true
|
||||
colored.workspace = true
|
||||
tracing.workspace = true
|
||||
anyhow.workspace = true
|
||||
base64.workspace = true
|
||||
pkcs8.workspace = true
|
||||
|
||||
@@ -47,6 +47,7 @@ impl Pkcs8PrivateKey {
|
||||
path: P,
|
||||
) -> anyhow::Result<()> {
|
||||
let path = path.as_ref();
|
||||
tracing::info!("Writing private key to {path:?}");
|
||||
std::fs::write(path, self.as_pem()).with_context(|| {
|
||||
format!("Failed to write private key pem to {path:?}")
|
||||
})
|
||||
|
||||
@@ -48,6 +48,7 @@ impl SpkiPublicKey {
|
||||
path: P,
|
||||
) -> anyhow::Result<()> {
|
||||
let path = path.as_ref();
|
||||
tracing::info!("Writing public key to {path:?}");
|
||||
std::fs::write(path, self.as_pem()).with_context(|| {
|
||||
format!("Failed to write private key pem to {path:?}")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user