Skip to main content

OverlayManager

Struct OverlayManager 

Source
pub struct OverlayManager { /* private fields */ }
Expand description

Manages overlay networks for a deployment

Implementations§

Source§

impl OverlayManager

Source

pub async fn new(deployment: String) -> Result<Self, AgentError>

Create a new overlay manager for a deployment (legacy single-node path).

This constructor hands out container IPs from the full default cluster /16 (10.200.0.0/16). In multi-node deployments every node’s agent would then independently allocate from the same flat range, producing IP collisions. Prefer OverlayManager::with_slice for cluster deployments so the agent is bounded to a per-node slice assigned by the leader’s NodeSliceAllocator.

§Errors

Returns an error if the overlay manager cannot be initialized.

§Panics

Panics if the default CIDR 10.200.0.0/16 cannot be parsed (this is a compile-time constant).

Source

pub fn with_slice( deployment: String, cluster_cidr: IpNetwork, slice_cidr: IpNetwork, port: u16, ) -> Self

Create an OverlayManager bound to a per-node slice.

slice_cidr is a /28 (or whatever the cluster’s slice prefix is) owned by this node, assigned by the leader’s NodeSliceAllocator. The internal IpAllocator is bounded to this slice so container IPs never collide across nodes.

cluster_cidr is the full cluster CIDR (e.g. 10.200.0.0/16), kept for configuration / logging purposes. The allocator itself only uses slice_cidr.

Source

pub fn with_overlay_port(self, port: u16) -> Self

Set the WireGuard listen port for the overlay network.

Source

pub fn set_dns_config( &mut self, addr: Option<SocketAddr>, domain: Option<String>, )

Record the overlay DNS server address and zone domain so attaches can propagate them to HCN endpoint schemas (Windows) and future per-container DNS plumbing (Linux /etc/resolv.conf).

addr is the socket address the overlay hickory DNS server is listening on (typically overlay_ip:15353). domain is the DNS zone (e.g. "overlay.local"). Either may be omitted independently.

Source

pub fn with_dns_config( self, addr: Option<SocketAddr>, domain: Option<String>, ) -> Self

Builder-style variant of OverlayManager::set_dns_config.

Source

pub fn dns_server_addr(&self) -> Option<SocketAddr>

Returns the overlay DNS server address if the daemon bootstrapped one.

Source

pub fn dns_domain(&self) -> Option<&str>

Returns the overlay DNS zone domain, if configured.

Source

pub async fn setup_global_overlay(&mut self) -> Result<(), AgentError>

Setup the global overlay network for the deployment

§Errors

Returns an error if key generation or interface creation fails.

Source

pub async fn setup_service_overlay( &self, service_name: &str, ) -> Result<String, AgentError>

Setup a service-scoped overlay network

§Errors

Returns an error if the overlay interface cannot be created.

Source

pub async fn attach_container( &self, container_pid: u32, service_name: &str, join_global: bool, ) -> Result<IpAddr, AgentError>

Add a container to the appropriate overlay networks.

On non-Linux platforms this is a no-op: per-container overlay attachment relies on Linux network namespaces (veth pairs + nsenter). On macOS, containers share the host network, so the node’s overlay IP is returned directly and the proxy differentiates traffic by port.

§Errors

Returns an error if the container cannot be attached to the overlay network.

Source

pub async fn teardown_service_overlay(&self, service_name: &str)

Tear down the overlay network for a single service.

Removes the service’s TUN transport (destroying the interface) and clears its entry from the interface tracking map. This is safe to call even if no overlay was created for the service (it will be a no-op).

Source

pub async fn cleanup(&mut self) -> Result<(), AgentError>

Cleanup all overlay networks

§Errors

Returns an error if cleanup operations fail.

Source

pub fn node_ip(&self) -> Option<IpAddr>

Returns this node’s IP on the global overlay network, if available.

This is set after [setup_global_overlay] completes successfully.

Source

pub fn deployment(&self) -> &str

Returns the deployment name this overlay manager was created for.

Source

pub fn global_interface(&self) -> Option<&str>

