Skip to content

Commit e737496

Browse files
authored
Fix broken --remote-port parsing and add --no-remote-ports flag (#4537)
1 parent aa1749d commit e737496

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

cli/src/commands/cloud/environments/tunnel/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ pub struct Tunnel {
3939

4040
/// Remote port on the Environment to expose on localhost
4141
/// This argument can be repeated to specify multiple remote ports
42-
#[clap(short = 'r', long, action = clap::ArgAction::Append)]
42+
#[clap(short = 'r', long, action = clap::ArgAction::Append, conflicts_with = "no_remote_ports")]
4343
remote_port: Vec<remote::RemotePort>,
4444

45+
/// Disable proxying remote Environment ports to localhost
46+
#[clap(long)]
47+
no_remote_ports: bool,
48+
4549
/// A name for the tunnel; a random name will be generated if not provided
4650
#[clap(long = "tunnel-name")]
4751
tunnel_name: Option<String>,
@@ -82,7 +86,7 @@ pub async fn run_tunnel(State(env): State<CliEnv>, opts: &Tunnel) -> Result<()>
8286
};
8387

8488
let mut opts = opts.clone();
85-
if opts.remote_port.is_empty() {
89+
if !opts.no_remote_ports && opts.remote_port.is_empty() {
8690
opts.remote_port = vec![RemotePort::Ingress, RemotePort::Admin];
8791
}
8892

cli/src/commands/cloud/environments/tunnel/remote.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ impl ValueEnum for RemotePort {
3030
}
3131

3232
fn to_possible_value(&self) -> Option<builder::PossibleValue> {
33-
Some(builder::PossibleValue::new(match self {
34-
Self::Ingress => HttpIngressPort::default_port_str(),
35-
Self::Admin => AdminPort::default_port_str(),
36-
}))
33+
Some(match self {
34+
Self::Ingress => builder::PossibleValue::new(HttpIngressPort::default_port_str())
35+
.help("Ingress HTTP port"),
36+
Self::Admin => {
37+
builder::PossibleValue::new(AdminPort::default_port_str()).help("Admin API port")
38+
}
39+
})
3740
}
3841
}
3942

crates/types/src/net/address.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ pub trait ListenerPort: Clone + PartialEq + Eq {
2626
/// Whether this port allows binding on an anonymous unix-socket or not.
2727
const IS_ANONYMOUS_UDS_ALLOWED: bool;
2828

29-
fn default_port_str() -> &'static str {
30-
stringify!(Self::DEFAULT_PORT)
31-
}
29+
fn default_port_str() -> &'static str;
3230
}
3331

3432
/// Implemented on ports that support gRPC protocol
@@ -48,6 +46,9 @@ impl ListenerPort for HttpIngressPort {
4846
const DEFAULT_PORT: u16 = 8080;
4947
const UDS_NAME: &'static str = "ingress.sock";
5048
const IS_ANONYMOUS_UDS_ALLOWED: bool = true;
49+
fn default_port_str() -> &'static str {
50+
"8080"
51+
}
5152
}
5253

5354
/// Admin HTTP Service 9070
@@ -60,6 +61,9 @@ impl ListenerPort for AdminPort {
6061
const DEFAULT_PORT: u16 = 9070;
6162
const UDS_NAME: &'static str = "admin.sock";
6263
const IS_ANONYMOUS_UDS_ALLOWED: bool = true;
64+
fn default_port_str() -> &'static str {
65+
"9070"
66+
}
6367
}
6468

6569
/// gRPC port for control and introspection
@@ -72,6 +76,9 @@ impl ListenerPort for ControlPort {
7276
const DEFAULT_PORT: u16 = 5122;
7377
const UDS_NAME: &'static str = "control.sock";
7478
const IS_ANONYMOUS_UDS_ALLOWED: bool = true;
79+
fn default_port_str() -> &'static str {
80+
"5122"
81+
}
7582
}
7683
impl GrpcPort for ControlPort {}
7784

@@ -86,6 +93,9 @@ impl ListenerPort for FabricPort {
8693
// this is disallowed for the message fabric since we must be able to acquire a
8794
// non-anonymous socket address to allow server-to-server communication.
8895
const IS_ANONYMOUS_UDS_ALLOWED: bool = false;
96+
fn default_port_str() -> &'static str {
97+
"5122"
98+
}
8999
}
90100
impl GrpcPort for FabricPort {}
91101

@@ -97,6 +107,9 @@ impl ListenerPort for TokioConsolePort {
97107
const DEFAULT_PORT: u16 = 6669;
98108
const UDS_NAME: &'static str = "tokio.sock";
99109
const IS_ANONYMOUS_UDS_ALLOWED: bool = false;
110+
fn default_port_str() -> &'static str {
111+
"6669"
112+
}
100113
}
101114

102115
#[derive(Debug, Clone, Eq, PartialEq, Hash, derive_more::Display)]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# CLI: Fix `--remote-port` in `restate cloud env tunnel`
2+
3+
## Bug Fix
4+
5+
### What Changed
6+
7+
`--remote-port` was completely broken — it rejected all input and displayed `[possible values: Self::DEFAULT_PORT, Self::DEFAULT_PORT]`. It now correctly accepts `8080` (ingress) and `9070` (admin).
8+
9+
A new `--no-remote-ports` flag has been added to disable environment port proxying while keeping only the inbound tunnel direction.

0 commit comments

Comments
 (0)