diff --git a/mirrord/operator/src/client.rs b/mirrord/operator/src/client.rs index def735c61a2..8d35d11966f 100644 --- a/mirrord/operator/src/client.rs +++ b/mirrord/operator/src/client.rs @@ -285,9 +285,14 @@ impl OperatorApi { } version_progress.success(None); - let raw_target = operator_api.fetch_target().await?; - let target_to_connect = if config.feature.copy_target.enabled { + let target_name = &operator_api.target_config.path; + let target = target_name + .as_ref() + .ok_or_else(|| OperatorApiError::InvalidTarget { + reason: "copy target feature is enabled, but target is not set".into(), + })?; + let mut copy_progress = progress.subtask("copying target"); if config.feature.copy_target.scale_down { @@ -300,12 +305,17 @@ impl OperatorApi { } let copied = operator_api - .copy_target(&metadata, raw_target, config.feature.copy_target.scale_down) + .copy_target( + &metadata, + target.clone(), + config.feature.copy_target.scale_down, + ) .await?; copy_progress.success(None); OperatorSessionTarget::Copied(copied) } else { + let raw_target = operator_api.fetch_target().await?; OperatorSessionTarget::Raw(raw_target) }; @@ -537,21 +547,13 @@ impl OperatorApi { async fn copy_target( &self, session_metadata: &OperatorSessionMetadata, - target: TargetCrd, + target: Target, scale_down: bool, ) -> Result { - let raw_target = target - .spec - .target - .clone() - .ok_or(OperatorApiError::InvalidTarget { - reason: "copy target feature is not compatible with targetless mode".into(), - })?; - let requested = CopyTargetCrd::new( - &target.name(), + &TargetCrd::target_name(&target), CopyTargetSpec { - target: raw_target, + target: target, idle_ttl: Some(Self::COPIED_POD_IDLE_TTL), scale_down, },