Skip to content

Commit

Permalink
Add Version Check
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryDodzin committed Feb 3, 2025
1 parent 06f5ac8 commit 2e2ccd7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 15 additions & 4 deletions mirrord/intproxy/src/agent_conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
net::{IpAddr, SocketAddr},
ops::ControlFlow,
path::{Path, PathBuf},
sync::Arc,
sync::{Arc, LazyLock},
};

use mirrord_analytics::{NullReporter, Reporter};
Expand All @@ -19,6 +19,7 @@ use mirrord_kube::{
};
use mirrord_operator::client::{error::OperatorApiError, OperatorApi, OperatorSession};
use mirrord_protocol::{ClientMessage, DaemonMessage};
use semver::VersionReq;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::{
Expand All @@ -42,6 +43,12 @@ use crate::{

mod portforward;

static OPERATOR_RETRY_VERSION: LazyLock<VersionReq> = LazyLock::new(|| {
">3.104.2"
.parse()
.expect("OPERATOR_RETRY_VERSION should be a valid VersionReq value")
});

/// Errors that can occur when the internal proxy tries to establish a connection with the agent.
#[derive(Error, Debug)]
pub enum AgentConnectionError {
Expand Down Expand Up @@ -141,9 +148,13 @@ impl AgentConnection {
(
connection.tx,
connection.rx,
ReconnectFlow::ConnectInfo {
config: config.clone(),
connect_info: AgentConnectInfo::Operator(session),
if OPERATOR_RETRY_VERSION.matches(&session.operator_version) {
ReconnectFlow::ConnectInfo {
config: config.clone(),
connect_info: AgentConnectInfo::Operator(session),
}
} else {
ReconnectFlow::default()
},
)
}
Expand Down
5 changes: 5 additions & 0 deletions mirrord/operator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pub struct OperatorSession {
/// Version of [`mirrord_protocol`] used by the operator.
/// Used to create [`ConnectionWrapper`].
pub operator_protocol_version: Option<Version>,

/// Version of the operator.
pub operator_version: Version,
}

impl fmt::Debug for OperatorSession {
Expand All @@ -126,6 +129,7 @@ impl fmt::Debug for OperatorSession {
&self.operator_license_fingerprint,
)
.field("operator_protocol_version", &self.operator_protocol_version)
.field("operator_version", &self.operator_version)
.finish()
}
}
Expand Down Expand Up @@ -662,6 +666,7 @@ impl OperatorApi<PreparedClientCert> {
.protocol_version
.as_ref()
.and_then(|version| version.parse().ok()),
operator_version: self.operator.spec.operator_version.clone(),
};

let mut connection_subtask = progress.subtask("connecting to the target");
Expand Down

0 comments on commit 2e2ccd7

Please sign in to comment.