Skip to content

Commit

Permalink
mirrord container port-publish warning (#2915)
Browse files Browse the repository at this point in the history
* mirrord container port-publish augmentation

* support -p in user command with when used with `--`

* Only Warn

* ..
  • Loading branch information
DmitryDodzin authored Nov 18, 2024
1 parent 20bd12f commit 06b81a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/+mirrord-container-publish.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Print a warning to the user when `-p` is provided as part of `mirrord container` run command that it may cause an issue because of our usage of container type network mode.
12 changes: 12 additions & 0 deletions mirrord/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,18 @@ impl ContainerCommand {
runtime_args: runtime_args.into_iter().map(T::into).collect(),
}
}

pub fn has_publish(&self) -> bool {
let ContainerCommand::Run { runtime_args } = self;

let mut hit_trailing_token = false;

runtime_args.iter().any(|runtime_arg| {
hit_trailing_token = hit_trailing_token || runtime_arg == "--";

!hit_trailing_token && matches!(runtime_arg.as_str(), "-p" | "--publish")
})
}
}

#[derive(Args, Debug)]
Expand Down
4 changes: 4 additions & 0 deletions mirrord/cli/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ pub(crate) async fn container_command(
) -> CliResult<()> {
let progress = ProgressTracker::from_env("mirrord container");

if runtime_args.command.has_publish() {
progress.warning("mirrord container may have problems with \"-p\" directly container in command, please add to \"contanier.cli_extra_args\" in config if you are planning to publish ports");
}

progress.warning("mirrord container is currently an unstable feature");

for (name, value) in exec_params.as_env_vars()? {
Expand Down

0 comments on commit 06b81a4

Please sign in to comment.