mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-09 08:55:55 -04:00
Merge pull request #137620 from Karthik-K-N/remove-hardcoded-volpath
test: Replace hardcoded kubelet volume paths with TestContext.KubeletRootDir in node e2e tests
This commit is contained in:
commit
3c47d576e5
4 changed files with 14 additions and 14 deletions
|
|
@ -372,6 +372,13 @@ func updateTestContext(ctx context.Context) error {
|
|||
setExtraEnvs()
|
||||
updateImageAllowList(ctx)
|
||||
|
||||
// Set KubeletRootDir to match the kubelet configuration used in node e2e tests.
|
||||
// This ensures tests that use framework.TestContext.KubeletRootDir (e.g., for HostPath volumes)
|
||||
// use the correct path.
|
||||
if framework.TestContext.KubeletRootDir == "" {
|
||||
framework.TestContext.KubeletRootDir = services.KubeletRootDirectory
|
||||
}
|
||||
|
||||
client, err := getAPIServerClient()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get apiserver client: %w", err)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
|
@ -296,9 +297,7 @@ current-context: local-context
|
|||
},
|
||||
},
|
||||
})
|
||||
// TODO: remove hardcoded kubelet volume directory path
|
||||
// framework.TestContext.KubeVolumeDir is currently not populated for node e2e
|
||||
hostLogFile = "/var/lib/kubelet/pods/" + string(pod.UID) + "/volumes/kubernetes.io~empty-dir" + logFile
|
||||
hostLogFile = filepath.Join(framework.TestContext.KubeletRootDir, "pods", string(pod.UID), "volumes/kubernetes.io~empty-dir") + logFile
|
||||
})
|
||||
|
||||
ginkgo.It("should generate node condition and events for corresponding errors", func(ctx context.Context) {
|
||||
|
|
|
|||
|
|
@ -48,10 +48,8 @@ func runOneQuotaTest(f *framework.Framework, quotasRequested bool, userNamespace
|
|||
sizeLimit := resource.MustParse("100Mi")
|
||||
useOverLimit := 101 /* Mb */
|
||||
useUnderLimit := 99 /* Mb */
|
||||
// TODO: remove hardcoded kubelet volume directory path
|
||||
// framework.TestContext.KubeVolumeDir is currently not populated for node e2e
|
||||
// As for why we do this: see comment below at isXfs.
|
||||
if isXfs("/var/lib/kubelet") {
|
||||
if isXfs(framework.TestContext.KubeletRootDir) {
|
||||
useUnderLimit = 50 /* Mb */
|
||||
}
|
||||
priority := 0
|
||||
|
|
@ -61,12 +59,10 @@ func runOneQuotaTest(f *framework.Framework, quotasRequested bool, userNamespace
|
|||
ginkgo.Context(fmt.Sprintf(testContextFmt, fmt.Sprintf("use quotas for LSCI monitoring (quotas enabled: %v, userNamespacesEnabled: %v)", quotasRequested, userNamespacesEnabled)), func() {
|
||||
tempSetCurrentKubeletConfig(f, func(ctx context.Context, initialConfig *kubeletconfig.KubeletConfiguration) {
|
||||
defer withFeatureGate(LSCIQuotaFeature, quotasRequested)()
|
||||
// TODO: remove hardcoded kubelet volume directory path
|
||||
// framework.TestContext.KubeVolumeDir is currently not populated for node e2e
|
||||
if !supportsUserNS(ctx, f) {
|
||||
e2eskipper.Skipf("runtime does not support user namespaces")
|
||||
}
|
||||
if quotasRequested && !supportsQuotas("/var/lib/kubelet", userNamespacesEnabled) {
|
||||
if quotasRequested && !supportsQuotas(framework.TestContext.KubeletRootDir, userNamespacesEnabled) {
|
||||
// No point in running this as a positive test if quotas are not
|
||||
// enabled on the underlying filesystem.
|
||||
e2eskipper.Skipf("Cannot run LocalStorageCapacityIsolationFSQuotaMonitoring on filesystem without project quota enabled")
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ package e2enode
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
|
@ -27,8 +29,6 @@ import (
|
|||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
|
|
@ -107,9 +107,7 @@ var _ = SIGDescribe("Kubelet Volume Manager", func() {
|
|||
{
|
||||
Name: "kubelet-pods",
|
||||
VolumeSource: v1.VolumeSource{
|
||||
// TODO: remove hardcoded kubelet volume directory path
|
||||
// framework.TestContext.KubeVolumeDir is currently not populated for node e2e
|
||||
HostPath: &v1.HostPathVolumeSource{Path: "/var/lib/kubelet/pods"},
|
||||
HostPath: &v1.HostPathVolumeSource{Path: filepath.Join(framework.TestContext.KubeletRootDir, "pods")},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue