Skip to content

Commit

Permalink
Port lock check removed (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 authored May 29, 2024
1 parent e8efeda commit 9a6541f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
1 change: 1 addition & 0 deletions changelog.d/+concurrent-steal.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where two mirrord sessions could not target the same pod while stealing from different ports.
32 changes: 0 additions & 32 deletions mirrord/operator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,44 +501,12 @@ impl OperatorApi {
}
}

/// Checks that there are no active port locks on the given target.
#[tracing::instrument(level = "trace", skip(self))]
async fn check_no_port_locks(&self, target: &TargetCrd) -> Result<()> {
let Ok(lock_target) = self
.target_api
.get_subresource("port-locks", &target.name())
.await
else {
return Ok(());
};

let no_port_locks = lock_target
.spec
.port_locks
.as_ref()
.map(Vec::is_empty)
.unwrap_or(true);

if no_port_locks {
Ok(())
} else {
Err(OperatorApiError::ConcurrentStealAbort)
}
}

/// Create websocket connection to operator.
#[tracing::instrument(level = "trace", skip(self))]
async fn connect_target(
&self,
session_info: OperatorSessionInformation,
) -> Result<OperatorSessionConnection> {
// why are we checking on client side..?
if let (ConcurrentSteal::Abort, OperatorSessionTarget::Raw(target)) =
(self.on_concurrent_steal, &session_info.target)
{
self.check_no_port_locks(target).await?;
}

let UserIdentity { name, hostname } = UserIdentity::load();

let request = {
Expand Down
1 change: 1 addition & 0 deletions mirrord/operator/src/crd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub const TARGETLESS_TARGET_NAME: &str = "targetless";
pub struct TargetSpec {
/// None when targetless.
pub target: Option<Target>,
#[deprecated = "port locks are enforced only in the operator, new operator versions always return an empty list"]
pub port_locks: Option<Vec<TargetPortLock>>,
}

Expand Down

0 comments on commit 9a6541f

Please sign in to comment.