Remove l2bridge checker on windows and l2tunnel mode (#3113)

* remove l2bridge checker and l2tunnel mode

* fix l2bridge type

* fix the comment to add an UT to ensure hcn network type is always l2bridge

* go format to fix the linter issue
This commit is contained in:
Paul Yu 2024-11-11 17:49:49 -05:00 коммит произвёл GitHub
Родитель 5011d9a9db
Коммит 8e8a5fde51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 45 добавлений и 30 удалений

Просмотреть файл

@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"capabilities": {
"portMappings": true,

Просмотреть файл

@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"capabilities": {
"portMappings": true,

Просмотреть файл

@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"executionMode": "v4swift",
"capabilities": {

Просмотреть файл

@ -30,7 +30,6 @@ const (
// HNS network types
hnsL2Bridge = "l2bridge"
hnsL2Tunnel = "l2tunnel"
// hcnSchemaVersionMajor indicates major version number for hcn schema
hcnSchemaVersionMajor = 2
@ -145,7 +144,7 @@ func CreateDefaultExtNetwork(networkType string) error {
return nil
}
if networkType != hnsL2Bridge && networkType != hnsL2Tunnel {
if networkType != hnsL2Bridge {
return fmt.Errorf("Invalid hns network type %s", networkType)
}

Просмотреть файл

@ -244,7 +244,7 @@ var args = acn.ArgumentList{
{
Name: acn.OptCreateDefaultExtNetworkType,
Shorthand: acn.OptCreateDefaultExtNetworkTypeAlias,
Description: "Create default external network for windows platform with the specified type (l2bridge or l2tunnel)",
Description: "Create default external network for windows platform with the specified type (l2bridge)",
Type: "string",
DefaultValue: "",
},

Просмотреть файл

@ -24,7 +24,6 @@ import (
const (
// HNS network types.
hnsL2bridge = "l2bridge"
hnsL2tunnel = "l2tunnel"
CnetAddressSpace = "cnetAddressSpace"
vEthernetAdapterPrefix = "vEthernet"
baseDecimal = 10
@ -113,6 +112,7 @@ func (nm *networkManager) newNetworkImplHnsV1(nwInfo *EndpointInfo, extIf *exter
// Initialize HNS network.
hnsNetwork := &hcsshim.HNSNetwork{
Name: nwInfo.NetworkID,
Type: hnsL2bridge,
NetworkAdapterName: networkAdapterName,
Policies: policy.SerializePolicies(policy.NetworkPolicy, nwInfo.NetworkPolicies, nil, false, false),
}
@ -132,16 +132,6 @@ func (nm *networkManager) newNetworkImplHnsV1(nwInfo *EndpointInfo, extIf *exter
vlanid = (int)(vlanPolicy.VLAN)
}
// Set network mode.
switch nwInfo.Mode {
case opModeBridge:
hnsNetwork.Type = hnsL2bridge
case opModeTunnel:
hnsNetwork.Type = hnsL2tunnel
default:
return nil, errNetworkModeInvalid
}
// Populate subnets.
for _, subnet := range nwInfo.Subnets {
hnsSubnet := hcsshim.Subnet{
@ -233,6 +223,7 @@ func (nm *networkManager) configureHcnNetwork(nwInfo *EndpointInfo, extIf *exter
// Initialize HNS network.
hcnNetwork := &hcn.HostComputeNetwork{
Name: nwInfo.NetworkID,
Type: hcn.L2Bridge,
Ipams: []hcn.Ipam{
{
Type: hcnIpamTypeStatic,
@ -287,16 +278,6 @@ func (nm *networkManager) configureHcnNetwork(nwInfo *EndpointInfo, extIf *exter
vlanid = (int)(vlanID)
}
// Set network mode.
switch nwInfo.Mode {
case opModeBridge:
hcnNetwork.Type = hcn.L2Bridge
case opModeTunnel:
hcnNetwork.Type = hcn.L2Tunnel
default:
return nil, errNetworkModeInvalid
}
// AccelnetNIC flag: hcn.EnableIov(9216) - treat Delegated/FrontendNIC also the same as Accelnet
// For L1VH with accelnet, hcn.DisableHostPort and hcn.EnableIov must be configured
if nwInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC {

Просмотреть файл

@ -60,7 +60,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) {
}
err = nm.deleteNetworkImplHnsV2(network)
if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
@ -95,7 +94,6 @@ func TestSuccesfulNetworkCreationWhenAlreadyExists(t *testing.T) {
}
_, err = nm.newNetworkImplHnsV2(nwInfo, extInterface)
if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
@ -468,7 +466,6 @@ func TestNewAndDeleteNetworkImplHnsV2ForDelegated(t *testing.T) {
}
err = nm.deleteNetworkImpl(network, cns.NodeNetworkInterfaceFrontendNIC)
if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
@ -522,6 +519,47 @@ func TestTransparentNetworkCreationForDelegated(t *testing.T) {
}
}
// Test Configure HNC network for infraNIC ensuring the hcn network type is always l2 bridge
func TestConfigureHCNNetworkInfraNIC(t *testing.T) {
expectedHcnNetworkType := hcn.L2Bridge
nm := &networkManager{
ExternalInterfaces: map[string]*externalInterface{},
}
extIf := externalInterface{
Name: "eth0",
}
nwInfo := &EndpointInfo{
AdapterName: "eth0",
NetworkID: "d3e97a83-ba4c-45d5-ba88-dc56757ece28",
MasterIfName: "eth0",
NICType: cns.InfraNIC,
IfIndex: 1,
EndpointID: "753d3fb6-e9b3-49e2-a109-2acc5dda61f1",
ContainerID: "545055c2-1462-42c8-b222-e75d0b291632",
NetNsPath: "fakeNameSpace",
IfName: "eth0",
Data: make(map[string]interface{}),
EndpointDNS: DNSInfo{
Suffix: "10.0.0.0",
Servers: []string{"10.0.0.1, 10.0.0.2"},
Options: nil,
},
HNSNetworkID: "853d3fb6-e9b3-49e2-a109-2acc5dda61f1",
}
hostComputeNetwork, err := nm.configureHcnNetwork(nwInfo, &extIf)
if err != nil {
t.Fatalf("Failed to configure hcn network for infraNIC interface due to: %v", err)
}
if hostComputeNetwork.Type != expectedHcnNetworkType {
t.Fatalf("Host network mode is not configured as %v mode when interface NIC type is infraNIC", expectedHcnNetworkType)
}
}
// Test Configure HCN Network for Swiftv2 DelegatedNIC HostComputeNetwork fields
func TestConfigureHCNNetworkSwiftv2DelegatedNIC(t *testing.T) {
expectedSwiftv2NetworkMode := hcn.Transparent