Returns the global overlay interface name, if one has been created.

Source

pub fn overlay_port(&self) -> u16

Returns the WireGuard listen port for the overlay network.

Source

pub fn has_global_transport(&self) -> bool

Returns true if the global overlay transport is active.

Source

pub async fn service_transport_count(&self) -> usize

Returns the number of service-specific overlay transports currently active.

Source

pub fn overlay_cidr(&self) -> String

Returns the CIDR string for the overlay IP allocator.

Source

pub fn slice_cidr(&self) -> Option<IpNetwork>

Returns the per-node slice CIDR this manager was built with, or None if the legacy OverlayManager::new constructor was used.

Source

pub fn cluster_cidr(&self) -> Option<IpNetwork>

Returns the full cluster CIDR, if this manager was constructed with one. The legacy OverlayManager::new path stores the default 10.200.0.0/16.

Source

pub async fn persist_ipam_state(&self, path: &Path) -> Result<(), AgentError>

Persist the IPAM allocator state to path.

The state is a small JSON blob capturing the allocator’s CIDR bound and its next-offset counter so restarts don’t re-hand-out the same IPs.

§Errors

Returns an error if the file cannot be written.

Source

pub async fn restore_ipam_state( &mut self, path: &Path, ) -> Result<(), AgentError>

Restore IPAM allocator state from path.

If the file does not exist this is a no-op (the allocator keeps its current counter). On load mismatch (e.g. the persisted CIDR differs from the allocator’s current CIDR) the counter is left untouched and a warning is emitted.

§Errors

Returns an error if the file exists but cannot be read or parsed.

Source

pub fn ip_alloc_stats(&self) -> (u64, IpAddr)

Returns IP allocation statistics: (allocated_count, next_offset).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>
where Self: Sized,

Propagate a header from the request to the response. Read more
Source§

fn add_extension<T>(self, value: T) -> AddExtension<Self, T>
where Self: Sized,

Add some shareable value to request extensions. Read more
Source§

fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>
where Self: Sized,

Apply a transformation to the request body. Read more
Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
Source§

fn compression(self) -> Compression<Self>
where Self: Sized,

Compresses response bodies. Read more
Source§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

fn sensitive_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>
where Self: Sized,

Mark headers as sensitive on both requests and responses. Read more
Source§

fn sensitive_request_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<Self>
where Self: Sized,

Mark headers as sensitive on requests. Read more
Source§

fn sensitive_response_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveResponseHeaders<Self>
where Self: Sized,

Mark headers as sensitive on responses. Read more
Source§

fn override_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request. Read more
Source§

fn append_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Append a header into the request. Read more
Source§

fn insert_request_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request, if the header is not already present. Read more
Source§

fn override_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response. Read more
Source§

fn append_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Append a header into the response. Read more
Source§

fn insert_response_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response, if the header is not already present. Read more
Source§

fn set_request_id<M>( self, header_name: HeaderName, make_request_id: M, ) -> SetRequestId<Self, M>
where Self: Sized, M: MakeRequestId,

Add request id header and extension. Read more
Source§

fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>
where Self: Sized, M: MakeRequestId,

Add request id header and extension, using x-request-id as the header name. Read more
Source§

fn propagate_request_id( self, header_name: HeaderName, ) -> PropagateRequestId<Self>
where Self: Sized,

Propgate request ids from requests to responses. Read more
Source§

fn propagate_x_request_id(self) -> PropagateRequestId<Self>
where Self: Sized,

Propgate request ids from requests to responses, using x-request-id as the header name. Read more
Source§

fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>
where Self: Sized,

Catch panics and convert them into 500 Internal Server responses. Read more
Source§

fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>
where Self: Sized,

Intercept requests with over-sized payloads and convert them into 413 Payload Too Large responses. Read more
Source§

fn trim_trailing_slash(self) -> NormalizePath<Self>
where Self: Sized,

Remove trailing slashes from paths. Read more
Source§

fn append_trailing_slash(self) -> NormalizePath<Self>
where Self: Sized,

Append trailing slash to paths. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

Source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,