-
Notifications
You must be signed in to change notification settings - Fork 130
Retrying compartmentless containers #1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: experimental-windows-ambient
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ use std::sync::RwLock; | |
#[derive(Debug, Serialize, Deserialize, Clone, Copy)] | ||
pub enum State { | ||
Pending, | ||
WaitingCompartment, | ||
Up, | ||
} | ||
|
||
|
@@ -61,23 +62,43 @@ pub struct WorkloadManagerAdminHandler { | |
} | ||
|
||
impl WorkloadManagerAdminHandler { | ||
pub fn proxy_pending( | ||
pub fn proxy_pending(&self, uid: &crate::inpod::WorkloadUid, workload_info: &WorkloadInfo) { | ||
let mut state = self.state.write().unwrap(); | ||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to merge these? |
||
|
||
// don't increment count here, as it is only for up and down. see comment in count. | ||
match state.get_mut(uid) { | ||
Some(key) => { | ||
key.state = State::Pending; | ||
} | ||
None => { | ||
state.insert( | ||
uid.clone(), | ||
ProxyState { | ||
state: State::Pending, | ||
connections: None, | ||
count: 0, | ||
info: workload_info.clone(), | ||
}, | ||
); | ||
} | ||
} | ||
} | ||
pub fn proxy_waiting_compartment( | ||
&self, | ||
uid: &crate::inpod::WorkloadUid, | ||
workload_info: &WorkloadInfo, | ||
) { | ||
let mut state = self.state.write().unwrap(); | ||
|
||
// don't increment count here, as it is only for up and down. see comment in count. | ||
match state.get_mut(uid) { | ||
Some(key) => { | ||
key.state = State::Pending; | ||
key.state = State::WaitingCompartment; | ||
} | ||
None => { | ||
state.insert( | ||
uid.clone(), | ||
ProxyState { | ||
state: State::Pending, | ||
state: State::WaitingCompartment, | ||
connections: None, | ||
count: 0, | ||
info: workload_info.clone(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
|
||
use crate::inpod::windows::namespace::InpodNamespace; | ||
use crate::inpod::windows::namespace::NetworkNamespace; | ||
use crate::proxy::DefaultSocketFactory; | ||
use crate::{config, socket}; | ||
|
||
|
@@ -36,14 +34,14 @@ impl InPodConfig { | |
..cfg.socket_config | ||
}; | ||
Ok(InPodConfig { | ||
cur_namespace: InpodNamespace::current()?, | ||
cur_namespace: NetworkNamespace::current()?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the rename? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, the current naming makes no distiction between the specific namespace. Does this rename add value? |
||
reuse_port: cfg.inpod_port_reuse, | ||
socket_config, | ||
}) | ||
} | ||
pub fn socket_factory( | ||
&self, | ||
netns: InpodNamespace, | ||
netns: NetworkNamespace, | ||
) -> Box<dyn crate::proxy::SocketFactory + Send + Sync> { | ||
let base = crate::proxy::DefaultSocketFactory(self.socket_config); | ||
let sf = InPodSocketFactory::from_cfg(base, self, netns); | ||
|
@@ -62,14 +60,14 @@ impl InPodConfig { | |
|
||
struct InPodSocketFactory { | ||
inner: DefaultSocketFactory, | ||
netns: InpodNamespace, | ||
netns: NetworkNamespace, | ||
} | ||
impl InPodSocketFactory { | ||
fn from_cfg(inner: DefaultSocketFactory, _: &InPodConfig, netns: InpodNamespace) -> Self { | ||
fn from_cfg(inner: DefaultSocketFactory, _: &InPodConfig, netns: NetworkNamespace) -> Self { | ||
Self::new(inner, netns) | ||
} | ||
fn new(inner: DefaultSocketFactory,netns: InpodNamespace) -> Self { | ||
Self {inner, netns } | ||
fn new(inner: DefaultSocketFactory, netns: NetworkNamespace) -> Self { | ||
Self { inner, netns } | ||
} | ||
|
||
fn run_in_ns<S, F: FnOnce() -> std::io::Result<S>>(&self, f: F) -> std::io::Result<S> { | ||
|
@@ -96,7 +94,7 @@ impl crate::proxy::SocketFactory for InPodSocketFactory { | |
} | ||
|
||
fn tcp_bind(&self, addr: std::net::SocketAddr) -> std::io::Result<socket::Listener> { | ||
let std_sock = self.configure( || std::net::TcpListener::bind(addr))?; | ||
let std_sock = self.configure(|| std::net::TcpListener::bind(addr))?; | ||
std_sock.set_nonblocking(true)?; | ||
tokio::net::TcpListener::from_std(std_sock).map(socket::Listener::new) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want to clone this?