Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/controller/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,6 @@ func (r *ReconcileNode) handleEFLO(ctx context.Context, k8sNode *corev1.Node, no
NodeID: &node.Spec.NodeMetadata.InstanceID,
}

if types.NodeExclusiveENIMode(node.Labels) != types.ExclusiveENIOnly {
return reconcile.Result{}, fmt.Errorf("exclusive ENI mode must be enabled for EFLO nodes")
}

resp, err := r.aliyun.GetEFLOController().DescribeNode(ctx, describeNodeReq)
if err != nil {
return reconcile.Result{}, err
Expand All @@ -448,6 +444,11 @@ func (r *ReconcileNode) handleEFLO(ctx context.Context, k8sNode *corev1.Node, no
if (node.Spec.NodeCap.Adapters <= 1 &&
limit.HighDenseQuantity > 0) ||
k8sNode.Annotations[types.ENOApi] == types.APIEcsHDeni { // check k8s config

if types.NodeExclusiveENIMode(node.Labels) != types.ExclusiveENIOnly {
return reconcile.Result{}, fmt.Errorf("exclusive ENI mode must be enabled for EFLO nodes")
}

node.Spec.NodeCap.Adapters = limit.HighDenseQuantity
node.Spec.NodeCap.TotalAdapters = limit.HighDenseQuantity

Expand Down
28 changes: 0 additions & 28 deletions pkg/controller/node/node_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,33 +501,5 @@ var _ = Describe("Node Controller", func() {
verifyNetworkCardsCount(ctx, nodeName, 0)
})
})

Context("Error Cases", func() {
It("should reject EFLO node without exclusive ENI mode", func() {
nodeName := "test-eflo-node-error"
defer cleanupNode(ctx, nodeName)

k8sNode := testutil.NewK8sNodeBuilder(nodeName).
WithEFLO().
WithInstanceType("eflo.instance").
WithProviderID("instanceID-error").
Build()
Expect(k8sClient.Create(ctx, k8sNode)).To(Succeed())

openAPI.On("DescribeNetworkInterfaceV2", mock.Anything, mock.Anything).Return([]*aliyunClient.NetworkInterface{
{
NetworkInterfaceID: "eni-test",
Type: aliyunClient.ENITypePrimary,
},
}, nil).Maybe()

reconciler := createReconciler(true, true)
_, err := reconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: types.NamespacedName{Name: nodeName},
})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("exclusive ENI mode must be enabled for EFLO nodes"))
})
})
})
})
2 changes: 1 addition & 1 deletion tests/connective_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type PodConfig struct {
// generatePodConfigs generates pod configurations with proper node affinity to avoid exclusive ENI nodes
func generatePodConfigs(testName string) []PodConfig {
// Get node affinity exclude labels to avoid scheduling on exclusive ENI nodes
nodeAffinityExclude := GetNodeAffinityExcludeForType(NodeTypeNormal)
nodeAffinityExclude := GetNodeAffinityExcludeForType(NodeTypeECSSharedENI)

var mutateConfig []PodConfig
if affinityLabel == "" {
Expand Down
96 changes: 83 additions & 13 deletions tests/connectivity_scenarios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@ import (
"sigs.k8s.io/e2e-framework/pkg/features"
)

// TestConnectivity_AllNodeTypes tests basic connectivity across all available node types
// Note: Trunk and Exclusive ENI mode tests are in trunk_test.go and exclusive_eni_test.go respectively
// TestConnectivity_AllNodeTypes tests basic connectivity across all available node types and ENI modes
// Tests all combinations: ECS/Lingjun nodes × Shared/Exclusive ENI modes
func TestConnectivity_AllNodeTypes(t *testing.T) {
var feats []features.Feature

// Test normal nodes
normalFeature := createConnectivityTest("Connectivity/NormalNode", NodeTypeNormal, "normal")
feats = append(feats, normalFeature)
// Test ECS nodes with shared ENI mode
ecsSharedFeature := createConnectivityTest("Connectivity/ECS-SharedENI", NodeTypeECSSharedENI, "ecs-shared")
feats = append(feats, ecsSharedFeature)

// Test exclusive ENI nodes (basic connectivity only, not exclusive ENI mode)
exclusiveENIFeature := createConnectivityTest("Connectivity/ExclusiveENINode", NodeTypeExclusiveENI, "exclusive-eni")
feats = append(feats, exclusiveENIFeature)
// Test ECS nodes with exclusive ENI mode
ecsExclusiveFeature := createConnectivityTest("Connectivity/ECS-ExclusiveENI", NodeTypeECSExclusiveENI, "ecs-exclusive")
feats = append(feats, ecsExclusiveFeature)

// Test Lingjun nodes
lingjunFeature := createConnectivityTest("Connectivity/LingjunNode", NodeTypeLingjun, "lingjun")
feats = append(feats, lingjunFeature)
// Test Lingjun nodes with shared ENI mode
lingjunSharedFeature := createConnectivityTest("Connectivity/Lingjun-SharedENI", NodeTypeLingjunSharedENI, "lingjun-shared")
feats = append(feats, lingjunSharedFeature)

// Test Lingjun nodes with exclusive ENI mode
lingjunExclusiveFeature := createConnectivityTest("Connectivity/Lingjun-ExclusiveENI", NodeTypeLingjunExclusiveENI, "lingjun-exclusive")
feats = append(feats, lingjunExclusiveFeature)

testenv.Test(t, feats...)
}
Expand Down Expand Up @@ -69,6 +73,17 @@ func createConnectivityTest(testName string, nodeType NodeType, label string) fe
server = server.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
server = server.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, server.Pod)
if err != nil {
t.Fatalf("create server pod failed, %v", err)
Expand All @@ -88,6 +103,17 @@ func createConnectivityTest(testName string, nodeType NodeType, label string) fe
client = client.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
client = client.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, client.Pod)
if err != nil {
t.Fatalf("create client pod failed, %v", err)
Expand Down Expand Up @@ -159,7 +185,7 @@ func createConnectivityTest(testName string, nodeType NodeType, label string) fe
func TestConnectivity_CrossNode(t *testing.T) {
var feats []features.Feature

for _, nodeType := range []NodeType{NodeTypeNormal, NodeTypeExclusiveENI, NodeTypeLingjun} {
for _, nodeType := range []NodeType{NodeTypeECSSharedENI, NodeTypeECSExclusiveENI, NodeTypeLingjunSharedENI, NodeTypeLingjunExclusiveENI} {
feat := createCrossNodeTest(nodeType)
feats = append(feats, feat)
}
Expand Down Expand Up @@ -199,6 +225,17 @@ func createCrossNodeTest(nodeType NodeType) features.Feature {
server = server.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
server = server.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, server.Pod)
if err != nil {
t.Fatalf("create server pod failed, %v", err)
Expand All @@ -217,6 +254,17 @@ func createCrossNodeTest(nodeType NodeType) features.Feature {
client = client.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
client = client.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, client.Pod)
if err != nil {
t.Fatalf("create client pod failed, %v", err)
Expand Down Expand Up @@ -274,7 +322,7 @@ func createCrossNodeTest(nodeType NodeType) features.Feature {
func TestConnectivity_CrossZone(t *testing.T) {
var feats []features.Feature

for _, nodeType := range []NodeType{NodeTypeNormal, NodeTypeExclusiveENI, NodeTypeLingjun} {
for _, nodeType := range []NodeType{NodeTypeECSSharedENI, NodeTypeECSExclusiveENI, NodeTypeLingjunSharedENI, NodeTypeLingjunExclusiveENI} {
feat := createCrossZoneTest(nodeType)
feats = append(feats, feat)
}
Expand Down Expand Up @@ -338,6 +386,17 @@ func createCrossZoneTest(nodeType NodeType) features.Feature {
server = server.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
server = server.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, server.Pod)
if err != nil {
t.Fatalf("create server pod failed, %v", err)
Expand All @@ -356,6 +415,17 @@ func createCrossZoneTest(nodeType NodeType) features.Feature {
client = client.WithNodeAffinityExclude(nodeAffinityExclude)
}

// Add tolerations for Lingjun nodes (both shared and exclusive ENI modes)
if nodeType == NodeTypeLingjunSharedENI || nodeType == NodeTypeLingjunExclusiveENI {
client = client.WithTolerations([]corev1.Toleration{
{
Key: "node-role.alibabacloud.com/lingjun",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
})
}

err = config.Client().Resources().Create(ctx, client.Pod)
if err != nil {
t.Fatalf("create client pod failed, %v", err)
Expand Down
6 changes: 3 additions & 3 deletions tests/multi_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type MultiNetworkConfig struct {
// NewMultiNetworkConfig creates a default multi-network test configuration
func NewMultiNetworkConfig() *MultiNetworkConfig {
config := &MultiNetworkConfig{
NodeTypes: []NodeType{NodeTypeNormal, NodeTypeExclusiveENI},
NodeTypes: []NodeType{NodeTypeECSSharedENI, NodeTypeECSExclusiveENI, NodeTypeLingjunSharedENI, NodeTypeLingjunExclusiveENI},
EnableDefaultMode: true, // Always test default mode
}

Expand Down Expand Up @@ -133,7 +133,7 @@ func createMultiNetworkTestFeature(testName string, nodeType NodeType, mode stri

// Create primary PodNetworking (always use default config)
pn1 := NewPodNetworking(pnPrimary)
if nodeType == NodeTypeExclusiveENI {
if nodeType == NodeTypeECSExclusiveENI || nodeType == NodeTypeLingjunExclusiveENI {
pn1 = pn1.WithENIAttachType(networkv1beta1.ENIOptionTypeENI)
}
err = CreatePodNetworkingAndWaitReady(ctx, config.Client(), pn1.PodNetworking)
Expand All @@ -145,7 +145,7 @@ func createMultiNetworkTestFeature(testName string, nodeType NodeType, mode stri

// Create secondary PodNetworking based on mode
pn2 := NewPodNetworking(pnSecondary)
if nodeType == NodeTypeExclusiveENI {
if nodeType == NodeTypeECSExclusiveENI || nodeType == NodeTypeLingjunExclusiveENI {
pn2 = pn2.WithENIAttachType(networkv1beta1.ENIOptionTypeENI)
}
if mode == "custom" {
Expand Down
Loading