Skip to content

Commit 022de0e

Browse files
author
Karina Ranadive
committed
fix
1 parent 4e6b260 commit 022de0e

File tree

1 file changed

+12
-40
lines changed

1 file changed

+12
-40
lines changed

test/integration/lrp/lrp_test.go

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package lrp
44

55
import (
66
"context"
7-
"fmt"
87
"os"
98
"strings"
109
"testing"
@@ -344,24 +343,6 @@ func validateCiliumLRP(t *testing.T, ctx context.Context, cs *k8sclient.Clientse
344343
require.NoError(t, err)
345344
t.Logf("Detected Kubernetes version: %s", serverVersion.String())
346345

347-
// Parse version to determine if we should use modern or legacy validation
348-
// K8s 1.32.0+ should use modern Cilium format (v1.17+)
349-
useModernFormat := false
350-
if serverVersion.Major == "1" {
351-
// Parse minor version
352-
var minorVersion int
353-
_, err := fmt.Sscanf(serverVersion.Minor, "%d", &minorVersion)
354-
if err == nil && minorVersion >= 32 {
355-
useModernFormat = true
356-
}
357-
}
358-
359-
if useModernFormat {
360-
t.Log("Using modern validation approach based on Kubernetes version >= 1.32.0")
361-
} else {
362-
t.Log("Using legacy validation approach based on Kubernetes version < 1.32.0")
363-
}
364-
365346
// Get kube-dns service IP for validation
366347
svc, err := kubernetes.GetService(ctx, cs, kubeSystemNamespace, dnsService)
367348
require.NoError(t, err)
@@ -422,39 +403,30 @@ func validateCiliumLRP(t *testing.T, ctx context.Context, cs *k8sclient.Clientse
422403
serviceLines := strings.Split(string(serviceOutput), "\n")
423404
tcpFound := false
424405
udpFound := false
406+
legacyFound := false
425407

426408
for _, line := range serviceLines {
427409
if strings.Contains(line, "LocalRedirect") && strings.Contains(line, kubeDNSIP) {
428410
// Check if this line contains the expected frontend (kube-dns) and backend (node-local-dns) IPs
429411
if strings.Contains(line, nodeLocalDNSIP) {
430-
if useModernFormat {
431-
// Modern format (K8s 1.32.0+/Cilium v1.17+): Check for explicit protocol
432-
if strings.Contains(line, "/TCP") {
433-
tcpFound = true
434-
t.Logf("Found TCP LocalRedirect: %s", strings.TrimSpace(line))
435-
} else if strings.Contains(line, "/UDP") {
436-
udpFound = true
437-
t.Logf("Found UDP LocalRedirect: %s", strings.TrimSpace(line))
438-
}
412+
// Check for both modern format (with /TCP or /UDP) and legacy format (without protocol)
413+
if strings.Contains(line, "/TCP") {
414+
tcpFound = true
415+
t.Logf("Found TCP LocalRedirect: %s", strings.TrimSpace(line))
416+
} else if strings.Contains(line, "/UDP") {
417+
udpFound = true
418+
t.Logf("Found UDP LocalRedirect: %s", strings.TrimSpace(line))
439419
} else {
440-
// Legacy format (K8s < 1.32.0/Cilium < v1.17): No protocol specified
420+
legacyFound = true
441421
t.Logf("Found legacy LocalRedirect: %s", strings.TrimSpace(line))
442422
}
443423
}
444424
}
445425
}
446426

447-
// Validate based on determined format
448-
if useModernFormat {
449-
// Modern format (K8s 1.32.0+/Cilium v1.17+): Separate TCP and UDP entries
450-
t.Log("Validating modern Cilium format - expecting separate TCP and UDP LocalRedirect entries")
451-
require.True(t, tcpFound, "TCP LocalRedirect entry not found with frontend IP %s and backend IP %s on node %s", kubeDNSIP, nodeLocalDNSIP, selectedNode)
452-
require.True(t, udpFound, "UDP LocalRedirect entry not found with frontend IP %s and backend IP %s on node %s", kubeDNSIP, nodeLocalDNSIP, selectedNode)
453-
} else {
454-
// Legacy format (K8s < 1.32.0/Cilium < v1.17): Just one LocalRedirect entry without protocol
455-
t.Log("Validating legacy Cilium format - expecting single LocalRedirect entry without protocol")
456-
require.False(t, useModernFormat, "Legacy LocalRedirect entry not found with frontend IP %s and backend IP %s on node %s", kubeDNSIP, nodeLocalDNSIP, selectedNode)
457-
}
427+
// Validate that we found either legacy format or modern format entries
428+
t.Log("Validating LocalRedirect entries - accepting either legacy format or modern TCP/UDP format")
429+
require.True(t, legacyFound || (tcpFound && udpFound), "Either legacy LocalRedirect entry OR both TCP and UDP entries must be found with frontend IP %s and backend IP %s on node %s", kubeDNSIP, nodeLocalDNSIP, selectedNode)
458430

459431
t.Logf("Cilium LRP List Output:\n%s", string(lrpOutput))
460432
t.Logf("Cilium Service List Output:\n%s", string(serviceOutput))

0 commit comments

Comments
 (0)