cli: update dev tunnel sdk (#203763)
This commit is contained in:
Родитель
01a85f298b
Коммит
d7cfba7af7
|
@ -384,7 +384,7 @@ dependencies = [
|
|||
"url",
|
||||
"uuid",
|
||||
"winapi",
|
||||
"winreg",
|
||||
"winreg 0.50.0",
|
||||
"zbus",
|
||||
"zip",
|
||||
]
|
||||
|
@ -1594,6 +1594,16 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_info"
|
||||
version = "3.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e"
|
||||
dependencies = [
|
||||
"log",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.0.0"
|
||||
|
@ -1888,7 +1898,7 @@ dependencies = [
|
|||
"wasm-bindgen-futures",
|
||||
"wasm-streams",
|
||||
"web-sys",
|
||||
"winreg",
|
||||
"winreg 0.50.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2516,13 +2526,15 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "tunnels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/microsoft/dev-tunnels?rev=97233d20448e1c3cb0e0fd9114acf68c7e5c0249#97233d20448e1c3cb0e0fd9114acf68c7e5c0249"
|
||||
source = "git+https://github.com/microsoft/dev-tunnels?rev=c1bf1424846ce3a1297ed3be7b8401cef6904bee#c1bf1424846ce3a1297ed3be7b8401cef6904bee"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"futures",
|
||||
"hyper",
|
||||
"log",
|
||||
"os_info",
|
||||
"rand 0.8.5",
|
||||
"reqwest",
|
||||
"russh",
|
||||
"russh-keys",
|
||||
|
@ -2534,7 +2546,9 @@ dependencies = [
|
|||
"tokio-util",
|
||||
"tungstenite",
|
||||
"url",
|
||||
"urlencoding",
|
||||
"uuid",
|
||||
"winreg 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2599,9 +2613,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.2"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
|
@ -2987,6 +3001,15 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d107f8c6e916235c4c01cabb3e8acf7bea8ef6a63ca2e7fa0527c049badfc48c"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.50.0"
|
||||
|
|
|
@ -34,7 +34,7 @@ serde_bytes = "0.11.9"
|
|||
chrono = { version = "0.4.26", features = ["serde", "std", "clock"], default-features = false }
|
||||
gethostname = "0.4.3"
|
||||
libc = "0.2.144"
|
||||
tunnels = { git = "https://github.com/microsoft/dev-tunnels", rev = "97233d20448e1c3cb0e0fd9114acf68c7e5c0249", default-features = false, features = ["connections"] }
|
||||
tunnels = { git = "https://github.com/microsoft/dev-tunnels", rev = "c1bf1424846ce3a1297ed3be7b8401cef6904bee", default-features = false, features = ["connections"] }
|
||||
keyring = { version = "2.0.3", default-features = false, features = ["linux-secret-service-rt-tokio-crypto-openssl"] }
|
||||
dialoguer = "0.10.4"
|
||||
hyper = { version = "0.14.26", features = ["server", "http1", "runtime"] }
|
||||
|
|
|
@ -409,14 +409,14 @@ impl DevTunnels {
|
|||
}
|
||||
}?;
|
||||
|
||||
let desired_tags = self.get_tags(&name);
|
||||
if is_new || vec_eq_as_set(&full_tunnel.tags, &desired_tags) {
|
||||
let desired_tags = self.get_labels(&name);
|
||||
if is_new || vec_eq_as_set(&full_tunnel.labels, &desired_tags) {
|
||||
return Ok((full_tunnel, persisted));
|
||||
}
|
||||
|
||||
debug!(self.log, "Tunnel name changed, applying updates...");
|
||||
|
||||
full_tunnel.tags = desired_tags;
|
||||
full_tunnel.labels = desired_tags;
|
||||
|
||||
let updated_tunnel = spanf!(
|
||||
self.log,
|
||||
|
@ -531,7 +531,6 @@ impl DevTunnels {
|
|||
let fut = self.client.delete_tunnel_endpoints(
|
||||
&locator,
|
||||
&endpoint.host_id,
|
||||
None,
|
||||
NO_REQUEST_OPTIONS,
|
||||
);
|
||||
|
||||
|
@ -572,52 +571,51 @@ impl DevTunnels {
|
|||
)
|
||||
.map_err(|e| wrap(e, "failed to lookup tunnel"))?
|
||||
}
|
||||
None => {
|
||||
let new_tunnel = Tunnel {
|
||||
tags: self.get_tags(name),
|
||||
..Default::default()
|
||||
};
|
||||
None => loop {
|
||||
let result = spanf!(
|
||||
self.log,
|
||||
self.log.span("dev-tunnel.create"),
|
||||
self.client.create_tunnel(
|
||||
Tunnel {
|
||||
labels: self.get_labels(name),
|
||||
..Default::default()
|
||||
},
|
||||
options
|
||||
)
|
||||
);
|
||||
|
||||
loop {
|
||||
let result = spanf!(
|
||||
self.log,
|
||||
self.log.span("dev-tunnel.create"),
|
||||
self.client.create_tunnel(&new_tunnel, options)
|
||||
);
|
||||
|
||||
match result {
|
||||
Err(HttpError::ResponseError(e))
|
||||
if e.status_code == StatusCode::TOO_MANY_REQUESTS =>
|
||||
{
|
||||
if let Some(d) = e.get_details() {
|
||||
let detail = d.detail.unwrap_or_else(|| "unknown".to_string());
|
||||
if detail.contains(TUNNEL_COUNT_LIMIT_NAME)
|
||||
&& self.try_recycle_tunnel().await?
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return Err(AnyError::from(TunnelCreationFailed(
|
||||
name.to_string(),
|
||||
detail,
|
||||
)));
|
||||
match result {
|
||||
Err(HttpError::ResponseError(e))
|
||||
if e.status_code == StatusCode::TOO_MANY_REQUESTS =>
|
||||
{
|
||||
if let Some(d) = e.get_details() {
|
||||
let detail = d.detail.unwrap_or_else(|| "unknown".to_string());
|
||||
if detail.contains(TUNNEL_COUNT_LIMIT_NAME)
|
||||
&& self.try_recycle_tunnel().await?
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return Err(AnyError::from(TunnelCreationFailed(
|
||||
name.to_string(),
|
||||
"You have exceeded a limit for the port fowarding service. Please remove other machines before trying to add this machine.".to_string(),
|
||||
detail,
|
||||
)));
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(AnyError::from(TunnelCreationFailed(
|
||||
|
||||
return Err(AnyError::from(TunnelCreationFailed(
|
||||
name.to_string(),
|
||||
format!("{:?}", e),
|
||||
)))
|
||||
}
|
||||
Ok(t) => break t,
|
||||
"You have exceeded a limit for the port fowarding service. Please remove other machines before trying to add this machine.".to_string(),
|
||||
)));
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(AnyError::from(TunnelCreationFailed(
|
||||
name.to_string(),
|
||||
format!("{:?}", e),
|
||||
)))
|
||||
}
|
||||
Ok(t) => break t,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let pt = PersistedTunnel {
|
||||
|
@ -631,7 +629,7 @@ impl DevTunnels {
|
|||
}
|
||||
|
||||
/// Gets the expected tunnel tags
|
||||
fn get_tags(&self, name: &str) -> Vec<String> {
|
||||
fn get_labels(&self, name: &str) -> Vec<String> {
|
||||
vec![
|
||||
name.to_string(),
|
||||
PROTOCOL_VERSION_TAG.to_string(),
|
||||
|
@ -649,20 +647,20 @@ impl DevTunnels {
|
|||
tunnel: Tunnel,
|
||||
options: &TunnelRequestOptions,
|
||||
) -> Result<Tunnel, AnyError> {
|
||||
let new_tags = self.get_tags(name);
|
||||
if vec_eq_as_set(&tunnel.tags, &new_tags) {
|
||||
let new_labels = self.get_labels(name);
|
||||
if vec_eq_as_set(&tunnel.labels, &new_labels) {
|
||||
return Ok(tunnel);
|
||||
}
|
||||
|
||||
debug!(
|
||||
self.log,
|
||||
"Updating tunnel tags {} -> {}",
|
||||
tunnel.tags.join(", "),
|
||||
new_tags.join(", ")
|
||||
tunnel.labels.join(", "),
|
||||
new_labels.join(", ")
|
||||
);
|
||||
|
||||
let tunnel_update = Tunnel {
|
||||
tags: new_tags,
|
||||
labels: new_labels,
|
||||
tunnel_id: tunnel.tunnel_id.clone(),
|
||||
cluster_id: tunnel.cluster_id.clone(),
|
||||
..Default::default()
|
||||
|
@ -725,7 +723,7 @@ impl DevTunnels {
|
|||
self.log,
|
||||
self.log.span("dev-tunnel.listall"),
|
||||
self.client.list_all_tunnels(&TunnelRequestOptions {
|
||||
tags: tags.iter().map(|t| t.to_string()).collect(),
|
||||
labels: tags.iter().map(|t| t.to_string()).collect(),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
|
@ -739,8 +737,8 @@ impl DevTunnels {
|
|||
self.log,
|
||||
self.log.span("dev-tunnel.rename.search"),
|
||||
self.client.list_all_tunnels(&TunnelRequestOptions {
|
||||
tags: vec![self.tag.to_string(), name.to_string()],
|
||||
require_all_tags: true,
|
||||
labels: vec![self.tag.to_string(), name.to_string()],
|
||||
require_all_labels: true,
|
||||
limit: 1,
|
||||
include_ports: true,
|
||||
token_scopes: vec!["host".to_string()],
|
||||
|
@ -770,7 +768,7 @@ impl DevTunnels {
|
|||
v.status
|
||||
.as_ref()
|
||||
.and_then(|s| s.host_connection_count.as_ref().map(|c| c.get_count()))
|
||||
.unwrap_or(0) > 0 && v.tags.iter().any(|t| t == n)
|
||||
.unwrap_or(0) > 0 && v.labels.iter().any(|t| t == n)
|
||||
})
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче