pub struct Manager { /* private fields */ }Expand description
Implements the mirror reloader.
Implementations§
Source§impl Manager
impl Manager
Sourcepub fn prepare_copies(
&self,
targets: &[Target],
copy_image: &str,
) -> Result<Vec<CopyInfo>, CopyError>
pub fn prepare_copies( &self, targets: &[Target], copy_image: &str, ) -> Result<Vec<CopyInfo>, CopyError>
Scales down original deployments and creates -caproni copies
for the given targets. Skips unsupported resource types.
Callers are responsible for passing a deduplicated, pre-merged
target list; in practice, callers should use
collect_and_validate_targets to produce it. Returns a list
of CopyInfo for cleanup operations.
§Errors
Returns CopyError if scaling down, fetching, modifying, or
applying a copy fails for any target.
Source§impl Manager
impl Manager
Sourcepub fn new(kubectl_backend: Box<dyn KubectlBackend + Send + Sync>) -> Self
pub fn new(kubectl_backend: Box<dyn KubectlBackend + Send + Sync>) -> Self
Creates a new mirror reloader manager.
Sourcepub fn reloader_type(&self) -> &'static str
pub fn reloader_type(&self) -> &'static str
Returns the reloader type identifier ("mirror").
Sourcepub fn check_preconditions(
&self,
executor: &dyn CommandRunner,
reloader_config: &ReloaderConfig,
_caproni_config: &CaproniConfig,
get_tool_version: &dyn Fn(&str) -> Option<String>,
) -> Result<(), MirrorError>
pub fn check_preconditions( &self, executor: &dyn CommandRunner, reloader_config: &ReloaderConfig, _caproni_config: &CaproniConfig, get_tool_version: &dyn Fn(&str) -> Option<String>, ) -> Result<(), MirrorError>
Verifies mirrord version meets minimum requirements and that no
stale -caproni copy exists for this reloader’s target.
executor is threaded explicitly rather than read off an
ambient context, unlike the Go original’s executor.FromContext:
xianyun_executor::exec::context::{from_context, with_context}
are themselves unimplemented stubs in a sibling crate outside
this task’s scope, so this port takes the CommandRunner
directly as a parameter instead of threading it through a
context object. See PORT_NOTES.md.
§Errors
Returns MirrorError::MirrordVersionTooOld if the installed
mirrord version is below the configured minimum, or
MirrorError::CaproniDeploymentsExist if a stale -caproni
copy of the target already exists.
Sourcepub fn run(
&self,
executor: &dyn CommandRunner,
reloader_config: &ReloaderConfig,
caproni_config: &CaproniConfig,
kubeconfig_path: &str,
) -> Result<(), MirrorError>
pub fn run( &self, executor: &dyn CommandRunner, reloader_config: &ReloaderConfig, caproni_config: &CaproniConfig, kubeconfig_path: &str, ) -> Result<(), MirrorError>
Runs the mirror reloader, blocking until the context is
cancelled. Deployment copies must be prepared by the caller
before run is invoked (see
Manager::cleanup_copy_deployments).
This method:
- Generates a mirrord configuration file
- Starts
caproni edit-mode-process-supervisorwrapped in mirrord - Runs processes tagged
context: localoutside mirrord
kubeconfig_path is the path to a temporary kubeconfig for the
caproni-selected cluster (created and owned by the caller).
Implementations that launch external tooling pin KUBECONFIG to
it rather than relying on the user’s global current-context. It
may be empty.
§Errors
Returns MirrorError if the config is invalid, no repository
is configured, the mirrord config cannot be generated, or the
underlying process supervision fails.
Sourcepub fn prepare_from_reloader_configs(
&self,
reloaders: &HashMap<String, ReloaderConfig>,
copy_sleep_image: &str,
) -> Result<Vec<CopyInfo>, MirrorError>
pub fn prepare_from_reloader_configs( &self, reloaders: &HashMap<String, ReloaderConfig>, copy_sleep_image: &str, ) -> Result<Vec<CopyInfo>, MirrorError>
Collects and validates mirror targets from the given reloader configs, then prepares a coordinated set of deployment copies. Returns an empty list if there are no mirror targets.
§Errors
Returns MirrorError::ValidatingTargets if the targets
conflict, or MirrorError::Copy if preparing a copy fails.
Sourcepub fn cleanup_copy_deployments(&self, deployments: &[CopyInfo])
pub fn cleanup_copy_deployments(&self, deployments: &[CopyInfo])
Deletes all -caproni deployment copies and scales the
originals back up. Cleanup failures are logged, not returned:
the caller is typically shutting down and cannot act on them.
Sourcepub fn status(
&self,
reloader_config: &ReloaderConfig,
_caproni_config: &CaproniConfig,
) -> Result<Status, MirrorError>
pub fn status( &self, reloader_config: &ReloaderConfig, _caproni_config: &CaproniConfig, ) -> Result<Status, MirrorError>
Returns the current status of the reloader.
§Errors
Returns MirrorError if the config is not a mirror reloader
or has no target configured.
Sourcepub fn cleanup_stale_mirrord_agents(&self, namespace: &str)
pub fn cleanup_stale_mirrord_agents(&self, namespace: &str)
Removes leftover mirrord agent pods that may cause “Detected dirty iptables” errors on subsequent runs. This must be called once before any reloaders are started, not per-reloader, to avoid killing a live agent belonging to a concurrently running reloader. Failures are logged, not returned: this cleanup is best-effort.
Sourcepub fn validate(
&self,
reloader_config: &ReloaderConfig,
caproni_config: &CaproniConfig,
) -> Result<(), MirrorError>
pub fn validate( &self, reloader_config: &ReloaderConfig, caproni_config: &CaproniConfig, ) -> Result<(), MirrorError>
Validates the mirror reloader configuration. Mirror reloaders don’t have file path dependencies, so this primarily validates the configuration structure.
§Errors
Returns MirrorError if the config is not a mirror reloader,
has no target or referenced repository configured, or any
edit-mode process has an empty command.
Auto Trait Implementations§
impl !RefUnwindSafe for Manager
impl !UnwindSafe for Manager
impl Freeze for Manager
impl Send for Manager
impl Sync for Manager
impl Unpin for Manager
impl UnsafeUnpin for Manager
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more