mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
fix(console): don't replay history when attaching to the console
This commit is contained in:
parent
694de5d1fd
commit
b994bc1515
@ -23,7 +23,7 @@ impl ZoneAttachCommand {
|
||||
events: EventStream,
|
||||
) -> Result<()> {
|
||||
let zone_id: String = resolve_zone(&mut client, &self.zone).await?;
|
||||
let input = StdioConsoleStream::stdin_stream(zone_id.clone()).await;
|
||||
let input = StdioConsoleStream::stdin_stream(zone_id.clone(), false).await;
|
||||
let output = client.attach_zone_console(input).await?.into_inner();
|
||||
let stdout_handle =
|
||||
tokio::task::spawn(async move { StdioConsoleStream::stdout(output, true).await });
|
||||
|
@ -187,7 +187,7 @@ impl ZoneLaunchCommand {
|
||||
}
|
||||
|
||||
let code = if self.attach {
|
||||
let input = StdioConsoleStream::stdin_stream(id.clone()).await;
|
||||
let input = StdioConsoleStream::stdin_stream(id.clone(), true).await;
|
||||
let output = client.attach_zone_console(input).await?.into_inner();
|
||||
let stdout_handle =
|
||||
tokio::task::spawn(async move { StdioConsoleStream::stdout(output, true).await });
|
||||
|
@ -33,7 +33,7 @@ impl ZoneLogsCommand {
|
||||
let zone_id_stream = zone_id.clone();
|
||||
let follow = self.follow;
|
||||
let input = stream! {
|
||||
yield ZoneConsoleRequest { zone_id: zone_id_stream, data: Vec::new() };
|
||||
yield ZoneConsoleRequest { zone_id: zone_id_stream, replay_history: true, data: Vec::new() };
|
||||
if follow {
|
||||
let mut pending = pending::<ZoneConsoleRequest>();
|
||||
while let Some(x) = pending.next().await {
|
||||
|
@ -23,10 +23,13 @@ use tonic::Streaming;
|
||||
pub struct StdioConsoleStream;
|
||||
|
||||
impl StdioConsoleStream {
|
||||
pub async fn stdin_stream(zone: String) -> impl Stream<Item = ZoneConsoleRequest> {
|
||||
pub async fn stdin_stream(
|
||||
zone: String,
|
||||
replay_history: bool,
|
||||
) -> impl Stream<Item = ZoneConsoleRequest> {
|
||||
let mut stdin = stdin();
|
||||
stream! {
|
||||
yield ZoneConsoleRequest { zone_id: zone, data: vec![] };
|
||||
yield ZoneConsoleRequest { zone_id: zone, replay_history, data: vec![] };
|
||||
|
||||
let mut buffer = vec![0u8; 60];
|
||||
loop {
|
||||
@ -41,7 +44,7 @@ impl StdioConsoleStream {
|
||||
if size == 1 && buffer[0] == 0x1d {
|
||||
break;
|
||||
}
|
||||
yield ZoneConsoleRequest { zone_id: String::default(), data };
|
||||
yield ZoneConsoleRequest { zone_id: String::default(), replay_history, data };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,9 @@ impl AttachZoneConsoleRpc {
|
||||
.map_err(|error| anyhow!("failed to attach to console: {}", error))?;
|
||||
|
||||
let output = try_stream! {
|
||||
yield ZoneConsoleReply { data: console.initial.clone(), };
|
||||
if request.replay_history {
|
||||
yield ZoneConsoleReply { data: console.initial.clone(), };
|
||||
}
|
||||
loop {
|
||||
let what = select! {
|
||||
x = receiver.recv() => ConsoleDataSelect::Read(x),
|
||||
|
@ -104,6 +104,7 @@ message ExecInsideZoneReply {
|
||||
message ZoneConsoleRequest {
|
||||
string zone_id = 1;
|
||||
bytes data = 2;
|
||||
bool replay_history = 3;
|
||||
}
|
||||
|
||||
message ZoneConsoleReply {
|
||||
|
Loading…
Reference in New Issue
Block a user