kube-proxy: conditionally skip e2e

Conditionally skip instead of failing when nfacct test when the required
metric is not present. The only case when the metric will not be registered
by kube-proxy is when nfacct subsystem is not supported on the node, we
skip the test in that case.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
Daman Arora
2025-04-27 00:22:49 +05:30
parent 5290c24e85
commit 62ddcfba57
2 changed files with 13 additions and 6 deletions

View File

@@ -279,6 +279,11 @@ var (
// TODO: document the feature (owning SIG, when to use this feature for a test)
KubeProxyDaemonSetMigration = framework.WithFeature(framework.ValidFeatures.Add("KubeProxyDaemonSetMigration"))
// Owner: sig-network
// Marks tests that require the kernel to have support for the nfacct subsystem.
// (Some distros don't include this in the kernel.)
KubeProxyNFAcct = framework.WithFeature(framework.ValidFeatures.Add("KubeProxyNFAcct"))
// TODO: document the feature (owning SIG, when to use this feature for a test)
LabelSelector = framework.WithFeature(framework.ValidFeatures.Add("LabelSelector"))

View File

@@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/pkg/cluster/ports"
"k8s.io/kubernetes/pkg/proxy/apis/config"
"k8s.io/kubernetes/test/e2e/feature"
"k8s.io/kubernetes/test/e2e/framework"
e2emetrics "k8s.io/kubernetes/test/e2e/framework/metrics"
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
@@ -253,12 +254,13 @@ var _ = common.SIGDescribe("KubeProxy", func() {
framework.Failf("no valid conntrack entry for port %d on node %s: %v", testDaemonTCPPort, serverNodeInfo.nodeIP, err)
}
})
})
var _ = common.SIGDescribe("KubeProxyNFAcct", feature.KubeProxyNFAcct, func() {
fr := framework.NewDefaultFramework("kube-proxy-nfacct")
fr.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
ginkgo.It("should update metric for tracking accepted packets destined for localhost nodeports", func(ctx context.Context) {
if framework.TestContext.ClusterIsIPv6() {
e2eskipper.Skipf("test requires IPv4 cluster")
}
cs := fr.ClientSet
ns := fr.Namespace.Name
@@ -285,7 +287,7 @@ var _ = common.SIGDescribe("KubeProxy", func() {
// get proxyMode
stdout, err := e2epodoutput.RunHostCmd(fr.Namespace.Name, hostExecPodName, fmt.Sprintf("curl --silent 127.0.0.1:%d/proxyMode", ports.ProxyStatusPort))
if err != nil {
e2eskipper.Skipf("kube-proxy is not running or could not determine kube-proxy mode (%v)", err)
framework.Failf("failed to get proxy mode: err: %v; stdout: %s", stdout, err)
}
proxyMode := strings.TrimSpace(stdout)
@@ -354,7 +356,7 @@ var _ = common.SIGDescribe("KubeProxy", func() {
}
return true, nil
}); err != nil {
e2eskipper.Skipf("skipping test as localhost nodeports are not acceesible in this environment")
framework.ExpectNoError(err, "failed to access nodeport service on localhost")
}
}