Skip to content

Commit 219f062

Browse files
authored
Merge pull request kubernetes#64829 from dixudx/e2e_hostpath_type
fix bug on checking non directory HostPathType and add e2e tests for HostPathType
2 parents 7fdb2b1 + 084fe6d commit 219f062

File tree

4 files changed

+460
-4
lines changed

4 files changed

+460
-4
lines changed

pkg/volume/hostpath/host_path.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ func (ftc *fileTypeChecker) IsFile() bool {
370370
if !ftc.Exists() {
371371
return false
372372
}
373-
return !ftc.IsDir()
373+
pathType, err := ftc.hu.GetFileType(ftc.path)
374+
if err != nil {
375+
return false
376+
}
377+
return string(pathType) == string(v1.HostPathFile)
374378
}
375379

376380
func (ftc *fileTypeChecker) MakeFile() error {

pkg/volume/hostpath/host_path_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func TestOSFileTypeChecker(t *testing.T) {
447447
if oftc.IsDir() {
448448
t.Errorf("[%d: %q] expected socket file, got unexpected folder: %s", i, tc.name, path)
449449
}
450-
if !oftc.IsFile() {
450+
if oftc.IsFile() {
451451
t.Errorf("[%d: %q] expected socket file, got unexpected file: %s", i, tc.name, path)
452452
}
453453
if oftc.IsBlock() {
@@ -465,7 +465,7 @@ func TestOSFileTypeChecker(t *testing.T) {
465465
if oftc.IsDir() {
466466
t.Errorf("[%d: %q] expected character device, got unexpected folder: %s", i, tc.name, path)
467467
}
468-
if !oftc.IsFile() {
468+
if oftc.IsFile() {
469469
t.Errorf("[%d: %q] expected character device, got unexpected file: %s", i, tc.name, path)
470470
}
471471
if oftc.IsSocket() {
@@ -483,7 +483,7 @@ func TestOSFileTypeChecker(t *testing.T) {
483483
if oftc.IsDir() {
484484
t.Errorf("[%d: %q] expected block device, got unexpected folder: %s", i, tc.name, path)
485485
}
486-
if !oftc.IsFile() {
486+
if oftc.IsFile() {
487487
t.Errorf("[%d: %q] expected block device, got unexpected file: %s", i, tc.name, path)
488488
}
489489
if oftc.IsSocket() {

test/e2e/storage/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ go_library(
1212
"flexvolume_mounted_volume_resize.go",
1313
"flexvolume_online_resize.go",
1414
"generic_persistent_volume-disruptive.go",
15+
"host_path_type.go",
1516
"in_tree_volumes.go",
1617
"mounted_volume_resize.go",
1718
"nfs_persistent_volume-disruptive.go",
@@ -35,6 +36,7 @@ go_library(
3536
"//pkg/apis/core/v1/helper:go_default_library",
3637
"//pkg/apis/storage/v1/util:go_default_library",
3738
"//pkg/client/conditions:go_default_library",
39+
"//pkg/kubelet/events:go_default_library",
3840
"//pkg/kubelet/metrics:go_default_library",
3941
"//pkg/util/slice:go_default_library",
4042
"//pkg/volume/util:go_default_library",
@@ -47,6 +49,7 @@ go_library(
4749
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
4850
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
4951
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
52+
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
5053
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
5154
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
5255
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
@@ -66,6 +69,7 @@ go_library(
6669
"//test/e2e/framework:go_default_library",
6770
"//test/e2e/framework/auth:go_default_library",
6871
"//test/e2e/framework/deployment:go_default_library",
72+
"//test/e2e/framework/events:go_default_library",
6973
"//test/e2e/framework/kubectl:go_default_library",
7074
"//test/e2e/framework/kubesystem:go_default_library",
7175
"//test/e2e/framework/metrics:go_default_library",

0 commit comments

Comments
 (0)