Skip to content

Commit

Permalink
Enhance HNS network initialization (#5841)
Browse files Browse the repository at this point in the history
The current windows agent initialization couldn't guarantee that the
`EnableHNSNetworkExtension` was executed after creating the HNS
network. In certain corner cases where the Windows agent pod was
restarted after creating HNS network, the agent might miss executing
`EnableHNSNetworkExtension`.

To address this issue, this enhancement runs `EnableHNSNetworkExtension`
even if the HNS network has been created, which ensures the OVS
Extension is properly enabled.

Signed-off-by: Shuyang Xin <gavinx@vmware.com>
  • Loading branch information
XinShuYang authored Jan 23, 2024
1 parent c0c3e25 commit 053751d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/agent/agent_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (i *Initializer) prepareHNSNetworkAndOVSExtension() error {
// If the HNS Network already exists, return immediately.
hnsNetwork, err := hcsshim.GetHNSNetworkByName(util.LocalHNSNetwork)
if err == nil {
// Enable OVS Extension on the HNS Network.
if err = util.EnableHNSNetworkExtension(hnsNetwork.Id, util.OVSExtensionID); err != nil {
return err
}
// Enable RSC for existing vSwitch.
if err = util.EnableRSCOnVSwitch(util.LocalHNSNetwork); err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/util/net_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ func PrepareHNSNetwork(subnetCIDR *net.IPNet, nodeIPNet *net.IPNet, uplinkAdapte
}

// Enable OVS Extension on the HNS Network. If an error occurs, delete the HNS Network and return the error.
// While the hnsshim API allows for enabling the OVS extension when creating an HNS network, it can cause the adapter being unable
// to obtain a valid DHCP IP in case of network interruption. Therefore, we have to enable the OVS extension after running adapterIPExists.
if err = EnableHNSNetworkExtension(hnsNet.Id, OVSExtensionID); err != nil {
return err
}
Expand Down

0 comments on commit 053751d

Please sign in to comment.