mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
fix(managed-server): keep the tunnel manager under its line limit after #30888 and #30891 crossed (#30933)
The build's same-pairing check moves next to managedTunnelAccess, which it already wraps.
This commit is contained in:
@@ -54,6 +54,20 @@ export function managedTunnelAccess(
|
||||
: null
|
||||
}
|
||||
|
||||
/** The build's environment is still the same pairing, with an SSH tunnel it may use. */
|
||||
export function managedTunnelStillPaired(
|
||||
built: KnownRuntimeEnvironment,
|
||||
current: KnownRuntimeEnvironment | null,
|
||||
target: SshTarget | null | undefined,
|
||||
expected: ManagedTunnelExpectation
|
||||
): boolean {
|
||||
return (
|
||||
current?.runtimeId === built.runtimeId &&
|
||||
(current.pairingRevision ?? current.createdAt) === (built.pairingRevision ?? built.createdAt) &&
|
||||
managedTunnelAccess(current, target, expected) !== null
|
||||
)
|
||||
}
|
||||
|
||||
/** The SSH target and transport a managed environment's tunnel must use, or why it cannot. */
|
||||
export function resolveManagedTunnelBinding(
|
||||
environment: KnownRuntimeEnvironment,
|
||||
|
||||
@@ -22,7 +22,7 @@ import type { OrcadManagedServing } from './orcad-managed-serving'
|
||||
import {
|
||||
activeTunnelMatches,
|
||||
dropActiveOrcadTunnel,
|
||||
managedTunnelAccess,
|
||||
managedTunnelStillPaired,
|
||||
recordActiveOrcadTunnel,
|
||||
resolveManagedTunnelBinding,
|
||||
supersededTunnelError,
|
||||
@@ -260,17 +260,15 @@ export class OrcadManagedTunnelManager {
|
||||
const managerGeneration = this.managerGeneration
|
||||
const ownershipGeneration = this.ownershipGenerations.get(environment.id) ?? 0
|
||||
const expected = { environmentId: environment.id, ...deployment }
|
||||
const stillOwned = (): boolean => {
|
||||
const currentEnvironment = resolveCurrent()
|
||||
return (
|
||||
this.managerGeneration === managerGeneration &&
|
||||
(this.ownershipGenerations.get(environment.id) ?? 0) === ownershipGeneration &&
|
||||
currentEnvironment?.runtimeId === environment.runtimeId &&
|
||||
(currentEnvironment.pairingRevision ?? currentEnvironment.createdAt) ===
|
||||
(environment.pairingRevision ?? environment.createdAt) &&
|
||||
managedTunnelAccess(currentEnvironment, targetStore.getTarget(target.id), expected) !== null
|
||||
const stillOwned = (): boolean =>
|
||||
this.managerGeneration === managerGeneration &&
|
||||
(this.ownershipGenerations.get(environment.id) ?? 0) === ownershipGeneration &&
|
||||
managedTunnelStillPaired(
|
||||
environment,
|
||||
resolveCurrent(),
|
||||
targetStore.getTarget(target.id),
|
||||
expected
|
||||
)
|
||||
}
|
||||
const connection = await connectionManager.connect(target)
|
||||
if (!stillOwned()) {
|
||||
throw supersededTunnelError()
|
||||
|
||||
Reference in New Issue
Block a user