[shimV2] added network controller implementation#2633
[shimV2] added network controller implementation#2633rawahars merged 4 commits intomicrosoft:mainfrom
Conversation
This change adds the network controller implementation for V2 shims which manages the network lifecycle for a single pod running inside a UVM. Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
0336432 to
e901ab7
Compare
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
helsaawy
left a comment
There was a problem hiding this comment.
if we are going to gate the Controller functionality by build tags, can we fully extend it to the GuestNetworkManager types?
that way we don't have to deal with unused fields in either case:
//
// internal/controller/network/network.go
//
type Controller struct {
// ...
// guestMgr manages the guest-side NIC operations.
guestMgr guestNetworkManager
// ...
}
// New creates a ready-to-use Controller in [StateNotConfigured].
func New(
vmNetManager vmNetworkManager,Expand commentComment on line R51Resolved
guestMgr guestNetworkManager,
) *Controller {
//
// internal/controller/network/network_lcow.go
//
// guestNetworkManager exposes linux guest network operations.
// Implemented by [guestmanager.Guest].
type guestNetworkManager interface {
// AddLCOWNetworkInterface adds a network interface to the LCOW guest.
AddLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error
// RemoveLCOWNetworkInterface removes a network interface from the LCOW guest.
RemoveLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error
}
//
// internal/controller/network/network_wcow.go
//
// guestNetworkManager exposes windows guest network operations.
// Implemented by guestmanager.Guest.
type guestNetworkManager interface {
// AddNetworkNamespace adds a network namespace to the WCOW guest.
AddNetworkNamespace(ctx context.Context, settings *hcn.HostComputeNamespace) error
// RemoveNetworkNamespace removes a network namespace from the WCOW guest.
RemoveNetworkNamespace(ctx context.Context, settings *hcn.HostComputeNamespace) error
// AddNetworkInterface adds a network interface to the WCOW guest.
AddNetworkInterface(ctx context.Context, adapterID string, requestType guestrequest.RequestType, settings *hcn.HostComputeEndpoint) error
// RemoveNetworkInterface removes a network interface from the WCOW guest.
RemoveNetworkInterface(ctx context.Context, adapterID string, requestType guestrequest.RequestType, settings *hcn.HostComputeEndpoint) error
}|
also, more of a nit, but can WCOW be the default and therefore have LCOW require the |
c2d5a77 to
01a48e5
Compare
|
@helsaawy Made the suggested changes. These changes are inline with other places now. |
| // | ||
| // Guest-side operations differ between LCOW and WCOW and are implemented in | ||
| // platform-specific source files selected via build tags | ||
| // ("lcow" tag for LCOW shim, "wcow" tag for WCOW shim). |
There was a problem hiding this comment.
why did we go with not go with WCOW being the default?
it will likely cause more problems that the default build fails during runtime rather than assuming WCOW
There was a problem hiding this comment.
Right that was the intention based on discussion with Justin.
LCOW shim needs to be specifically compiled using lcow tag and WCOW with wcow. There's no default otherwise.
There was a problem hiding this comment.
so just building a shim will always give us something entirely non-functional?
There was a problem hiding this comment.
Yes that's true! It's purely intent driven with new shim.
Summary
This change adds the network controller implementation for V2 shims which manages the network lifecycle for a single pod running inside a UVM. The implementation provides a clear lifecycle state machine, separates platform-specific logic for LCOW and WCOW. This controller will be initialized from VMController which can inject the low-level managers to perform VM host + guest network operations.
The main changes are grouped below.
Network controller implementation:
Controllerinterface and its concreteManagertype, providingSetupandTeardownmethods to manage HCN namespaces and endpoints for a pod (internal/controller/network/interface.go,internal/controller/network/network.go).Platform-specific guest operations:
internal/controller/network/network_lcow.go,internal/controller/network/network_wcow.go).Lifecycle state management:
Statetype to track the network lifecycle, including transitions for setup, teardown, and error handling (internal/controller/network/state.go).