diff --git a/cmd/kube-proxy/app/BUILD b/cmd/kube-proxy/app/BUILD index 57cb1a319bb..bbabff37d6e 100644 --- a/cmd/kube-proxy/app/BUILD +++ b/cmd/kube-proxy/app/BUILD @@ -40,7 +40,6 @@ go_library( "//pkg/util/ipset:go_default_library", "//pkg/util/iptables:go_default_library", "//pkg/util/ipvs:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/sysctl:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -75,6 +74,7 @@ go_library( "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/pointer:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ diff --git a/cmd/kube-proxy/app/conntrack.go b/cmd/kube-proxy/app/conntrack.go index 941620643d1..74729bfa517 100644 --- a/cmd/kube-proxy/app/conntrack.go +++ b/cmd/kube-proxy/app/conntrack.go @@ -23,8 +23,8 @@ import ( "strings" "k8s.io/klog" + "k8s.io/utils/mount" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/sysctl" ) diff --git a/cmd/kubelet/app/BUILD b/cmd/kubelet/app/BUILD index 4b280bd129a..2bb87eeea7f 100644 --- a/cmd/kubelet/app/BUILD +++ b/cmd/kubelet/app/BUILD @@ -74,7 +74,6 @@ go_library( "//pkg/util/filesystem:go_default_library", "//pkg/util/flag:go_default_library", "//pkg/util/flock:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/node:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/rlimit:go_default_library", @@ -149,6 +148,7 @@ go_library( "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//vendor/k8s.io/utils/inotify:go_default_library", diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index fb11f762b68..8a705bb139a 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -36,6 +36,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "k8s.io/klog" + "k8s.io/utils/mount" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -95,7 +96,6 @@ import ( utilfs "k8s.io/kubernetes/pkg/util/filesystem" utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/util/flock" - "k8s.io/kubernetes/pkg/util/mount" nodeutil "k8s.io/kubernetes/pkg/util/node" "k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/util/rlimit" diff --git a/go.mod b/go.mod index bdb6168b3d2..7ad963ed8f6 100644 --- a/go.mod +++ b/go.mod @@ -163,7 +163,7 @@ require ( k8s.io/repo-infra v0.0.1-alpha.1 k8s.io/sample-apiserver v0.0.0 k8s.io/system-validators v1.0.4 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/kustomize v2.0.3+incompatible sigs.k8s.io/yaml v1.1.0 ) @@ -550,7 +550,7 @@ replace ( k8s.io/sample-cli-plugin => ./staging/src/k8s.io/sample-cli-plugin k8s.io/sample-controller => ./staging/src/k8s.io/sample-controller k8s.io/system-validators => k8s.io/system-validators v1.0.4 - k8s.io/utils => k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils => k8s.io/utils v0.0.0-20191114184206-e782cd3c129f modernc.org/cc => modernc.org/cc v1.0.0 modernc.org/golex => modernc.org/golex v1.0.0 modernc.org/mathutil => modernc.org/mathutil v1.0.0 diff --git a/go.sum b/go.sum index dca3ef7e667..03b2369e2ca 100644 --- a/go.sum +++ b/go.sum @@ -589,8 +589,8 @@ k8s.io/repo-infra v0.0.1-alpha.1 h1:2us1n30u3cOcoPsacNfCvCssS9B9Yldr1ZGOdK0728U= k8s.io/repo-infra v0.0.1-alpha.1/go.mod h1:wO1t9WaB99V80ljbeENTnayuEEwNZt7gECYh/CEyOJ8= k8s.io/system-validators v1.0.4 h1:sW57tJ/ciqOVbbTLN+ZNy64MJMNqUuiwrirQv8IR2Kw= k8s.io/system-validators v1.0.4/go.mod h1:HgSgTg4NAGNoYYjKsUyk52gdNi2PVDswQ9Iyn66R7NI= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/hack/.golint_failures b/hack/.golint_failures index 61f209d7e66..2b9265068b8 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -222,7 +222,6 @@ pkg/util/goroutinemap/exponentialbackoff pkg/util/iptables pkg/util/iptables/testing pkg/util/labels # See previous effort in PR #80685 -pkg/util/mount pkg/util/oom pkg/util/procfs pkg/util/removeall diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index a99c5e2850b..8aa0b1a2888 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -40,7 +40,6 @@ pkg/util/ebtables pkg/util/ipconfig pkg/util/iptables pkg/util/ipvs/testing -pkg/util/mount pkg/util/netsh pkg/volume pkg/volume/awsebs diff --git a/pkg/cloudprovider/providers/.import-restrictions b/pkg/cloudprovider/providers/.import-restrictions index 8371496c69d..1f266d036f8 100644 --- a/pkg/cloudprovider/providers/.import-restrictions +++ b/pkg/cloudprovider/providers/.import-restrictions @@ -3,20 +3,20 @@ { "SelectorRegexp": "k8s[.]io/utils", "AllowedPrefixes": [ + "k8s.io/utils/exec", + "k8s.io/utils/io", + "k8s.io/utils/keymutex", + "k8s.io/utils/mount", "k8s.io/utils/net", "k8s.io/utils/nsenter", - "k8s.io/utils/io", - "k8s.io/utils/strings", - "k8s.io/utils/exec", "k8s.io/utils/path", - "k8s.io/utils/keymutex" + "k8s.io/utils/strings" ] }, { "SelectorRegexp": "k8s[.]io/kubernetes", "AllowedPrefixes": [ - "k8s.io/kubernetes/pkg/cloudprovider/providers", - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/kubernetes/pkg/cloudprovider/providers" ], "ForbiddenPrefixes": [] } diff --git a/pkg/controller/.import-restrictions b/pkg/controller/.import-restrictions index 768f5ee89aa..3d07bfe4afc 100644 --- a/pkg/controller/.import-restrictions +++ b/pkg/controller/.import-restrictions @@ -247,7 +247,6 @@ "k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff", "k8s.io/kubernetes/pkg/util/hash", "k8s.io/kubernetes/pkg/util/labels", - "k8s.io/kubernetes/pkg/util/mount", "k8s.io/kubernetes/pkg/util/node", "k8s.io/kubernetes/pkg/util/slice", "k8s.io/kubernetes/pkg/util/taints", @@ -287,14 +286,15 @@ "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1", "k8s.io/metrics/pkg/client/custom_metrics", "k8s.io/metrics/pkg/client/external_metrics", - "k8s.io/utils/nsenter", + "k8s.io/utils/exec", "k8s.io/utils/integer", "k8s.io/utils/io", + "k8s.io/utils/mount", + "k8s.io/utils/net", + "k8s.io/utils/nsenter", "k8s.io/utils/path", "k8s.io/utils/pointer", - "k8s.io/utils/exec", - "k8s.io/utils/strings", - "k8s.io/utils/net" + "k8s.io/utils/strings" ] }, { diff --git a/pkg/controller/volume/attachdetach/BUILD b/pkg/controller/volume/attachdetach/BUILD index de845cc0863..295ee4c8d91 100644 --- a/pkg/controller/volume/attachdetach/BUILD +++ b/pkg/controller/volume/attachdetach/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/controller/volume/attachdetach/statusupdater:go_default_library", "//pkg/controller/volume/attachdetach/util:go_default_library", "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/csimigration:go_default_library", "//pkg/volume/util:go_default_library", @@ -49,6 +48,7 @@ go_library( "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/controller/volume/attachdetach/attach_detach_controller.go b/pkg/controller/volume/attachdetach/attach_detach_controller.go index 3f1212ae56f..96fe0190526 100644 --- a/pkg/controller/volume/attachdetach/attach_detach_controller.go +++ b/pkg/controller/volume/attachdetach/attach_detach_controller.go @@ -23,6 +23,10 @@ import ( "net" "time" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -45,9 +49,6 @@ import ( "k8s.io/client-go/util/workqueue" cloudprovider "k8s.io/cloud-provider" csitrans "k8s.io/csi-translation-lib" - "k8s.io/klog" - utilexec "k8s.io/utils/exec" - "k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache" "k8s.io/kubernetes/pkg/controller/volume/attachdetach/metrics" "k8s.io/kubernetes/pkg/controller/volume/attachdetach/populator" @@ -55,7 +56,6 @@ import ( "k8s.io/kubernetes/pkg/controller/volume/attachdetach/statusupdater" "k8s.io/kubernetes/pkg/controller/volume/attachdetach/util" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/csimigration" volumeutil "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/controller/volume/expand/BUILD b/pkg/controller/volume/expand/BUILD index 91621e2d260..90e05749087 100644 --- a/pkg/controller/volume/expand/BUILD +++ b/pkg/controller/volume/expand/BUILD @@ -9,7 +9,6 @@ go_library( deps = [ "//pkg/apis/core/v1/helper:go_default_library", "//pkg/controller/volume/events:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/csimigration:go_default_library", "//pkg/volume/util:go_default_library", @@ -35,6 +34,7 @@ go_library( "//staging/src/k8s.io/cloud-provider:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/controller/volume/expand/expand_controller.go b/pkg/controller/volume/expand/expand_controller.go index ec4133b58ac..73ce28e4cb1 100644 --- a/pkg/controller/volume/expand/expand_controller.go +++ b/pkg/controller/volume/expand/expand_controller.go @@ -22,6 +22,8 @@ import ( "time" "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" @@ -41,11 +43,8 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" cloudprovider "k8s.io/cloud-provider" - utilexec "k8s.io/utils/exec" - v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" "k8s.io/kubernetes/pkg/controller/volume/events" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/csimigration" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/controller/volume/persistentvolume/BUILD b/pkg/controller/volume/persistentvolume/BUILD index 8a34932e0f6..96442c698f3 100644 --- a/pkg/controller/volume/persistentvolume/BUILD +++ b/pkg/controller/volume/persistentvolume/BUILD @@ -24,7 +24,6 @@ go_library( "//pkg/features:go_default_library", "//pkg/util/goroutinemap:go_default_library", "//pkg/util/goroutinemap/exponentialbackoff:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/csimigration:go_default_library", "//pkg/volume/util:go_default_library", @@ -58,6 +57,7 @@ go_library( "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/controller/volume/persistentvolume/volume_host.go b/pkg/controller/volume/persistentvolume/volume_host.go index d35e9a963e3..3c9bc3708c8 100644 --- a/pkg/controller/volume/persistentvolume/volume_host.go +++ b/pkg/controller/volume/persistentvolume/volume_host.go @@ -20,16 +20,16 @@ import ( "fmt" "net" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/record" cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" - utilexec "k8s.io/utils/exec" - - "k8s.io/kubernetes/pkg/util/mount" vol "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/subpath" ) diff --git a/pkg/kubelet/BUILD b/pkg/kubelet/BUILD index 43ff5f1e25c..f942cf4c2aa 100644 --- a/pkg/kubelet/BUILD +++ b/pkg/kubelet/BUILD @@ -100,7 +100,6 @@ go_library( "//pkg/security/apparmor:go_default_library", "//pkg/security/podsecuritypolicy/sysctl:go_default_library", "//pkg/util/iptables:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/node:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/removeall:go_default_library", @@ -149,6 +148,7 @@ go_library( "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/integer:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/net:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", ] + select({ @@ -214,7 +214,6 @@ go_test( "//pkg/kubelet/util/sliceutils:go_default_library", "//pkg/kubelet/volumemanager:go_default_library", "//pkg/scheduler/nodeinfo:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/taints:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/awsebs:go_default_library", @@ -256,6 +255,7 @@ go_test( "//vendor/github.com/google/cadvisor/info/v2:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/require:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library", diff --git a/pkg/kubelet/cm/BUILD b/pkg/kubelet/cm/BUILD index 10270839aa7..7b57d09c324 100644 --- a/pkg/kubelet/cm/BUILD +++ b/pkg/kubelet/cm/BUILD @@ -58,7 +58,6 @@ go_library( "//pkg/kubelet/qos:go_default_library", "//pkg/kubelet/stats/pidlimit:go_default_library", "//pkg/kubelet/types:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/procfs:go_default_library", "//pkg/util/sysctl:go_default_library", @@ -73,27 +72,28 @@ go_library( "//vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library", "//vendor/k8s.io/utils/io:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", ], "@io_bazel_rules_go//go/platform:darwin": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:dragonfly": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:freebsd": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:ios": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ "//pkg/api/v1/resource:go_default_library", @@ -108,7 +108,6 @@ go_library( "//pkg/kubelet/qos:go_default_library", "//pkg/kubelet/stats/pidlimit:go_default_library", "//pkg/kubelet/types:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/procfs:go_default_library", "//pkg/util/sysctl:go_default_library", @@ -123,37 +122,38 @@ go_library( "//vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library", "//vendor/k8s.io/utils/io:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", ], "@io_bazel_rules_go//go/platform:nacl": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:netbsd": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:openbsd": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:plan9": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:solaris": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ "//pkg/kubelet/cadvisor:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), @@ -174,7 +174,6 @@ go_test( "@io_bazel_rules_go//go/platform:android": [ "//pkg/features:go_default_library", "//pkg/kubelet/eviction/api:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", @@ -182,11 +181,11 @@ go_test( "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/require:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ "//pkg/features:go_default_library", "//pkg/kubelet/eviction/api:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", @@ -194,6 +193,7 @@ go_test( "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/require:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), diff --git a/pkg/kubelet/cm/container_manager_linux.go b/pkg/kubelet/cm/container_manager_linux.go index 8dcdc5f1249..81d3a015639 100644 --- a/pkg/kubelet/cm/container_manager_linux.go +++ b/pkg/kubelet/cm/container_manager_linux.go @@ -33,6 +33,9 @@ import ( "github.com/opencontainers/runc/libcontainer/cgroups/fs" "github.com/opencontainers/runc/libcontainer/configs" "k8s.io/klog" + utilio "k8s.io/utils/io" + "k8s.io/utils/mount" + utilpath "k8s.io/utils/path" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -59,12 +62,9 @@ import ( "k8s.io/kubernetes/pkg/kubelet/stats/pidlimit" "k8s.io/kubernetes/pkg/kubelet/status" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/util/procfs" utilsysctl "k8s.io/kubernetes/pkg/util/sysctl" - utilio "k8s.io/utils/io" - utilpath "k8s.io/utils/path" ) const ( diff --git a/pkg/kubelet/cm/container_manager_linux_test.go b/pkg/kubelet/cm/container_manager_linux_test.go index 832266cf600..ce885868a33 100644 --- a/pkg/kubelet/cm/container_manager_linux_test.go +++ b/pkg/kubelet/cm/container_manager_linux_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) func fakeContainerMgrMountInt() mount.Interface { diff --git a/pkg/kubelet/cm/container_manager_unsupported.go b/pkg/kubelet/cm/container_manager_unsupported.go index 2e02cf5d20a..d59afa81e50 100644 --- a/pkg/kubelet/cm/container_manager_unsupported.go +++ b/pkg/kubelet/cm/container_manager_unsupported.go @@ -21,13 +21,14 @@ package cm import ( "fmt" - "k8s.io/api/core/v1" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/record" internalapi "k8s.io/cri-api/pkg/apis" "k8s.io/kubernetes/pkg/kubelet/cadvisor" "k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/status" - "k8s.io/kubernetes/pkg/util/mount" ) type unsupportedContainerManager struct { diff --git a/pkg/kubelet/cm/container_manager_windows.go b/pkg/kubelet/cm/container_manager_windows.go index 55f172171e6..e4a88b86b9b 100644 --- a/pkg/kubelet/cm/container_manager_windows.go +++ b/pkg/kubelet/cm/container_manager_windows.go @@ -24,12 +24,14 @@ package cm import ( "fmt" + "k8s.io/klog" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/tools/record" internalapi "k8s.io/cri-api/pkg/apis" - "k8s.io/klog" kubefeatures "k8s.io/kubernetes/pkg/features" podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1" "k8s.io/kubernetes/pkg/kubelet/cadvisor" @@ -41,7 +43,6 @@ import ( "k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache" "k8s.io/kubernetes/pkg/kubelet/status" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" - "k8s.io/kubernetes/pkg/util/mount" ) type containerManagerImpl struct { diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 8de35755185..f77ad998876 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -33,6 +33,11 @@ import ( "time" cadvisorapi "github.com/google/cadvisor/info/v1" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/integer" + "k8s.io/utils/mount" + utilnet "k8s.io/utils/net" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -108,7 +113,6 @@ import ( "k8s.io/kubernetes/pkg/security/apparmor" sysctlwhitelist "k8s.io/kubernetes/pkg/security/podsecuritypolicy/sysctl" utilipt "k8s.io/kubernetes/pkg/util/iptables" - "k8s.io/kubernetes/pkg/util/mount" nodeutil "k8s.io/kubernetes/pkg/util/node" "k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/util/selinux" @@ -117,9 +121,6 @@ import ( "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/util/subpath" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilexec "k8s.io/utils/exec" - "k8s.io/utils/integer" - utilnet "k8s.io/utils/net" ) const ( diff --git a/pkg/kubelet/kubelet_getters.go b/pkg/kubelet/kubelet_getters.go index 5335d61e084..1554972f9f4 100644 --- a/pkg/kubelet/kubelet_getters.go +++ b/pkg/kubelet/kubelet_getters.go @@ -24,16 +24,16 @@ import ( "path/filepath" cadvisorapiv1 "github.com/google/cadvisor/info/v1" - v1 "k8s.io/api/core/v1" "k8s.io/klog" + "k8s.io/utils/mount" + utilpath "k8s.io/utils/path" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/kubelet/cm" "k8s.io/kubernetes/pkg/kubelet/config" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" - "k8s.io/kubernetes/pkg/util/mount" utilnode "k8s.io/kubernetes/pkg/util/node" - utilpath "k8s.io/utils/path" ) // getRootDir returns the full path to the directory under which kubelet can diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 329d7238eaa..c42b35be7e3 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -27,6 +27,8 @@ import ( cadvisorapi "github.com/google/cadvisor/info/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -67,7 +69,6 @@ import ( "k8s.io/kubernetes/pkg/kubelet/util/queue" kubeletvolume "k8s.io/kubernetes/pkg/kubelet/volumemanager" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/awsebs" "k8s.io/kubernetes/pkg/volume/azure_dd" diff --git a/pkg/kubelet/runonce_test.go b/pkg/kubelet/runonce_test.go index 80a34209784..bea0ba78589 100644 --- a/pkg/kubelet/runonce_test.go +++ b/pkg/kubelet/runonce_test.go @@ -23,6 +23,8 @@ import ( cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapiv2 "github.com/google/cadvisor/info/v2" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -43,7 +45,6 @@ import ( "k8s.io/kubernetes/pkg/kubelet/status" statustest "k8s.io/kubernetes/pkg/kubelet/status/testing" "k8s.io/kubernetes/pkg/kubelet/volumemanager" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util/hostutil" diff --git a/pkg/kubelet/volume_host.go b/pkg/kubelet/volume_host.go index da5c2563d38..5556d0cc714 100644 --- a/pkg/kubelet/volume_host.go +++ b/pkg/kubelet/volume_host.go @@ -22,6 +22,8 @@ import ( "runtime" "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" @@ -34,13 +36,10 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" cloudprovider "k8s.io/cloud-provider" - utilexec "k8s.io/utils/exec" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/kubelet/configmap" "k8s.io/kubernetes/pkg/kubelet/secret" "k8s.io/kubernetes/pkg/kubelet/token" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" diff --git a/pkg/kubelet/volumemanager/BUILD b/pkg/kubelet/volumemanager/BUILD index 9603d1daef4..df2965a5321 100644 --- a/pkg/kubelet/volumemanager/BUILD +++ b/pkg/kubelet/volumemanager/BUILD @@ -23,7 +23,6 @@ go_library( "//pkg/kubelet/volumemanager/metrics:go_default_library", "//pkg/kubelet/volumemanager/populator:go_default_library", "//pkg/kubelet/volumemanager/reconciler:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/csimigration:go_default_library", "//pkg/volume/util:go_default_library", @@ -40,6 +39,7 @@ go_library( "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) @@ -57,7 +57,6 @@ go_test( "//pkg/kubelet/secret:go_default_library", "//pkg/kubelet/status:go_default_library", "//pkg/kubelet/status/testing:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -73,6 +72,7 @@ go_test( "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/kubelet/volumemanager/reconciler/BUILD b/pkg/kubelet/volumemanager/reconciler/BUILD index 523ca37a03d..f70e7a9090c 100644 --- a/pkg/kubelet/volumemanager/reconciler/BUILD +++ b/pkg/kubelet/volumemanager/reconciler/BUILD @@ -15,7 +15,6 @@ go_library( "//pkg/kubelet/config:go_default_library", "//pkg/kubelet/volumemanager/cache:go_default_library", "//pkg/util/goroutinemap/exponentialbackoff:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -29,6 +28,7 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], @@ -41,7 +41,6 @@ go_test( deps = [ "//pkg/features:go_default_library", "//pkg/kubelet/volumemanager/cache:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -60,6 +59,7 @@ go_test( "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler.go b/pkg/kubelet/volumemanager/reconciler/reconciler.go index 8b89448dcde..3524446d5d4 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler.go @@ -27,26 +27,27 @@ import ( "path/filepath" "time" + "k8s.io/klog" + "k8s.io/utils/mount" + utilpath "k8s.io/utils/path" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" utilfeature "k8s.io/apiserver/pkg/util/feature" clientset "k8s.io/client-go/kubernetes" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/volumemanager/cache" "k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff" - "k8s.io/kubernetes/pkg/util/mount" volumepkg "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/util/nestedpendingoperations" "k8s.io/kubernetes/pkg/volume/util/operationexecutor" volumetypes "k8s.io/kubernetes/pkg/volume/util/types" - utilpath "k8s.io/utils/path" - utilstrings "k8s.io/utils/strings" ) // Reconciler runs a periodic loop to reconcile the desired state of the world diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go index 255a073e11c..0fccd8d7567 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go @@ -22,6 +22,9 @@ import ( "time" "github.com/stretchr/testify/assert" + "k8s.io/klog" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -33,10 +36,8 @@ import ( core "k8s.io/client-go/testing" "k8s.io/client-go/tools/record" featuregatetesting "k8s.io/component-base/featuregate/testing" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/kubelet/volumemanager/cache" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetesting "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/kubelet/volumemanager/volume_manager.go b/pkg/kubelet/volumemanager/volume_manager.go index 5b349ffefe9..3fe144a073f 100644 --- a/pkg/kubelet/volumemanager/volume_manager.go +++ b/pkg/kubelet/volumemanager/volume_manager.go @@ -24,6 +24,9 @@ import ( "strings" "time" + "k8s.io/klog" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" @@ -32,7 +35,6 @@ import ( clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/record" csitrans "k8s.io/csi-translation-lib" - "k8s.io/klog" "k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/pkg/kubelet/pod" @@ -42,7 +44,6 @@ import ( "k8s.io/kubernetes/pkg/kubelet/volumemanager/metrics" "k8s.io/kubernetes/pkg/kubelet/volumemanager/populator" "k8s.io/kubernetes/pkg/kubelet/volumemanager/reconciler" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/csimigration" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/kubelet/volumemanager/volume_manager_test.go b/pkg/kubelet/volumemanager/volume_manager_test.go index ade545a2180..6eaabf55a9c 100644 --- a/pkg/kubelet/volumemanager/volume_manager_test.go +++ b/pkg/kubelet/volumemanager/volume_manager_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" @@ -42,7 +44,6 @@ import ( "k8s.io/kubernetes/pkg/kubelet/secret" "k8s.io/kubernetes/pkg/kubelet/status" statustest "k8s.io/kubernetes/pkg/kubelet/status/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/kubemark/BUILD b/pkg/kubemark/BUILD index ccb01672b27..8db94cf6a0e 100644 --- a/pkg/kubemark/BUILD +++ b/pkg/kubemark/BUILD @@ -28,7 +28,6 @@ go_library( "//pkg/proxy/config:go_default_library", "//pkg/proxy/iptables:go_default_library", "//pkg/util/iptables:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/node:go_default_library", "//pkg/util/oom:go_default_library", "//pkg/util/sysctl:go_default_library", @@ -70,6 +69,7 @@ go_library( "//test/utils:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/pointer:go_default_library", ], ) diff --git a/pkg/kubemark/hollow_kubelet.go b/pkg/kubemark/hollow_kubelet.go index 431a42f8567..3b3706f7f32 100644 --- a/pkg/kubemark/hollow_kubelet.go +++ b/pkg/kubemark/hollow_kubelet.go @@ -20,6 +20,9 @@ import ( "fmt" "time" + "k8s.io/klog" + "k8s.io/utils/mount" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" kubeletapp "k8s.io/kubernetes/cmd/kubelet/app" @@ -31,7 +34,6 @@ import ( containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" "k8s.io/kubernetes/pkg/kubelet/dockershim" kubetypes "k8s.io/kubernetes/pkg/kubelet/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/cephfs" @@ -57,8 +59,6 @@ import ( "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/util/subpath" "k8s.io/kubernetes/test/utils" - - "k8s.io/klog" ) type HollowKubelet struct { diff --git a/pkg/util/BUILD b/pkg/util/BUILD index 00b09527503..e1dfbbb4f5b 100644 --- a/pkg/util/BUILD +++ b/pkg/util/BUILD @@ -31,7 +31,6 @@ filegroup( "//pkg/util/ipvs:all-srcs", "//pkg/util/labels:all-srcs", "//pkg/util/maps:all-srcs", - "//pkg/util/mount:all-srcs", "//pkg/util/netsh:all-srcs", "//pkg/util/node:all-srcs", "//pkg/util/oom:all-srcs", diff --git a/pkg/util/mount/fake_exec.go b/pkg/util/mount/fake_exec.go deleted file mode 100644 index 35b637c0e54..00000000000 --- a/pkg/util/mount/fake_exec.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -// NewFakeExec returns a new FakeExec -func NewFakeExec(run runHook) *FakeExec { - return &FakeExec{runHook: run} -} - -// FakeExec for testing. -type FakeExec struct { - runHook runHook -} -type runHook func(cmd string, args ...string) ([]byte, error) - -// Run executes the command using the optional runhook, if given -func (f *FakeExec) Run(cmd string, args ...string) ([]byte, error) { - if f.runHook != nil { - return f.runHook(cmd, args...) - } - return nil, nil -} diff --git a/pkg/util/mount/mount_helper_test.go b/pkg/util/mount/mount_helper_test.go deleted file mode 100644 index 91be5cf956a..00000000000 --- a/pkg/util/mount/mount_helper_test.go +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "runtime" - "syscall" - "testing" -) - -func TestDoCleanupMountPoint(t *testing.T) { - - if runtime.GOOS == "darwin" { - t.Skipf("not supported on GOOS=%s", runtime.GOOS) - } - - const testMount = "test-mount" - const defaultPerm = 0750 - - tests := map[string]struct { - corruptedMnt bool - // Function that prepares the directory structure for the test under - // the given base directory. - // Returns a fake MountPoint, a fake error for the mount point, - // and error if the prepare function encountered a fatal error. - prepare func(base string) (MountPoint, error, error) - expectErr bool - }{ - "mount-ok": { - prepare: func(base string) (MountPoint, error, error) { - path := filepath.Join(base, testMount) - if err := os.MkdirAll(path, defaultPerm); err != nil { - return MountPoint{}, nil, err - } - return MountPoint{Device: "/dev/sdb", Path: path}, nil, nil - }, - }, - "mount-corrupted": { - prepare: func(base string) (MountPoint, error, error) { - path := filepath.Join(base, testMount) - if err := os.MkdirAll(path, defaultPerm); err != nil { - return MountPoint{}, nil, err - } - return MountPoint{Device: "/dev/sdb", Path: path}, os.NewSyscallError("fake", syscall.ESTALE), nil - }, - corruptedMnt: true, - }, - "mount-err-not-corrupted": { - prepare: func(base string) (MountPoint, error, error) { - path := filepath.Join(base, testMount) - if err := os.MkdirAll(path, defaultPerm); err != nil { - return MountPoint{}, nil, err - } - return MountPoint{Device: "/dev/sdb", Path: path}, os.NewSyscallError("fake", syscall.ETIMEDOUT), nil - }, - expectErr: true, - }, - } - - for name, tt := range tests { - t.Run(name, func(t *testing.T) { - - tmpDir, err := ioutil.TempDir("", "unmount-mount-point-test") - if err != nil { - t.Fatalf("failed to create tmpdir: %v", err) - } - defer os.RemoveAll(tmpDir) - - if tt.prepare == nil { - t.Fatalf("prepare function required") - } - - mountPoint, mountError, err := tt.prepare(tmpDir) - if err != nil { - t.Fatalf("failed to prepare test: %v", err) - } - - fake := NewFakeMounter( - []MountPoint{mountPoint}, - ) - fake.MountCheckErrors = map[string]error{mountPoint.Path: mountError} - - err = doCleanupMountPoint(mountPoint.Path, fake, true, tt.corruptedMnt) - if tt.expectErr { - if err == nil { - t.Errorf("test %s failed, expected error, got none", name) - } - if err := validateDirExists(mountPoint.Path); err != nil { - t.Errorf("test %s failed, mount path doesn't exist: %v", name, err) - } - } - if !tt.expectErr { - if err != nil { - t.Errorf("test %s failed: %v", name, err) - } - if err := validateDirNotExists(mountPoint.Path); err != nil { - t.Errorf("test %s failed, mount path still exists: %v", name, err) - } - } - }) - } -} - -func validateDirExists(dir string) error { - _, err := ioutil.ReadDir(dir) - if err != nil { - return err - } - return nil -} - -func validateDirNotExists(dir string) error { - _, err := ioutil.ReadDir(dir) - if os.IsNotExist(err) { - return nil - } - if err != nil { - return err - } - return fmt.Errorf("dir %q still exists", dir) -} diff --git a/pkg/util/mount/mount_helper_unix_test.go b/pkg/util/mount/mount_helper_unix_test.go deleted file mode 100644 index f364b02863c..00000000000 --- a/pkg/util/mount/mount_helper_unix_test.go +++ /dev/null @@ -1,215 +0,0 @@ -// +build !windows - -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "io/ioutil" - "os" - "path/filepath" - "reflect" - "testing" -) - -func writeFile(content string) (string, string, error) { - tempDir, err := ioutil.TempDir("", "mounter_shared_test") - if err != nil { - return "", "", err - } - filename := filepath.Join(tempDir, "mountinfo") - err = ioutil.WriteFile(filename, []byte(content), 0600) - if err != nil { - os.RemoveAll(tempDir) - return "", "", err - } - return tempDir, filename, nil -} - -func TestParseMountInfo(t *testing.T) { - info := - `62 0 253:0 / / rw,relatime shared:1 - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered -78 62 0:41 / /tmp rw,nosuid,nodev shared:30 - tmpfs tmpfs rw,seclabel -80 62 0:42 / /var/lib/nfs/rpc_pipefs rw,relatime shared:31 - rpc_pipefs sunrpc rw -82 62 0:43 / /var/lib/foo rw,relatime shared:32 - tmpfs tmpfs rw -83 63 0:44 / /var/lib/bar rw,relatime - tmpfs tmpfs rw -227 62 253:0 /var/lib/docker/devicemapper /var/lib/docker/devicemapper rw,relatime - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered -224 62 253:0 /var/lib/docker/devicemapper/test/shared /var/lib/docker/devicemapper/test/shared rw,relatime master:1 shared:44 - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered -76 17 8:1 / /mnt/stateful_partition rw,nosuid,nodev,noexec,relatime - ext4 /dev/sda1 rw,commit=30,data=ordered -80 17 8:1 /var /var rw,nosuid,nodev,noexec,relatime shared:30 - ext4 /dev/sda1 rw,commit=30,data=ordered -189 80 8:1 /var/lib/kubelet /var/lib/kubelet rw,relatime shared:30 - ext4 /dev/sda1 rw,commit=30,data=ordered -818 77 8:40 / /var/lib/kubelet/pods/c25464af-e52e-11e7-ab4d-42010a800002/volumes/kubernetes.io~gce-pd/vol1 rw,relatime shared:290 - ext4 /dev/sdc rw,data=ordered -819 78 8:48 / /var/lib/kubelet/pods/c25464af-e52e-11e7-ab4d-42010a800002/volumes/kubernetes.io~gce-pd/vol1 rw,relatime shared:290 - ext4 /dev/sdd rw,data=ordered -900 100 8:48 /dir1 /var/lib/kubelet/pods/c25464af-e52e-11e7-ab4d-42010a800002/volume-subpaths/vol1/subpath1/0 rw,relatime shared:290 - ext4 /dev/sdd rw,data=ordered -901 101 8:1 /dir1 /var/lib/kubelet/pods/c25464af-e52e-11e7-ab4d-42010a800002/volume-subpaths/vol1/subpath1/1 rw,relatime shared:290 - ext4 /dev/sdd rw,data=ordered -902 102 8:1 /var/lib/kubelet/pods/d4076f24-e53a-11e7-ba15-42010a800002/volumes/kubernetes.io~empty-dir/vol1/dir1 /var/lib/kubelet/pods/d4076f24-e53a-11e7-ba15-42010a800002/volume-subpaths/vol1/subpath1/0 rw,relatime shared:30 - ext4 /dev/sda1 rw,commit=30,data=ordered -903 103 8:1 /var/lib/kubelet/pods/d4076f24-e53a-11e7-ba15-42010a800002/volumes/kubernetes.io~empty-dir/vol2/dir1 /var/lib/kubelet/pods/d4076f24-e53a-11e7-ba15-42010a800002/volume-subpaths/vol1/subpath1/1 rw,relatime shared:30 - ext4 /dev/sda1 rw,commit=30,data=ordered -178 25 253:0 /etc/bar /var/lib/kubelet/pods/12345/volume-subpaths/vol1/subpath1/0 rw,relatime shared:1 - ext4 /dev/sdb2 rw,errors=remount-ro,data=ordered -698 186 0:41 /tmp1/dir1 /var/lib/kubelet/pods/41135147-e697-11e7-9342-42010a800002/volume-subpaths/vol1/subpath1/0 rw shared:26 - tmpfs tmpfs rw -918 77 8:50 / /var/lib/kubelet/pods/2345/volumes/kubernetes.io~gce-pd/vol1 rw,relatime shared:290 - ext4 /dev/sdc rw,data=ordered -919 78 8:58 / /var/lib/kubelet/pods/2345/volumes/kubernetes.io~gce-pd/vol1 rw,relatime shared:290 - ext4 /dev/sdd rw,data=ordered -920 100 8:50 /dir1 /var/lib/kubelet/pods/2345/volume-subpaths/vol1/subpath1/0 rw,relatime shared:290 - ext4 /dev/sdc rw,data=ordered -150 23 1:58 / /media/nfs_vol rw,relatime shared:89 - nfs4 172.18.4.223:/srv/nfs rw,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.4.223,local_lock=none,addr=172.18.4.223 -151 24 1:58 / /media/nfs_bindmount rw,relatime shared:89 - nfs4 172.18.4.223:/srv/nfs/foo rw,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.4.223,local_lock=none,addr=172.18.4.223 -134 23 0:58 / /var/lib/kubelet/pods/43219158-e5e1-11e7-a392-0e858b8eaf40/volumes/kubernetes.io~nfs/nfs1 rw,relatime shared:89 - nfs4 172.18.4.223:/srv/nfs rw,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.4.223,local_lock=none,addr=172.18.4.223 -187 23 0:58 / /var/lib/kubelet/pods/1fc5ea21-eff4-11e7-ac80-0e858b8eaf40/volumes/kubernetes.io~nfs/nfs2 rw,relatime shared:96 - nfs4 172.18.4.223:/srv/nfs2 rw,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.4.223,local_lock=none,addr=172.18.4.223 -188 24 0:58 / /var/lib/kubelet/pods/43219158-e5e1-11e7-a392-0e858b8eaf40/volume-subpaths/nfs1/subpath1/0 rw,relatime shared:89 - nfs4 172.18.4.223:/srv/nfs/foo rw,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.4.223,local_lock=none,addr=172.18.4.223 -347 60 0:71 / /var/lib/kubelet/pods/13195d46-f9fa-11e7-bbf1-5254007a695a/volumes/kubernetes.io~nfs/vol2 rw,relatime shared:170 - nfs 172.17.0.3:/exports/2 rw,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=172.17.0.3,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=172.17.0.3 -222 24 253:0 /tmp/src /mnt/dst rw,relatime shared:1 - ext4 /dev/mapper/vagrant--vg-root rw,errors=remount-ro,data=ordered -28 18 0:24 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755 -29 28 0:25 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd -31 28 0:27 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,cpuset -32 28 0:28 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,cpu,cpuacct -33 28 0:29 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,freezer -34 28 0:30 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,net_cls,net_prio -35 28 0:31 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,pids -36 28 0:32 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,devices -37 28 0:33 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,hugetlb -38 28 0:34 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,blkio -39 28 0:35 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,memory -40 28 0:36 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,perf_event -` - tempDir, filename, err := writeFile(info) - if err != nil { - t.Fatalf("cannot create temporary file: %v", err) - } - defer os.RemoveAll(tempDir) - - tests := []struct { - name string - id int - expectedInfo MountInfo - }{ - { - "simple bind mount", - 189, - MountInfo{ - ID: 189, - ParentID: 80, - MajorMinor: "8:1", - Root: "/var/lib/kubelet", - Source: "/dev/sda1", - MountPoint: "/var/lib/kubelet", - OptionalFields: []string{"shared:30"}, - FsType: "ext4", - MountOptions: []string{"rw", "relatime"}, - SuperOptions: []string{"rw", "commit=30", "data=ordered"}, - }, - }, - { - "bind mount a directory", - 222, - MountInfo{ - ID: 222, - ParentID: 24, - MajorMinor: "253:0", - Root: "/tmp/src", - Source: "/dev/mapper/vagrant--vg-root", - MountPoint: "/mnt/dst", - OptionalFields: []string{"shared:1"}, - FsType: "ext4", - MountOptions: []string{"rw", "relatime"}, - SuperOptions: []string{"rw", "errors=remount-ro", "data=ordered"}, - }, - }, - { - "more than one optional fields", - 224, - MountInfo{ - ID: 224, - ParentID: 62, - MajorMinor: "253:0", - Root: "/var/lib/docker/devicemapper/test/shared", - Source: "/dev/mapper/ssd-root", - MountPoint: "/var/lib/docker/devicemapper/test/shared", - OptionalFields: []string{"master:1", "shared:44"}, - FsType: "ext4", - MountOptions: []string{"rw", "relatime"}, - SuperOptions: []string{"rw", "seclabel", "data=ordered"}, - }, - }, - { - "cgroup-mountpoint", - 28, - MountInfo{ - ID: 28, - ParentID: 18, - MajorMinor: "0:24", - Root: "/", - Source: "tmpfs", - MountPoint: "/sys/fs/cgroup", - OptionalFields: []string{"shared:9"}, - FsType: "tmpfs", - MountOptions: []string{"ro", "nosuid", "nodev", "noexec"}, - SuperOptions: []string{"ro", "mode=755"}, - }, - }, - { - "cgroup-subsystem-systemd-mountpoint", - 29, - MountInfo{ - ID: 29, - ParentID: 28, - MajorMinor: "0:25", - Root: "/", - Source: "cgroup", - MountPoint: "/sys/fs/cgroup/systemd", - OptionalFields: []string{"shared:10"}, - FsType: "cgroup", - MountOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}, - SuperOptions: []string{"rw", "xattr", "release_agent=/lib/systemd/systemd-cgroups-agent", "name=systemd"}, - }, - }, - { - "cgroup-subsystem-cpuset-mountpoint", - 31, - MountInfo{ - ID: 31, - ParentID: 28, - MajorMinor: "0:27", - Root: "/", - Source: "cgroup", - MountPoint: "/sys/fs/cgroup/cpuset", - OptionalFields: []string{"shared:13"}, - FsType: "cgroup", - MountOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}, - SuperOptions: []string{"rw", "cpuset"}, - }, - }, - } - - infos, err := ParseMountInfo(filename) - if err != nil { - t.Fatalf("Cannot parse %s: %s", filename, err) - } - - for _, test := range tests { - found := false - for _, info := range infos { - if info.ID == test.id { - found = true - if !reflect.DeepEqual(info, test.expectedInfo) { - t.Errorf("Test case %q:\n expected: %+v\n got: %+v", test.name, test.expectedInfo, info) - } - break - } - } - if !found { - t.Errorf("Test case %q: mountPoint %d not found", test.name, test.id) - } - } -} diff --git a/pkg/util/mount/mount_helper_windows_test.go b/pkg/util/mount/mount_helper_windows_test.go deleted file mode 100644 index 7f5e6eb1827..00000000000 --- a/pkg/util/mount/mount_helper_windows_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// +build windows - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "testing" -) - -func TestNormalizeWindowsPath(t *testing.T) { - path := `/var/lib/kubelet/pods/146f8428-83e7-11e7-8dd4-000d3a31dac4/volumes/kubernetes.io~azure-disk` - normalizedPath := NormalizeWindowsPath(path) - if normalizedPath != `c:\var\lib\kubelet\pods\146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~azure-disk` { - t.Errorf("normizeWindowsPath test failed, normalizedPath : %q", normalizedPath) - } - - path = `/var/lib/kubelet/pods/146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~azure-disk` - normalizedPath = NormalizeWindowsPath(path) - if normalizedPath != `c:\var\lib\kubelet\pods\146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~azure-disk` { - t.Errorf("normizeWindowsPath test failed, normalizedPath : %q", normalizedPath) - } - - path = `/` - normalizedPath = NormalizeWindowsPath(path) - if normalizedPath != `c:\` { - t.Errorf("normizeWindowsPath test failed, normalizedPath : %q", normalizedPath) - } -} - -func TestValidateDiskNumber(t *testing.T) { - diskNum := "0" - if err := ValidateDiskNumber(diskNum); err != nil { - t.Errorf("TestValidateDiskNumber test failed, disk number : %s", diskNum) - } - - diskNum = "99" - if err := ValidateDiskNumber(diskNum); err != nil { - t.Errorf("TestValidateDiskNumber test failed, disk number : %s", diskNum) - } - - diskNum = "ab" - if err := ValidateDiskNumber(diskNum); err == nil { - t.Errorf("TestValidateDiskNumber test failed, disk number : %s", diskNum) - } - - diskNum = "100" - if err := ValidateDiskNumber(diskNum); err == nil { - t.Errorf("TestValidateDiskNumber test failed, disk number : %s", diskNum) - } -} diff --git a/pkg/util/mount/mount_linux_test.go b/pkg/util/mount/mount_linux_test.go deleted file mode 100644 index 47b6e31a04c..00000000000 --- a/pkg/util/mount/mount_linux_test.go +++ /dev/null @@ -1,439 +0,0 @@ -// +build linux - -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "io/ioutil" - "os" - "reflect" - "testing" -) - -func TestReadProcMountsFrom(t *testing.T) { - successCase := - `/dev/0 /path/to/0 type0 flags 0 0 -/dev/1 /path/to/1 type1 flags 1 1 -/dev/2 /path/to/2 type2 flags,1,2=3 2 2 -` - // NOTE: readProcMountsFrom has been updated to using fnv.New32a() - mounts, err := parseProcMounts([]byte(successCase)) - if err != nil { - t.Errorf("expected success, got %v", err) - } - if len(mounts) != 3 { - t.Fatalf("expected 3 mounts, got %d", len(mounts)) - } - mp := MountPoint{"/dev/0", "/path/to/0", "type0", []string{"flags"}, 0, 0} - if !mountPointsEqual(&mounts[0], &mp) { - t.Errorf("got unexpected MountPoint[0]: %#v", mounts[0]) - } - mp = MountPoint{"/dev/1", "/path/to/1", "type1", []string{"flags"}, 1, 1} - if !mountPointsEqual(&mounts[1], &mp) { - t.Errorf("got unexpected MountPoint[1]: %#v", mounts[1]) - } - mp = MountPoint{"/dev/2", "/path/to/2", "type2", []string{"flags", "1", "2=3"}, 2, 2} - if !mountPointsEqual(&mounts[2], &mp) { - t.Errorf("got unexpected MountPoint[2]: %#v", mounts[2]) - } - - errorCases := []string{ - "/dev/0 /path/to/mount\n", - "/dev/1 /path/to/mount type flags a 0\n", - "/dev/2 /path/to/mount type flags 0 b\n", - } - for _, ec := range errorCases { - _, err := parseProcMounts([]byte(ec)) - if err == nil { - t.Errorf("expected error") - } - } -} - -func mountPointsEqual(a, b *MountPoint) bool { - if a.Device != b.Device || a.Path != b.Path || a.Type != b.Type || !reflect.DeepEqual(a.Opts, b.Opts) || a.Pass != b.Pass || a.Freq != b.Freq { - return false - } - return true -} - -func TestGetMountRefs(t *testing.T) { - fm := NewFakeMounter( - []MountPoint{ - {Device: "/dev/sdb", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd"}, - {Device: "/dev/sdb", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2"}, - }) - - tests := []struct { - mountPath string - expectedRefs []string - }{ - { - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod", - []string{ - "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd", - }, - }, - { - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1", - []string{ - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2", - "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2", - }, - }, - { - "/var/fake/directory/that/doesnt/exist", - []string{}, - }, - } - - for i, test := range tests { - if refs, err := fm.GetMountRefs(test.mountPath); err != nil || !setEquivalent(test.expectedRefs, refs) { - t.Errorf("%d. getMountRefs(%q) = %v, %v; expected %v, nil", i, test.mountPath, refs, err, test.expectedRefs) - } - } -} - -func setEquivalent(set1, set2 []string) bool { - map1 := make(map[string]bool) - map2 := make(map[string]bool) - for _, s := range set1 { - map1[s] = true - } - for _, s := range set2 { - map2[s] = true - } - - for s := range map1 { - if !map2[s] { - return false - } - } - for s := range map2 { - if !map1[s] { - return false - } - } - return true -} - -func TestGetDeviceNameFromMount(t *testing.T) { - fm := NewFakeMounter( - []MountPoint{ - {Device: "/dev/disk/by-path/prefix-lun-1", - Path: "/mnt/111"}, - {Device: "/dev/disk/by-path/prefix-lun-1", - Path: "/mnt/222"}, - }) - - tests := []struct { - mountPath string - expectedDevice string - expectedRefs int - }{ - { - "/mnt/222", - "/dev/disk/by-path/prefix-lun-1", - 2, - }, - } - - for i, test := range tests { - if device, refs, err := GetDeviceNameFromMount(fm, test.mountPath); err != nil || test.expectedRefs != refs || test.expectedDevice != device { - t.Errorf("%d. GetDeviceNameFromMount(%s) = (%s, %d), %v; expected (%s,%d), nil", i, test.mountPath, device, refs, err, test.expectedDevice, test.expectedRefs) - } - } -} - -func TestGetMountRefsByDev(t *testing.T) { - fm := NewFakeMounter( - []MountPoint{ - {Device: "/dev/sdb", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd"}, - {Device: "/dev/sdb", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1"}, - {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2"}, - }) - - tests := []struct { - mountPath string - expectedRefs []string - }{ - { - "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd", - []string{ - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod", - }, - }, - { - "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2", - []string{ - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1", - "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2", - }, - }, - } - - for i, test := range tests { - - if refs, err := getMountRefsByDev(fm, test.mountPath); err != nil || !setEquivalent(test.expectedRefs, refs) { - t.Errorf("%d. getMountRefsByDev(%q) = %v, %v; expected %v, nil", i, test.mountPath, refs, err, test.expectedRefs) - } - } -} - -func TestPathWithinBase(t *testing.T) { - tests := []struct { - name string - fullPath string - basePath string - expected bool - }{ - { - name: "good subpath", - fullPath: "/a/b/c", - basePath: "/a", - expected: true, - }, - { - name: "good subpath 2", - fullPath: "/a/b/c", - basePath: "/a/b", - expected: true, - }, - { - name: "good subpath end slash", - fullPath: "/a/b/c/", - basePath: "/a/b", - expected: true, - }, - { - name: "good subpath backticks", - fullPath: "/a/b/../c", - basePath: "/a", - expected: true, - }, - { - name: "good subpath equal", - fullPath: "/a/b/c", - basePath: "/a/b/c", - expected: true, - }, - { - name: "good subpath equal 2", - fullPath: "/a/b/c/", - basePath: "/a/b/c", - expected: true, - }, - { - name: "good subpath root", - fullPath: "/a", - basePath: "/", - expected: true, - }, - { - name: "bad subpath parent", - fullPath: "/a/b/c", - basePath: "/a/b/c/d", - expected: false, - }, - { - name: "bad subpath outside", - fullPath: "/b/c", - basePath: "/a/b/c", - expected: false, - }, - { - name: "bad subpath prefix", - fullPath: "/a/b/cd", - basePath: "/a/b/c", - expected: false, - }, - { - name: "bad subpath backticks", - fullPath: "/a/../b", - basePath: "/a", - expected: false, - }, - { - name: "configmap subpath", - fullPath: "/var/lib/kubelet/pods/uuid/volumes/kubernetes.io~configmap/config/..timestamp/file.txt", - basePath: "/var/lib/kubelet/pods/uuid/volumes/kubernetes.io~configmap/config", - expected: true, - }, - } - for _, test := range tests { - if PathWithinBase(test.fullPath, test.basePath) != test.expected { - t.Errorf("test %q failed: expected %v", test.name, test.expected) - } - - } -} - -func TestSearchMountPoints(t *testing.T) { - base := ` -19 25 0:18 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw -20 25 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw -21 25 0:6 / /dev rw,nosuid,relatime shared:2 - devtmpfs udev rw,size=4058156k,nr_inodes=1014539,mode=755 -22 21 0:14 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 -23 25 0:19 / /run rw,nosuid,noexec,relatime shared:5 - tmpfs tmpfs rw,size=815692k,mode=755 -25 0 252:0 / / rw,relatime shared:1 - ext4 /dev/mapper/ubuntu--vg-root rw,errors=remount-ro,data=ordered -26 19 0:12 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw -27 21 0:21 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw -28 23 0:22 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k -29 19 0:23 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755 -30 29 0:24 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd -31 19 0:25 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:11 - pstore pstore rw -32 29 0:26 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,devices -33 29 0:27 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,freezer -34 29 0:28 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,pids -35 29 0:29 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,blkio -36 29 0:30 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,memory -37 29 0:31 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,perf_event -38 29 0:32 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,hugetlb -39 29 0:33 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,cpu,cpuacct -40 29 0:34 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,cpuset -41 29 0:35 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,net_cls,net_prio -58 25 7:1 / /mnt/disks/blkvol1 rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordere -` - - testcases := []struct { - name string - source string - mountInfos string - expectedRefs []string - expectedErr error - }{ - { - "dir", - "/mnt/disks/vol1", - base, - nil, - nil, - }, - { - "dir-used", - "/mnt/disks/vol1", - base + ` -56 25 252:0 /mnt/disks/vol1 /var/lib/kubelet/pods/1890aef5-5a60-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test rw,relatime shared:1 - ext4 /dev/mapper/ubuntu--vg-root rw,errors=remount-ro,data=ordered -57 25 0:45 / /mnt/disks/vol rw,relatime shared:36 - tmpfs tmpfs rw -`, - []string{"/var/lib/kubelet/pods/1890aef5-5a60-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test"}, - nil, - }, - { - "tmpfs-vol", - "/mnt/disks/vol1", - base + `120 25 0:76 / /mnt/disks/vol1 rw,relatime shared:41 - tmpfs vol1 rw,size=10000k -`, - nil, - nil, - }, - { - "tmpfs-vol-used-by-two-pods", - "/mnt/disks/vol1", - base + `120 25 0:76 / /mnt/disks/vol1 rw,relatime shared:41 - tmpfs vol1 rw,size=10000k -196 25 0:76 / /var/lib/kubelet/pods/ade3ac21-5a5b-11e8-8559-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-8f263585 rw,relatime shared:41 - tmpfs vol1 rw,size=10000k -228 25 0:76 / /var/lib/kubelet/pods/ac60532d-5a5b-11e8-8559-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-8f263585 rw,relatime shared:41 - tmpfs vol1 rw,size=10000k -`, - []string{ - "/var/lib/kubelet/pods/ade3ac21-5a5b-11e8-8559-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-8f263585", - "/var/lib/kubelet/pods/ac60532d-5a5b-11e8-8559-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-8f263585", - }, - nil, - }, - { - "tmpfs-subdir-used-indirectly-via-bindmount-dir-by-one-pod", - "/mnt/vol1/foo", - base + `177 25 0:46 / /mnt/data rw,relatime shared:37 - tmpfs data rw -190 25 0:46 /vol1 /mnt/vol1 rw,relatime shared:37 - tmpfs data rw -191 25 0:46 /vol2 /mnt/vol2 rw,relatime shared:37 - tmpfs data rw -62 25 0:46 /vol1/foo /var/lib/kubelet/pods/e25f2f01-5b06-11e8-8694-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test rw,relatime shared:37 - tmpfs data rw -`, - []string{"/var/lib/kubelet/pods/e25f2f01-5b06-11e8-8694-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test"}, - nil, - }, - { - "dir-bindmounted", - "/mnt/disks/vol2", - base + `342 25 252:0 /mnt/disks/vol2 /mnt/disks/vol2 rw,relatime shared:1 - ext4 /dev/mapper/ubuntu--vg-root rw,errors=remount-ro,data=ordered -`, - nil, - nil, - }, - { - "dir-bindmounted-used-by-one-pod", - "/mnt/disks/vol2", - base + `342 25 252:0 /mnt/disks/vol2 /mnt/disks/vol2 rw,relatime shared:1 - ext4 /dev/mapper/ubuntu--vg-root rw,errors=remount-ro,data=ordered -77 25 252:0 /mnt/disks/vol2 /var/lib/kubelet/pods/f30dc360-5a5d-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-1fb30a1c rw,relatime shared:1 - ext4 /dev/mapper/ubuntu--vg-root rw,errors=remount-ro,data=ordered -`, - []string{"/var/lib/kubelet/pods/f30dc360-5a5d-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-1fb30a1c"}, - nil, - }, - { - "blockfs", - "/mnt/disks/blkvol1", - base + `58 25 7:1 / /mnt/disks/blkvol1 rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -`, - nil, - nil, - }, - { - "blockfs-used-by-one-pod", - "/mnt/disks/blkvol1", - base + `58 25 7:1 / /mnt/disks/blkvol1 rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -62 25 7:1 / /var/lib/kubelet/pods/f19fe4e2-5a63-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -`, - []string{"/var/lib/kubelet/pods/f19fe4e2-5a63-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test"}, - nil, - }, - { - "blockfs-used-by-two-pods", - "/mnt/disks/blkvol1", - base + `58 25 7:1 / /mnt/disks/blkvol1 rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -62 25 7:1 / /var/lib/kubelet/pods/f19fe4e2-5a63-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -95 25 7:1 / /var/lib/kubelet/pods/4854a48b-5a64-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test rw,relatime shared:38 - ext4 /dev/loop1 rw,data=ordered -`, - []string{"/var/lib/kubelet/pods/f19fe4e2-5a63-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test", - "/var/lib/kubelet/pods/4854a48b-5a64-11e8-962f-000c29bb0377/volumes/kubernetes.io~local-volume/local-pv-test"}, - nil, - }, - } - tmpFile, err := ioutil.TempFile("", "test-get-filetype") - if err != nil { - t.Fatal(err) - } - defer os.Remove(tmpFile.Name()) - defer tmpFile.Close() - for _, v := range testcases { - tmpFile.Truncate(0) - tmpFile.Seek(0, 0) - tmpFile.WriteString(v.mountInfos) - tmpFile.Sync() - refs, err := SearchMountPoints(v.source, tmpFile.Name()) - if !reflect.DeepEqual(refs, v.expectedRefs) { - t.Errorf("test %q: expected Refs: %#v, got %#v", v.name, v.expectedRefs, refs) - } - if !reflect.DeepEqual(err, v.expectedErr) { - t.Errorf("test %q: expected err: %v, got %v", v.name, v.expectedErr, err) - } - } -} diff --git a/pkg/util/mount/mount_test.go b/pkg/util/mount/mount_test.go deleted file mode 100644 index 6b9d5d5fc4b..00000000000 --- a/pkg/util/mount/mount_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "reflect" - "testing" -) - -func TestMakeBindOpts(t *testing.T) { - tests := []struct { - mountOption []string - isBind bool - expectedBindOpts []string - expectedRemountOpts []string - }{ - { - []string{"vers=2", "ro", "_netdev"}, - false, - []string{}, - []string{}, - }, - { - - []string{"bind", "vers=2", "ro", "_netdev"}, - true, - []string{"bind", "_netdev"}, - []string{"bind", "remount", "vers=2", "ro", "_netdev"}, - }, - } - for _, test := range tests { - bind, bindOpts, bindRemountOpts := MakeBindOpts(test.mountOption) - if bind != test.isBind { - t.Errorf("Expected bind to be %v but got %v", test.isBind, bind) - } - if test.isBind { - if !reflect.DeepEqual(test.expectedBindOpts, bindOpts) { - t.Errorf("Expected bind mount options to be %+v got %+v", test.expectedBindOpts, bindOpts) - } - if !reflect.DeepEqual(test.expectedRemountOpts, bindRemountOpts) { - t.Errorf("Expected remount options to be %+v got %+v", test.expectedRemountOpts, bindRemountOpts) - } - } - - } -} diff --git a/pkg/util/mount/mount_windows_test.go b/pkg/util/mount/mount_windows_test.go deleted file mode 100644 index 288cc633518..00000000000 --- a/pkg/util/mount/mount_windows_test.go +++ /dev/null @@ -1,333 +0,0 @@ -// +build windows - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "k8s.io/utils/exec/testing" -) - -func makeLink(link, target string) error { - if output, err := exec.Command("cmd", "/c", "mklink", "/D", link, target).CombinedOutput(); err != nil { - return fmt.Errorf("mklink failed: %v, link(%q) target(%q) output: %q", err, link, target, string(output)) - } - return nil -} - -func removeLink(link string) error { - if output, err := exec.Command("cmd", "/c", "rmdir", link).CombinedOutput(); err != nil { - return fmt.Errorf("rmdir failed: %v, output: %q", err, string(output)) - } - return nil -} - -func setEquivalent(set1, set2 []string) bool { - map1 := make(map[string]bool) - map2 := make(map[string]bool) - for _, s := range set1 { - map1[s] = true - } - for _, s := range set2 { - map2[s] = true - } - - for s := range map1 { - if !map2[s] { - return false - } - } - for s := range map2 { - if !map1[s] { - return false - } - } - return true -} - -// this func must run in admin mode, otherwise it will fail -func TestGetMountRefs(t *testing.T) { - tests := []struct { - mountPath string - expectedRefs []string - }{ - { - mountPath: `c:\windows`, - expectedRefs: []string{`c:\windows`}, - }, - { - mountPath: `c:\doesnotexist`, - expectedRefs: []string{}, - }, - } - - mounter := Mounter{"fake/path"} - - for _, test := range tests { - if refs, err := mounter.GetMountRefs(test.mountPath); err != nil || !setEquivalent(test.expectedRefs, refs) { - t.Errorf("getMountRefs(%q) = %v, error: %v; expected %v", test.mountPath, refs, err, test.expectedRefs) - } - } -} - -func TestPathWithinBase(t *testing.T) { - tests := []struct { - fullPath string - basePath string - expectedResult bool - }{ - { - fullPath: `c:\tmp\a\b\c`, - basePath: `c:\tmp`, - expectedResult: true, - }, - { - fullPath: `c:\tmp1`, - basePath: `c:\tmp2`, - expectedResult: false, - }, - { - fullPath: `c:\tmp`, - basePath: `c:\tmp`, - expectedResult: true, - }, - { - fullPath: `c:\tmp`, - basePath: `c:\tmp\a\b\c`, - expectedResult: false, - }, - { - fullPath: `c:\kubelet\pods\uuid\volumes\kubernetes.io~configmap\config\..timestamp\file.txt`, - basePath: `c:\kubelet\pods\uuid\volumes\kubernetes.io~configmap\config`, - expectedResult: true, - }, - } - - for _, test := range tests { - result := PathWithinBase(test.fullPath, test.basePath) - assert.Equal(t, result, test.expectedResult, "Expect result not equal with PathWithinBase(%s, %s) return: %q, expected: %q", - test.fullPath, test.basePath, result, test.expectedResult) - } -} - -func TestIsLikelyNotMountPoint(t *testing.T) { - mounter := Mounter{"fake/path"} - - tests := []struct { - fileName string - targetLinkName string - setUp func(base, fileName, targetLinkName string) error - expectedResult bool - expectError bool - }{ - { - "Dir", - "", - func(base, fileName, targetLinkName string) error { - return os.Mkdir(filepath.Join(base, fileName), 0750) - }, - true, - false, - }, - { - "InvalidDir", - "", - func(base, fileName, targetLinkName string) error { - return nil - }, - true, - true, - }, - { - "ValidSymLink", - "targetSymLink", - func(base, fileName, targetLinkName string) error { - targeLinkPath := filepath.Join(base, targetLinkName) - if err := os.Mkdir(targeLinkPath, 0750); err != nil { - return err - } - - filePath := filepath.Join(base, fileName) - if err := makeLink(filePath, targeLinkPath); err != nil { - return err - } - return nil - }, - false, - false, - }, - { - "InvalidSymLink", - "targetSymLink2", - func(base, fileName, targetLinkName string) error { - targeLinkPath := filepath.Join(base, targetLinkName) - if err := os.Mkdir(targeLinkPath, 0750); err != nil { - return err - } - - filePath := filepath.Join(base, fileName) - if err := makeLink(filePath, targeLinkPath); err != nil { - return err - } - return removeLink(targeLinkPath) - }, - true, - false, - }, - } - - for _, test := range tests { - base, err := ioutil.TempDir("", test.fileName) - if err != nil { - t.Fatalf(err.Error()) - } - - defer os.RemoveAll(base) - - if err := test.setUp(base, test.fileName, test.targetLinkName); err != nil { - t.Fatalf("unexpected error in setUp(%s, %s): %v", test.fileName, test.targetLinkName, err) - } - - filePath := filepath.Join(base, test.fileName) - result, err := mounter.IsLikelyNotMountPoint(filePath) - assert.Equal(t, result, test.expectedResult, "Expect result not equal with IsLikelyNotMountPoint(%s) return: %q, expected: %q", - filePath, result, test.expectedResult) - - if test.expectError { - assert.NotNil(t, err, "Expect error during IsLikelyNotMountPoint(%s)", filePath) - } else { - assert.Nil(t, err, "Expect error is nil during IsLikelyNotMountPoint(%s)", filePath) - } - } -} - -func TestFormatAndMount(t *testing.T) { - tests := []struct { - device string - target string - fstype string - execScripts []ExecArgs - mountOptions []string - expectError bool - }{ - { - device: "0", - target: "disk", - fstype: "NTFS", - execScripts: []ExecArgs{ - {"powershell", []string{"/c", "Get-Disk", "-Number"}, "0", nil}, - {"powershell", []string{"/c", "Get-Partition", "-DiskNumber"}, "0", nil}, - {"cmd", []string{"/c", "mklink", "/D"}, "", nil}, - }, - mountOptions: []string{}, - expectError: false, - }, - { - device: "0", - target: "disk", - fstype: "", - execScripts: []ExecArgs{ - {"powershell", []string{"/c", "Get-Disk", "-Number"}, "0", nil}, - {"powershell", []string{"/c", "Get-Partition", "-DiskNumber"}, "0", nil}, - {"cmd", []string{"/c", "mklink", "/D"}, "", nil}, - }, - mountOptions: []string{}, - expectError: false, - }, - { - device: "invalidDevice", - target: "disk", - fstype: "NTFS", - mountOptions: []string{}, - expectError: true, - }, - } - - for _, test := range tests { - fakeMounter := ErrorMounter{NewFakeMounter(nil), 0, nil} - fakeExec := &testingexec.FakeExec{} - for _, script := range test.execScripts { - fakeCmd := &testingexec.FakeCmd{} - cmdAction := makeFakeCmd(fakeCmd, script.command, script.args...) - outputAction := makeFakeOutput(script.output, script.err) - fakeCmd.CombinedOutputScript = append(fakeCmd.CombinedOutputScript, outputAction) - fakeExec.CommandScript = append(fakeExec.CommandScript, cmdAction) - } - mounter := SafeFormatAndMount{ - Interface: &fakeMounter, - Exec: fakeExec, - } - base, err := ioutil.TempDir("", test.device) - if err != nil { - t.Fatalf(err.Error()) - } - defer os.RemoveAll(base) - - target := filepath.Join(base, test.target) - err = mounter.FormatAndMount(test.device, target, test.fstype, test.mountOptions) - if test.expectError { - assert.NotNil(t, err, "Expect error during FormatAndMount(%s, %s, %s, %v)", test.device, test.target, test.fstype, test.mountOptions) - } else { - assert.Nil(t, err, "Expect error is nil during FormatAndMount(%s, %s, %s, %v)", test.device, test.target, test.fstype, test.mountOptions) - } - } -} - -func TestNewSMBMapping(t *testing.T) { - tests := []struct { - username string - password string - remotepath string - expectError bool - }{ - { - "", - "password", - `\\remotepath`, - true, - }, - { - "username", - "", - `\\remotepath`, - true, - }, - { - "username", - "password", - "", - true, - }, - } - - for _, test := range tests { - _, err := newSMBMapping(test.username, test.password, test.remotepath) - if test.expectError { - assert.NotNil(t, err, "Expect error during newSMBMapping(%s, %s, %s, %v)", test.username, test.password, test.remotepath) - } else { - assert.Nil(t, err, "Expect error is nil during newSMBMapping(%s, %s, %s, %v)", test.username, test.password, test.remotepath) - } - } -} diff --git a/pkg/util/mount/safe_format_and_mount_test.go b/pkg/util/mount/safe_format_and_mount_test.go deleted file mode 100644 index d6cc06bce58..00000000000 --- a/pkg/util/mount/safe_format_and_mount_test.go +++ /dev/null @@ -1,248 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "fmt" - "io/ioutil" - "os" - "runtime" - "strings" - "testing" - - "k8s.io/utils/exec" - "k8s.io/utils/exec/testing" -) - -type ErrorMounter struct { - *FakeMounter - errIndex int - err []error -} - -func (mounter *ErrorMounter) Mount(source string, target string, fstype string, options []string) error { - i := mounter.errIndex - mounter.errIndex++ - if mounter.err != nil && mounter.err[i] != nil { - return mounter.err[i] - } - return mounter.FakeMounter.Mount(source, target, fstype, options) -} - -type ExecArgs struct { - command string - args []string - output string - err error -} - -func TestSafeFormatAndMount(t *testing.T) { - if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { - t.Skipf("not supported on GOOS=%s", runtime.GOOS) - } - mntDir, err := ioutil.TempDir(os.TempDir(), "mount") - if err != nil { - t.Fatalf("failed to create tmp dir: %v", err) - } - defer os.RemoveAll(mntDir) - tests := []struct { - description string - fstype string - mountOptions []string - execScripts []ExecArgs - mountErrs []error - expectedError error - }{ - { - description: "Test a read only mount", - fstype: "ext4", - mountOptions: []string{"ro"}, - }, - { - description: "Test a normal mount", - fstype: "ext4", - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - }, - }, - { - description: "Test 'fsck' fails with exit status 4", - fstype: "ext4", - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 4}}, - }, - expectedError: fmt.Errorf("'fsck' found errors on device /dev/foo but could not correct them"), - }, - { - description: "Test 'fsck' fails with exit status 1 (errors found and corrected)", - fstype: "ext4", - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 1}}, - }, - }, - { - description: "Test 'fsck' fails with exit status other than 1 and 4 (likely unformatted device)", - fstype: "ext4", - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 8}}, - }, - }, - { - description: "Test that 'blkid' is called and fails", - fstype: "ext4", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'")}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "DEVNAME=/dev/foo\nTYPE=ext4\n", nil}, - }, - expectedError: fmt.Errorf("unknown filesystem type '(null)'"), - }, - { - description: "Test that 'blkid' is called and confirms unformatted disk, format fails", - fstype: "ext4", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'")}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}}, - {"mkfs.ext4", []string{"-F", "-m0", "/dev/foo"}, "", fmt.Errorf("formatting failed")}, - }, - expectedError: fmt.Errorf("formatting failed"), - }, - { - description: "Test that 'blkid' is called and confirms unformatted disk, format passes, second mount fails", - fstype: "ext4", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), fmt.Errorf("Still cannot mount")}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}}, - {"mkfs.ext4", []string{"-F", "-m0", "/dev/foo"}, "", nil}, - }, - expectedError: fmt.Errorf("Still cannot mount"), - }, - { - description: "Test that 'blkid' is called and confirms unformatted disk, format passes, second mount passes", - fstype: "ext4", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), nil}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}}, - {"mkfs.ext4", []string{"-F", "-m0", "/dev/foo"}, "", nil}, - }, - expectedError: nil, - }, - { - description: "Test that 'blkid' is called and confirms unformatted disk, format passes, second mount passes with ext3", - fstype: "ext3", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), nil}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}}, - {"mkfs.ext3", []string{"-F", "-m0", "/dev/foo"}, "", nil}, - }, - expectedError: nil, - }, - { - description: "test that none ext4 fs does not get called with ext4 options.", - fstype: "xfs", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), nil}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}}, - {"mkfs.xfs", []string{"/dev/foo"}, "", nil}, - }, - expectedError: nil, - }, - { - description: "Test that 'blkid' is called and reports ext4 partition", - fstype: "ext3", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'")}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "DEVNAME=/dev/foo\nPTTYPE=dos\n", nil}, - }, - expectedError: fmt.Errorf("failed to mount the volume as \"ext3\", it already contains unknown data, probably partitions. Mount error: unknown filesystem type '(null)'"), - }, - { - description: "Test that 'blkid' is called but has some usage or other errors (an exit code of 4 is returned)", - fstype: "xfs", - mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), nil}, - execScripts: []ExecArgs{ - {"fsck", []string{"-a", "/dev/foo"}, "", nil}, - {"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 4}}, - {"mkfs.xfs", []string{"/dev/foo"}, "", nil}, - }, - expectedError: fmt.Errorf("exit 4"), - }, - } - - for _, test := range tests { - fakeMounter := ErrorMounter{NewFakeMounter(nil), 0, test.mountErrs} - fakeExec := &testingexec.FakeExec{ExactOrder: true} - for _, script := range test.execScripts { - fakeCmd := &testingexec.FakeCmd{} - cmdAction := makeFakeCmd(fakeCmd, script.command, script.args...) - outputAction := makeFakeOutput(script.output, script.err) - fakeCmd.CombinedOutputScript = append(fakeCmd.CombinedOutputScript, outputAction) - fakeExec.CommandScript = append(fakeExec.CommandScript, cmdAction) - } - mounter := SafeFormatAndMount{ - Interface: &fakeMounter, - Exec: fakeExec, - } - - device := "/dev/foo" - dest := mntDir - err := mounter.FormatAndMount(device, dest, test.fstype, test.mountOptions) - if test.expectedError == nil { - if err != nil { - t.Errorf("test \"%s\" unexpected non-error: %v", test.description, err) - } - - // Check that something was mounted on the directory - isNotMountPoint, err := fakeMounter.IsLikelyNotMountPoint(dest) - if err != nil || isNotMountPoint { - t.Errorf("test \"%s\" the directory was not mounted", test.description) - } - - //check that the correct device was mounted - mountedDevice, _, err := GetDeviceNameFromMount(fakeMounter.FakeMounter, dest) - if err != nil || mountedDevice != device { - t.Errorf("test \"%s\" the correct device was not mounted", test.description) - } - } else { - if err == nil || !strings.HasPrefix(err.Error(), test.expectedError.Error()) { - t.Errorf("test \"%s\" unexpected error: \n [%v]. \nExpecting [%v]", test.description, err, test.expectedError) - } - } - } -} - -func makeFakeCmd(fakeCmd *testingexec.FakeCmd, cmd string, args ...string) testingexec.FakeCommandAction { - c := cmd - a := args - return func(cmd string, args ...string) exec.Cmd { - command := testingexec.InitFakeCmd(fakeCmd, c, a...) - return command - } -} - -func makeFakeOutput(output string, err error) testingexec.FakeCombinedOutputAction { - o := output - return func() ([]byte, error) { - return []byte(o), err - } -} diff --git a/pkg/util/removeall/BUILD b/pkg/util/removeall/BUILD index 9cdce022b72..7b1fe6cc87b 100644 --- a/pkg/util/removeall/BUILD +++ b/pkg/util/removeall/BUILD @@ -11,8 +11,8 @@ go_test( srcs = ["removeall_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) @@ -20,7 +20,7 @@ go_library( name = "go_default_library", srcs = ["removeall.go"], importpath = "k8s.io/kubernetes/pkg/util/removeall", - deps = ["//pkg/util/mount:go_default_library"], + deps = ["//vendor/k8s.io/utils/mount:go_default_library"], ) filegroup( diff --git a/pkg/util/removeall/removeall.go b/pkg/util/removeall/removeall.go index fa15ac1bdd3..66717ee29d0 100644 --- a/pkg/util/removeall/removeall.go +++ b/pkg/util/removeall/removeall.go @@ -22,7 +22,7 @@ import ( "os" "syscall" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // RemoveAllOneFilesystem removes path and any children it contains. diff --git a/pkg/util/removeall/removeall_test.go b/pkg/util/removeall/removeall_test.go index 07db7718ed0..8fbdf733f14 100644 --- a/pkg/util/removeall/removeall_test.go +++ b/pkg/util/removeall/removeall_test.go @@ -24,7 +24,7 @@ import ( "testing" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) type fakeMounter struct { diff --git a/pkg/util/resizefs/BUILD b/pkg/util/resizefs/BUILD index 17411ac74fd..b4144f1255e 100644 --- a/pkg/util/resizefs/BUILD +++ b/pkg/util/resizefs/BUILD @@ -10,42 +10,42 @@ go_library( visibility = ["//visibility:public"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:darwin": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:dragonfly": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:freebsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:ios": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:nacl": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:netbsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:openbsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:plan9": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:solaris": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), diff --git a/pkg/util/resizefs/resizefs_linux.go b/pkg/util/resizefs/resizefs_linux.go index 1d2d5e0fca9..5ec8a387766 100644 --- a/pkg/util/resizefs/resizefs_linux.go +++ b/pkg/util/resizefs/resizefs_linux.go @@ -22,7 +22,7 @@ import ( "fmt" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // ResizeFs Provides support for resizing file systems diff --git a/pkg/util/resizefs/resizefs_unsupported.go b/pkg/util/resizefs/resizefs_unsupported.go index dd4dd017e82..cde1d4ca082 100644 --- a/pkg/util/resizefs/resizefs_unsupported.go +++ b/pkg/util/resizefs/resizefs_unsupported.go @@ -21,7 +21,7 @@ package resizefs import ( "fmt" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // ResizeFs Provides support for resizing file systems diff --git a/pkg/volume/BUILD b/pkg/volume/BUILD index bba57a77212..8e608ecc467 100644 --- a/pkg/volume/BUILD +++ b/pkg/volume/BUILD @@ -19,7 +19,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume/util/fs:go_default_library", "//pkg/volume/util/hostutil:go_default_library", "//pkg/volume/util/recyclerclient:go_default_library", @@ -41,6 +40,7 @@ go_library( "//staging/src/k8s.io/cloud-provider:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/awsebs/BUILD b/pkg/volume/awsebs/BUILD index 5e21539885d..0a64e9943ea 100644 --- a/pkg/volume/awsebs/BUILD +++ b/pkg/volume/awsebs/BUILD @@ -21,7 +21,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/awsebs", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -35,6 +34,7 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/aws:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -48,7 +48,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -61,6 +60,7 @@ go_test( "//staging/src/k8s.io/legacy-cloud-providers/aws:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/awsebs/attacher.go b/pkg/volume/awsebs/attacher.go index 365ebb3e082..35bf55df8fe 100644 --- a/pkg/volume/awsebs/attacher.go +++ b/pkg/volume/awsebs/attacher.go @@ -28,10 +28,10 @@ import ( "time" "k8s.io/klog" + "k8s.io/utils/mount" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/aws" diff --git a/pkg/volume/awsebs/aws_ebs.go b/pkg/volume/awsebs/aws_ebs.go index 7666a1b0cf5..7bae0358e34 100644 --- a/pkg/volume/awsebs/aws_ebs.go +++ b/pkg/volume/awsebs/aws_ebs.go @@ -29,6 +29,7 @@ import ( "strings" "k8s.io/klog" + "k8s.io/utils/mount" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -36,7 +37,6 @@ import ( "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/aws" diff --git a/pkg/volume/awsebs/aws_ebs_block.go b/pkg/volume/awsebs/aws_ebs_block.go index 6adfc7b9305..86e380288e6 100644 --- a/pkg/volume/awsebs/aws_ebs_block.go +++ b/pkg/volume/awsebs/aws_ebs_block.go @@ -24,14 +24,15 @@ import ( "strconv" "strings" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" "k8s.io/legacy-cloud-providers/aws" - utilstrings "k8s.io/utils/strings" ) var _ volume.BlockVolumePlugin = &awsElasticBlockStorePlugin{} diff --git a/pkg/volume/awsebs/aws_ebs_test.go b/pkg/volume/awsebs/aws_ebs_test.go index f6fb3a6ec21..67caef29a29 100644 --- a/pkg/volume/awsebs/aws_ebs_test.go +++ b/pkg/volume/awsebs/aws_ebs_test.go @@ -26,13 +26,14 @@ import ( "testing" "github.com/stretchr/testify/assert" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/legacy-cloud-providers/aws" diff --git a/pkg/volume/awsebs/aws_util.go b/pkg/volume/awsebs/aws_util.go index 148881aa98f..be53866ee06 100644 --- a/pkg/volume/awsebs/aws_util.go +++ b/pkg/volume/awsebs/aws_util.go @@ -27,6 +27,7 @@ import ( "time" "k8s.io/klog" + "k8s.io/utils/mount" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -34,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/util/sets" cloudprovider "k8s.io/cloud-provider" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/aws" diff --git a/pkg/volume/azure_dd/BUILD b/pkg/volume/azure_dd/BUILD index ed072b52ef5..9e607d94ef0 100644 --- a/pkg/volume/azure_dd/BUILD +++ b/pkg/volume/azure_dd/BUILD @@ -25,7 +25,6 @@ go_library( deps = [ "//pkg/apis/core:go_default_library", "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -42,6 +41,7 @@ go_library( "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ diff --git a/pkg/volume/azure_dd/attacher.go b/pkg/volume/azure_dd/attacher.go index 28592bc7e94..42296172f0d 100644 --- a/pkg/volume/azure_dd/attacher.go +++ b/pkg/volume/azure_dd/attacher.go @@ -29,12 +29,12 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" "k8s.io/klog" + "k8s.io/utils/mount" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/azure" diff --git a/pkg/volume/azure_dd/azure_common_windows.go b/pkg/volume/azure_dd/azure_common_windows.go index 502e8c3cc9b..0b8f9004d68 100644 --- a/pkg/volume/azure_dd/azure_common_windows.go +++ b/pkg/volume/azure_dd/azure_common_windows.go @@ -27,8 +27,7 @@ import ( "k8s.io/klog" utilexec "k8s.io/utils/exec" - - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) func scsiHostRescan(io ioHandler, exec utilexec.Interface) { diff --git a/pkg/volume/azure_dd/azure_dd_block.go b/pkg/volume/azure_dd/azure_dd_block.go index b9aaa36316a..d610afd06d7 100644 --- a/pkg/volume/azure_dd/azure_dd_block.go +++ b/pkg/volume/azure_dd/azure_dd_block.go @@ -22,14 +22,15 @@ import ( "fmt" "path/filepath" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) var _ volume.VolumePlugin = &azureDataDiskPlugin{} diff --git a/pkg/volume/azure_dd/azure_mounter.go b/pkg/volume/azure_dd/azure_mounter.go index f2ed18c5d92..2f8d38bd0aa 100644 --- a/pkg/volume/azure_dd/azure_mounter.go +++ b/pkg/volume/azure_dd/azure_mounter.go @@ -23,9 +23,10 @@ import ( "os" "runtime" - "k8s.io/api/core/v1" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/azure_file/BUILD b/pkg/volume/azure_file/BUILD index 656bc65e0cf..1c4640f78a0 100644 --- a/pkg/volume/azure_file/BUILD +++ b/pkg/volume/azure_file/BUILD @@ -1,10 +1,4 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", @@ -15,8 +9,8 @@ go_library( "doc.go", ], importpath = "k8s.io/kubernetes/pkg/volume/azure_file", + visibility = ["//visibility:public"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -29,6 +23,7 @@ go_library( "//staging/src/k8s.io/legacy-cloud-providers/azure:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -38,7 +33,6 @@ go_test( srcs = ["azure_file_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -48,6 +42,7 @@ go_test( "//staging/src/k8s.io/cloud-provider/fake:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/azure:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) @@ -62,4 +57,5 @@ filegroup( name = "all-srcs", srcs = [":package-srcs"], tags = ["automanaged"], + visibility = ["//visibility:public"], ) diff --git a/pkg/volume/azure_file/azure_file.go b/pkg/volume/azure_file/azure_file.go index dfbb5ebd49f..cd1a13ba369 100644 --- a/pkg/volume/azure_file/azure_file.go +++ b/pkg/volume/azure_file/azure_file.go @@ -24,18 +24,19 @@ import ( "os" "runtime" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" cloudprovider "k8s.io/cloud-provider" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/azure" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary endpoint for volume plugins diff --git a/pkg/volume/azure_file/azure_file_test.go b/pkg/volume/azure_file/azure_file_test.go index 8608237ddc2..ff6dfdf44e6 100644 --- a/pkg/volume/azure_file/azure_file_test.go +++ b/pkg/volume/azure_file/azure_file_test.go @@ -33,7 +33,8 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" fakecloud "k8s.io/cloud-provider/fake" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/legacy-cloud-providers/azure" diff --git a/pkg/volume/cephfs/BUILD b/pkg/volume/cephfs/BUILD index 993481194dc..b521e4b48c9 100644 --- a/pkg/volume/cephfs/BUILD +++ b/pkg/volume/cephfs/BUILD @@ -14,13 +14,13 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/cephfs", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -30,12 +30,12 @@ go_test( srcs = ["cephfs_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/cephfs/cephfs.go b/pkg/volume/cephfs/cephfs.go index 91142b5ee01..4ba29214fd9 100644 --- a/pkg/volume/cephfs/cephfs.go +++ b/pkg/volume/cephfs/cephfs.go @@ -24,14 +24,15 @@ import ( "runtime" "strings" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/cephfs/cephfs_test.go b/pkg/volume/cephfs/cephfs_test.go index 53ad6a8d480..66bbef17e0f 100644 --- a/pkg/volume/cephfs/cephfs_test.go +++ b/pkg/volume/cephfs/cephfs_test.go @@ -21,10 +21,11 @@ import ( "path/filepath" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/cinder/BUILD b/pkg/volume/cinder/BUILD index a51e18c3d9f..6d8674c91d3 100644 --- a/pkg/volume/cinder/BUILD +++ b/pkg/volume/cinder/BUILD @@ -18,7 +18,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/cinder", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -36,6 +35,7 @@ go_library( "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -49,7 +49,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -61,6 +60,7 @@ go_test( "//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/openstack:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/cinder/attacher.go b/pkg/volume/cinder/attacher.go index d7ddb29dc1e..ebf84d31d0f 100644 --- a/pkg/volume/cinder/attacher.go +++ b/pkg/volume/cinder/attacher.go @@ -26,11 +26,12 @@ import ( "strings" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/cinder/cinder.go b/pkg/volume/cinder/cinder.go index 8aa3f336d87..d09baeb0caa 100644 --- a/pkg/volume/cinder/cinder.go +++ b/pkg/volume/cinder/cinder.go @@ -25,20 +25,21 @@ import ( "path" "path/filepath" + "k8s.io/klog" + "k8s.io/utils/keymutex" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/openstack" - "k8s.io/utils/keymutex" - utilstrings "k8s.io/utils/strings" ) const ( diff --git a/pkg/volume/cinder/cinder_block.go b/pkg/volume/cinder/cinder_block.go index de53b985d89..5c4273b95b0 100644 --- a/pkg/volume/cinder/cinder_block.go +++ b/pkg/volume/cinder/cinder_block.go @@ -22,14 +22,15 @@ import ( "fmt" "path/filepath" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) var _ volume.VolumePlugin = &cinderPlugin{} diff --git a/pkg/volume/cinder/cinder_test.go b/pkg/volume/cinder/cinder_test.go index 11f968b0e62..72a69fd3f83 100644 --- a/pkg/volume/cinder/cinder_test.go +++ b/pkg/volume/cinder/cinder_test.go @@ -28,7 +28,8 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/volume/configmap/BUILD b/pkg/volume/configmap/BUILD index a8329fa8b07..ab7d2571142 100644 --- a/pkg/volume/configmap/BUILD +++ b/pkg/volume/configmap/BUILD @@ -14,7 +14,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/configmap", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -22,6 +21,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/configmap/configmap.go b/pkg/volume/configmap/configmap.go index 450fe1f7f85..7b0d900f16e 100644 --- a/pkg/volume/configmap/configmap.go +++ b/pkg/volume/configmap/configmap.go @@ -19,15 +19,16 @@ package configmap import ( "fmt" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the entry point for plugin detection in a package. diff --git a/pkg/volume/emptydir/BUILD b/pkg/volume/emptydir/BUILD index effeea9615a..c4a58fda540 100644 --- a/pkg/volume/emptydir/BUILD +++ b/pkg/volume/emptydir/BUILD @@ -17,7 +17,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/emptydir", deps = [ "//pkg/apis/core/v1/helper:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/fsquota:go_default_library", @@ -26,6 +25,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ @@ -44,7 +44,6 @@ go_test( embed = [":go_default_library"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -53,9 +52,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -64,6 +63,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), diff --git a/pkg/volume/emptydir/empty_dir.go b/pkg/volume/emptydir/empty_dir.go index 4ac5f2a18df..607705aea9f 100644 --- a/pkg/volume/emptydir/empty_dir.go +++ b/pkg/volume/emptydir/empty_dir.go @@ -21,17 +21,18 @@ import ( "os" "path/filepath" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/fsquota" - utilstrings "k8s.io/utils/strings" ) // TODO: in the near future, this will be changed to be more restrictive diff --git a/pkg/volume/emptydir/empty_dir_linux.go b/pkg/volume/emptydir/empty_dir_linux.go index 3f8b1628274..93b48e27dc6 100644 --- a/pkg/volume/emptydir/empty_dir_linux.go +++ b/pkg/volume/emptydir/empty_dir_linux.go @@ -23,9 +23,9 @@ import ( "golang.org/x/sys/unix" "k8s.io/klog" + "k8s.io/utils/mount" - "k8s.io/api/core/v1" - "k8s.io/kubernetes/pkg/util/mount" + v1 "k8s.io/api/core/v1" ) // Defined by Linux - the type number for tmpfs mounts. diff --git a/pkg/volume/emptydir/empty_dir_test.go b/pkg/volume/emptydir/empty_dir_test.go index 07debcb7a6e..fe2c5db8c19 100644 --- a/pkg/volume/emptydir/empty_dir_test.go +++ b/pkg/volume/emptydir/empty_dir_test.go @@ -23,12 +23,13 @@ import ( "path/filepath" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util" diff --git a/pkg/volume/emptydir/empty_dir_unsupported.go b/pkg/volume/emptydir/empty_dir_unsupported.go index caeb6a77182..b048f76081a 100644 --- a/pkg/volume/emptydir/empty_dir_unsupported.go +++ b/pkg/volume/emptydir/empty_dir_unsupported.go @@ -19,8 +19,9 @@ limitations under the License. package emptydir import ( - "k8s.io/api/core/v1" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" ) // realMountDetector pretends to implement mediumer. diff --git a/pkg/volume/fc/BUILD b/pkg/volume/fc/BUILD index ccc2d64e772..dd16c9f27b3 100644 --- a/pkg/volume/fc/BUILD +++ b/pkg/volume/fc/BUILD @@ -18,7 +18,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/fc", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -28,6 +27,7 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -40,7 +40,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util:go_default_library", @@ -50,6 +49,7 @@ go_test( "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//vendor/k8s.io/utils/exec/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/fc/attacher.go b/pkg/volume/fc/attacher.go index 356399330f1..4a431fd9928 100644 --- a/pkg/volume/fc/attacher.go +++ b/pkg/volume/fc/attacher.go @@ -23,12 +23,13 @@ import ( "strings" "time" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/fc/disk_manager.go b/pkg/volume/fc/disk_manager.go index 602b7aa0bdb..8ad90f11b8f 100644 --- a/pkg/volume/fc/disk_manager.go +++ b/pkg/volume/fc/disk_manager.go @@ -20,7 +20,8 @@ import ( "os" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/fc/fc.go b/pkg/volume/fc/fc.go index cf4a1d0508d..dfc2aa9d062 100644 --- a/pkg/volume/fc/fc.go +++ b/pkg/volume/fc/fc.go @@ -23,19 +23,19 @@ import ( "strconv" "strings" - "k8s.io/api/core/v1" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/klog" - utilexec "k8s.io/utils/exec" - "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/fc/fc_test.go b/pkg/volume/fc/fc_test.go index b0d3bfe3265..356e9810f79 100644 --- a/pkg/volume/fc/fc_test.go +++ b/pkg/volume/fc/fc_test.go @@ -24,14 +24,14 @@ import ( "strings" "testing" + "k8s.io/utils/exec/testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/utils/exec/testing" - - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/fc/fc_util.go b/pkg/volume/fc/fc_util.go index de5d52ca5a0..9fec400e8f1 100644 --- a/pkg/volume/fc/fc_util.go +++ b/pkg/volume/fc/fc_util.go @@ -24,11 +24,12 @@ import ( "strconv" "strings" - "k8s.io/api/core/v1" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/flexvolume/BUILD b/pkg/volume/flexvolume/BUILD index 6af91d59242..9cb8aceaa93 100644 --- a/pkg/volume/flexvolume/BUILD +++ b/pkg/volume/flexvolume/BUILD @@ -30,7 +30,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/flexvolume", deps = [ "//pkg/util/filesystem:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -40,6 +39,7 @@ go_library( "//vendor/github.com/fsnotify/fsnotify:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -60,7 +60,6 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/util/filesystem:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -72,6 +71,7 @@ go_test( "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/exec/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/flexvolume/attacher-defaults.go b/pkg/volume/flexvolume/attacher-defaults.go index 3c82f264b91..876ddc00b91 100644 --- a/pkg/volume/flexvolume/attacher-defaults.go +++ b/pkg/volume/flexvolume/attacher-defaults.go @@ -20,9 +20,9 @@ import ( "time" "k8s.io/klog" + "k8s.io/utils/mount" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" ) diff --git a/pkg/volume/flexvolume/detacher-defaults.go b/pkg/volume/flexvolume/detacher-defaults.go index 134f26da059..323164300b7 100644 --- a/pkg/volume/flexvolume/detacher-defaults.go +++ b/pkg/volume/flexvolume/detacher-defaults.go @@ -19,9 +19,10 @@ package flexvolume import ( "time" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + "k8s.io/apimachinery/pkg/types" ) type detacherDefaults flexVolumeDetacher diff --git a/pkg/volume/flexvolume/detacher.go b/pkg/volume/flexvolume/detacher.go index 39ff9770436..6fe368b2437 100644 --- a/pkg/volume/flexvolume/detacher.go +++ b/pkg/volume/flexvolume/detacher.go @@ -20,9 +20,10 @@ import ( "fmt" "os" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/volume" ) diff --git a/pkg/volume/flexvolume/mounter_test.go b/pkg/volume/flexvolume/mounter_test.go index ef2970bccd3..4e806c90c9f 100644 --- a/pkg/volume/flexvolume/mounter_test.go +++ b/pkg/volume/flexvolume/mounter_test.go @@ -19,10 +19,11 @@ package flexvolume import ( "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/test/utils/harness" ) diff --git a/pkg/volume/flexvolume/plugin.go b/pkg/volume/flexvolume/plugin.go index a1204098e19..6ca9ba7dc55 100644 --- a/pkg/volume/flexvolume/plugin.go +++ b/pkg/volume/flexvolume/plugin.go @@ -26,10 +26,10 @@ import ( api "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/utils/exec" + "k8s.io/utils/mount" utilstrings "k8s.io/utils/strings" ) diff --git a/pkg/volume/flexvolume/unmounter-defaults.go b/pkg/volume/flexvolume/unmounter-defaults.go index e3f05f0ec87..8eca3ad9748 100644 --- a/pkg/volume/flexvolume/unmounter-defaults.go +++ b/pkg/volume/flexvolume/unmounter-defaults.go @@ -18,7 +18,7 @@ package flexvolume import ( "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) type unmounterDefaults flexVolumeUnmounter diff --git a/pkg/volume/flexvolume/unmounter.go b/pkg/volume/flexvolume/unmounter.go index 9435f2c2c46..7970cb77a2c 100644 --- a/pkg/volume/flexvolume/unmounter.go +++ b/pkg/volume/flexvolume/unmounter.go @@ -21,9 +21,10 @@ import ( "os" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" "k8s.io/utils/exec" + "k8s.io/utils/mount" + + "k8s.io/kubernetes/pkg/volume" ) // FlexVolumeUnmounter is the disk that will be cleaned by this plugin. diff --git a/pkg/volume/flexvolume/unmounter_test.go b/pkg/volume/flexvolume/unmounter_test.go index 0e5bf04023a..41c07433558 100644 --- a/pkg/volume/flexvolume/unmounter_test.go +++ b/pkg/volume/flexvolume/unmounter_test.go @@ -19,8 +19,9 @@ package flexvolume import ( "testing" + "k8s.io/utils/mount" + "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/test/utils/harness" ) diff --git a/pkg/volume/flexvolume/util.go b/pkg/volume/flexvolume/util.go index 4a3019e25e3..c38b858e6f9 100644 --- a/pkg/volume/flexvolume/util.go +++ b/pkg/volume/flexvolume/util.go @@ -22,7 +22,8 @@ import ( "os" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/flexvolume/volume.go b/pkg/volume/flexvolume/volume.go index 7e718f072a2..5f0c47542b4 100644 --- a/pkg/volume/flexvolume/volume.go +++ b/pkg/volume/flexvolume/volume.go @@ -17,10 +17,11 @@ limitations under the License. package flexvolume import ( - "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" + "k8s.io/utils/mount" utilstrings "k8s.io/utils/strings" + + "k8s.io/apimachinery/pkg/types" + "k8s.io/kubernetes/pkg/volume" ) type flexVolume struct { diff --git a/pkg/volume/flocker/BUILD b/pkg/volume/flocker/BUILD index 2f6c2b70a21..276ada39eed 100644 --- a/pkg/volume/flocker/BUILD +++ b/pkg/volume/flocker/BUILD @@ -17,7 +17,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/flocker", deps = [ "//pkg/util/env:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -28,6 +27,7 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", "//vendor/github.com/clusterhq/flocker-go:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -41,7 +41,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -50,6 +49,7 @@ go_test( "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//vendor/github.com/clusterhq/flocker-go:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/flocker/flocker.go b/pkg/volume/flocker/flocker.go index 353bf4c0148..723b28de4db 100644 --- a/pkg/volume/flocker/flocker.go +++ b/pkg/volume/flocker/flocker.go @@ -23,14 +23,14 @@ import ( "time" flockerapi "github.com/clusterhq/flocker-go" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/env" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" + "k8s.io/utils/mount" utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/kubernetes/pkg/util/env" + "k8s.io/kubernetes/pkg/volume" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/flocker/flocker_test.go b/pkg/volume/flocker/flocker_test.go index 6cccd1a3970..93fa28506e9 100644 --- a/pkg/volume/flocker/flocker_test.go +++ b/pkg/volume/flocker/flocker_test.go @@ -21,15 +21,15 @@ import ( "os" "testing" + flockerapi "github.com/clusterhq/flocker-go" + "github.com/stretchr/testify/assert" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" - - flockerapi "github.com/clusterhq/flocker-go" - "github.com/stretchr/testify/assert" ) const pluginName = "kubernetes.io/flocker" diff --git a/pkg/volume/gcepd/BUILD b/pkg/volume/gcepd/BUILD index 76ab8ca354f..cff495a05d4 100644 --- a/pkg/volume/gcepd/BUILD +++ b/pkg/volume/gcepd/BUILD @@ -18,7 +18,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/gcepd", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -34,6 +33,7 @@ go_library( "//staging/src/k8s.io/legacy-cloud-providers/gce:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], @@ -49,7 +49,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -63,6 +62,7 @@ go_test( "//staging/src/k8s.io/cloud-provider/volume:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/gcepd/attacher.go b/pkg/volume/gcepd/attacher.go index be53697f9f7..43c03564c59 100644 --- a/pkg/volume/gcepd/attacher.go +++ b/pkg/volume/gcepd/attacher.go @@ -29,13 +29,13 @@ import ( "strconv" "time" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/klog" - utilexec "k8s.io/utils/exec" - - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/gce" diff --git a/pkg/volume/gcepd/gce_pd.go b/pkg/volume/gcepd/gce_pd.go index cbc093669c1..a1f4eff61b1 100644 --- a/pkg/volume/gcepd/gce_pd.go +++ b/pkg/volume/gcepd/gce_pd.go @@ -27,19 +27,20 @@ import ( "strconv" "strings" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" gcecloud "k8s.io/legacy-cloud-providers/gce" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/gcepd/gce_pd_block.go b/pkg/volume/gcepd/gce_pd_block.go index dac6dd2da83..1f5be234734 100644 --- a/pkg/volume/gcepd/gce_pd_block.go +++ b/pkg/volume/gcepd/gce_pd_block.go @@ -23,14 +23,15 @@ import ( "path/filepath" "strconv" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) var _ volume.VolumePlugin = &gcePersistentDiskPlugin{} diff --git a/pkg/volume/gcepd/gce_pd_test.go b/pkg/volume/gcepd/gce_pd_test.go index ae6cabaa13c..e5a443945bc 100644 --- a/pkg/volume/gcepd/gce_pd_test.go +++ b/pkg/volume/gcepd/gce_pd_test.go @@ -26,13 +26,14 @@ import ( "sort" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/gcepd/gce_util.go b/pkg/volume/gcepd/gce_util.go index 146b208001d..ec2ab90db72 100644 --- a/pkg/volume/gcepd/gce_util.go +++ b/pkg/volume/gcepd/gce_util.go @@ -25,18 +25,19 @@ import ( "strings" "time" + "k8s.io/klog" + "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilpath "k8s.io/utils/path" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" cloudprovider "k8s.io/cloud-provider" cloudvolume "k8s.io/cloud-provider/volume" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" gcecloud "k8s.io/legacy-cloud-providers/gce" - "k8s.io/utils/exec" - utilpath "k8s.io/utils/path" ) const ( diff --git a/pkg/volume/glusterfs/BUILD b/pkg/volume/glusterfs/BUILD index 5774416506f..a7b6e671934 100644 --- a/pkg/volume/glusterfs/BUILD +++ b/pkg/volume/glusterfs/BUILD @@ -17,7 +17,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/glusterfs", deps = [ "//pkg/apis/core/v1/helper:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -33,6 +32,7 @@ go_library( "//vendor/github.com/heketi/heketi/client/api/go-client:go_default_library", "//vendor/github.com/heketi/heketi/pkg/glusterfs/api:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -45,7 +45,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -56,6 +55,7 @@ go_test( "//staging/src/k8s.io/client-go/testing:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//vendor/github.com/heketi/heketi/pkg/glusterfs/api:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 72e4fb68ae2..8067ba83344 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -30,6 +30,10 @@ import ( gcli "github.com/heketi/heketi/client/api/go-client" gapi "github.com/heketi/heketi/pkg/glusterfs/api" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -40,12 +44,9 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" clientset "k8s.io/client-go/kubernetes" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volutil "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/glusterfs/glusterfs_test.go b/pkg/volume/glusterfs/glusterfs_test.go index c79186c67cb..4ae81f58009 100644 --- a/pkg/volume/glusterfs/glusterfs_test.go +++ b/pkg/volume/glusterfs/glusterfs_test.go @@ -23,6 +23,8 @@ import ( "testing" gapi "github.com/heketi/heketi/pkg/glusterfs/api" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -30,7 +32,6 @@ import ( "k8s.io/client-go/kubernetes/fake" core "k8s.io/client-go/testing" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/hostpath/BUILD b/pkg/volume/hostpath/BUILD index 37cbe37ea01..0c2bd65bf3a 100644 --- a/pkg/volume/hostpath/BUILD +++ b/pkg/volume/hostpath/BUILD @@ -14,7 +14,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/hostpath", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -24,6 +23,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/hostpath/host_path.go b/pkg/volume/hostpath/host_path.go index 54bc282fb65..af10f49ed54 100644 --- a/pkg/volume/hostpath/host_path.go +++ b/pkg/volume/hostpath/host_path.go @@ -21,11 +21,12 @@ import ( "os" "regexp" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" diff --git a/pkg/volume/iscsi/BUILD b/pkg/volume/iscsi/BUILD index 252e40c4926..60d8dd0b0e1 100644 --- a/pkg/volume/iscsi/BUILD +++ b/pkg/volume/iscsi/BUILD @@ -19,7 +19,6 @@ go_library( deps = [ "//pkg/features:go_default_library", "//pkg/kubelet/config:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -30,6 +29,7 @@ go_library( "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -42,7 +42,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -51,6 +50,7 @@ go_test( "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//vendor/k8s.io/utils/exec/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/iscsi/attacher.go b/pkg/volume/iscsi/attacher.go index 5231414116c..7b3d439077e 100644 --- a/pkg/volume/iscsi/attacher.go +++ b/pkg/volume/iscsi/attacher.go @@ -21,15 +21,16 @@ import ( "os" "time" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/keymutex" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" - "k8s.io/utils/keymutex" ) type iscsiAttacher struct { diff --git a/pkg/volume/iscsi/disk_manager.go b/pkg/volume/iscsi/disk_manager.go index aff2045d7ff..dffd7050e46 100644 --- a/pkg/volume/iscsi/disk_manager.go +++ b/pkg/volume/iscsi/disk_manager.go @@ -20,7 +20,8 @@ import ( "os" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/iscsi/iscsi.go b/pkg/volume/iscsi/iscsi.go index f190359a5ca..957a90a331a 100644 --- a/pkg/volume/iscsi/iscsi.go +++ b/pkg/volume/iscsi/iscsi.go @@ -23,18 +23,18 @@ import ( "strconv" "strings" - "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" utilexec "k8s.io/utils/exec" + "k8s.io/utils/keymutex" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" - "k8s.io/kubernetes/pkg/util/mount" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/volume" ioutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - "k8s.io/utils/keymutex" - utilstrings "k8s.io/utils/strings" ) // This is the primary entrypoint for volume plugins. diff --git a/pkg/volume/iscsi/iscsi_test.go b/pkg/volume/iscsi/iscsi_test.go index a200e3100ae..6eea1e82584 100644 --- a/pkg/volume/iscsi/iscsi_test.go +++ b/pkg/volume/iscsi/iscsi_test.go @@ -22,14 +22,14 @@ import ( "strings" "testing" + "k8s.io/utils/exec/testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/utils/exec/testing" - - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/iscsi/iscsi_util.go b/pkg/volume/iscsi/iscsi_util.go index 3a0ccde3a42..f8742d9f716 100644 --- a/pkg/volume/iscsi/iscsi_util.go +++ b/pkg/volume/iscsi/iscsi_util.go @@ -29,15 +29,16 @@ import ( "strings" "time" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/kubelet/config" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" - utilexec "k8s.io/utils/exec" ) const ( diff --git a/pkg/volume/local/BUILD b/pkg/volume/local/BUILD index a880e6dda25..1fcbe6c957f 100644 --- a/pkg/volume/local/BUILD +++ b/pkg/volume/local/BUILD @@ -10,7 +10,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/kubelet/events:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -21,6 +20,7 @@ go_library( "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -34,7 +34,6 @@ go_test( embed = [":go_default_library"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -42,9 +41,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:darwin": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -52,9 +51,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:ios": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -62,9 +61,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -72,9 +71,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -82,6 +81,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), diff --git a/pkg/volume/local/local.go b/pkg/volume/local/local.go index 0f8beb0641b..b79180a6c87 100644 --- a/pkg/volume/local/local.go +++ b/pkg/volume/local/local.go @@ -30,12 +30,12 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/kubernetes/pkg/kubelet/events" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/validation" "k8s.io/utils/keymutex" + "k8s.io/utils/mount" utilstrings "k8s.io/utils/strings" ) diff --git a/pkg/volume/local/local_test.go b/pkg/volume/local/local_test.go index 3035f09f580..36a9c1fef1e 100644 --- a/pkg/volume/local/local_test.go +++ b/pkg/volume/local/local_test.go @@ -30,10 +30,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/kubernetes/pkg/volume/util/hostutil" + "k8s.io/utils/mount" ) const ( diff --git a/pkg/volume/nfs/BUILD b/pkg/volume/nfs/BUILD index 42baf1177e3..624a7898a2e 100644 --- a/pkg/volume/nfs/BUILD +++ b/pkg/volume/nfs/BUILD @@ -14,7 +14,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/nfs", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/recyclerclient:go_default_library", @@ -22,6 +21,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -31,7 +31,6 @@ go_test( srcs = ["nfs_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -39,6 +38,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/nfs/nfs.go b/pkg/volume/nfs/nfs.go index b6d407333fd..41b2e1dd9bb 100644 --- a/pkg/volume/nfs/nfs.go +++ b/pkg/volume/nfs/nfs.go @@ -21,15 +21,16 @@ import ( "os" "runtime" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/recyclerclient" - utilstrings "k8s.io/utils/strings" ) func getPath(uid types.UID, volName string, host volume.VolumeHost) string { diff --git a/pkg/volume/nfs/nfs_test.go b/pkg/volume/nfs/nfs_test.go index 7b1d711d4f2..f9bfbac3d3d 100644 --- a/pkg/volume/nfs/nfs_test.go +++ b/pkg/volume/nfs/nfs_test.go @@ -21,12 +21,13 @@ import ( "os" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/plugins.go b/pkg/volume/plugins.go index 08de0e9af0d..7393c682e1f 100644 --- a/pkg/volume/plugins.go +++ b/pkg/volume/plugins.go @@ -22,6 +22,10 @@ import ( "strings" "sync" + "k8s.io/klog" + "k8s.io/utils/exec" + "k8s.io/utils/mount" + authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -37,11 +41,7 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" - "k8s.io/utils/exec" - "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/util/recyclerclient" "k8s.io/kubernetes/pkg/volume/util/subpath" diff --git a/pkg/volume/portworx/BUILD b/pkg/volume/portworx/BUILD index 6925d5f355e..06f8c232f02 100644 --- a/pkg/volume/portworx/BUILD +++ b/pkg/volume/portworx/BUILD @@ -11,13 +11,13 @@ go_test( srcs = ["portworx_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) @@ -31,7 +31,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/portworx", deps = [ "//pkg/apis/core:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -45,6 +44,7 @@ go_library( "//vendor/github.com/libopenstorage/openstorage/api/spec:go_default_library", "//vendor/github.com/libopenstorage/openstorage/volume:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/portworx/portworx.go b/pkg/volume/portworx/portworx.go index 8c592b869de..da6cfbe7088 100644 --- a/pkg/volume/portworx/portworx.go +++ b/pkg/volume/portworx/portworx.go @@ -21,15 +21,16 @@ import ( "os" volumeclient "github.com/libopenstorage/openstorage/api/client/volume" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) const ( diff --git a/pkg/volume/portworx/portworx_test.go b/pkg/volume/portworx/portworx_test.go index 94ea785e0cc..e1fd58c995f 100644 --- a/pkg/volume/portworx/portworx_test.go +++ b/pkg/volume/portworx/portworx_test.go @@ -22,11 +22,12 @@ import ( "path/filepath" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/quobyte/BUILD b/pkg/volume/quobyte/BUILD index 040ead569cb..60bc5a55ab1 100644 --- a/pkg/volume/quobyte/BUILD +++ b/pkg/volume/quobyte/BUILD @@ -15,7 +15,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/quobyte", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -26,6 +25,7 @@ go_library( "//vendor/github.com/google/uuid:go_default_library", "//vendor/github.com/quobyte/api:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -35,7 +35,6 @@ go_test( srcs = ["quobyte_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -43,6 +42,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/quobyte/quobyte.go b/pkg/volume/quobyte/quobyte.go index 25ffb5b429c..33d730da522 100644 --- a/pkg/volume/quobyte/quobyte.go +++ b/pkg/volume/quobyte/quobyte.go @@ -23,15 +23,16 @@ import ( gostrings "strings" "github.com/google/uuid" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/quobyte/quobyte_test.go b/pkg/volume/quobyte/quobyte_test.go index c5834359742..2eabce6e6a7 100644 --- a/pkg/volume/quobyte/quobyte_test.go +++ b/pkg/volume/quobyte/quobyte_test.go @@ -21,12 +21,13 @@ import ( "os" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/rbd/BUILD b/pkg/volume/rbd/BUILD index 8cdcf9c5ebc..09226ab256b 100644 --- a/pkg/volume/rbd/BUILD +++ b/pkg/volume/rbd/BUILD @@ -18,7 +18,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/rbd", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/node:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", @@ -36,6 +35,7 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], @@ -46,7 +46,6 @@ go_test( srcs = ["rbd_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -56,6 +55,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/rbd/attacher.go b/pkg/volume/rbd/attacher.go index 7dbb24b6685..12c2e77c935 100644 --- a/pkg/volume/rbd/attacher.go +++ b/pkg/volume/rbd/attacher.go @@ -21,10 +21,11 @@ import ( "os" "time" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/volume" volutil "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/rbd/disk_manager.go b/pkg/volume/rbd/disk_manager.go index 93d5f81a141..5c10332606e 100644 --- a/pkg/volume/rbd/disk_manager.go +++ b/pkg/volume/rbd/disk_manager.go @@ -26,10 +26,11 @@ import ( "fmt" "os" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" ) diff --git a/pkg/volume/rbd/rbd.go b/pkg/volume/rbd/rbd.go index eb6a808023e..a07fe8bf06d 100644 --- a/pkg/volume/rbd/rbd.go +++ b/pkg/volume/rbd/rbd.go @@ -23,7 +23,12 @@ import ( "regexp" dstrings "strings" - "k8s.io/api/core/v1" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -31,15 +36,11 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" utilfeature "k8s.io/apiserver/pkg/util/feature" clientset "k8s.io/client-go/kubernetes" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" volutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilexec "k8s.io/utils/exec" - utilstrings "k8s.io/utils/strings" ) var ( diff --git a/pkg/volume/rbd/rbd_test.go b/pkg/volume/rbd/rbd_test.go index 04459444a24..f2c55a2c434 100644 --- a/pkg/volume/rbd/rbd_test.go +++ b/pkg/volume/rbd/rbd_test.go @@ -27,6 +27,8 @@ import ( "testing" "time" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" ) diff --git a/pkg/volume/rbd/rbd_util.go b/pkg/volume/rbd/rbd_util.go index 89f1e41b221..85044e85fde 100644 --- a/pkg/volume/rbd/rbd_util.go +++ b/pkg/volume/rbd/rbd_util.go @@ -32,18 +32,19 @@ import ( "strings" "time" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilpath "k8s.io/utils/path" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/wait" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/node" "k8s.io/kubernetes/pkg/volume" volutil "k8s.io/kubernetes/pkg/volume/util" - utilexec "k8s.io/utils/exec" - utilpath "k8s.io/utils/path" ) const ( diff --git a/pkg/volume/scaleio/BUILD b/pkg/volume/scaleio/BUILD index fd96f3a6f8b..f1410f50657 100644 --- a/pkg/volume/scaleio/BUILD +++ b/pkg/volume/scaleio/BUILD @@ -40,7 +40,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/scaleio", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -54,6 +53,7 @@ go_library( "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/scaleio/sio_volume.go b/pkg/volume/scaleio/sio_volume.go index 67bc549b9b9..9904147be53 100644 --- a/pkg/volume/scaleio/sio_volume.go +++ b/pkg/volume/scaleio/sio_volume.go @@ -23,17 +23,18 @@ import ( "strconv" "strings" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + api "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) type sioVolume struct { diff --git a/pkg/volume/secret/BUILD b/pkg/volume/secret/BUILD index 288808826ff..cb168c9532d 100644 --- a/pkg/volume/secret/BUILD +++ b/pkg/volume/secret/BUILD @@ -14,7 +14,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/secret", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -22,6 +21,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/secret/secret.go b/pkg/volume/secret/secret.go index 5679af20e56..3eee6d91827 100644 --- a/pkg/volume/secret/secret.go +++ b/pkg/volume/secret/secret.go @@ -19,15 +19,16 @@ package secret import ( "fmt" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the entry point for plugin detection in a package. diff --git a/pkg/volume/storageos/BUILD b/pkg/volume/storageos/BUILD index 9b0f4e7dc95..8d1b5730cbe 100644 --- a/pkg/volume/storageos/BUILD +++ b/pkg/volume/storageos/BUILD @@ -15,7 +15,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/storageos", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -28,6 +27,7 @@ go_library( "//vendor/github.com/storageos/go-api/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -40,7 +40,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -50,6 +49,7 @@ go_test( "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//vendor/github.com/storageos/go-api/types:go_default_library", "//vendor/k8s.io/utils/exec/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/storageos/storageos.go b/pkg/volume/storageos/storageos.go index 990d275a42a..a90e384e9a6 100644 --- a/pkg/volume/storageos/storageos.go +++ b/pkg/volume/storageos/storageos.go @@ -23,18 +23,19 @@ import ( "path/filepath" "strings" - "k8s.io/api/core/v1" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" clientset "k8s.io/client-go/kubernetes" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilexec "k8s.io/utils/exec" - utilstrings "k8s.io/utils/strings" ) // ProbeVolumePlugins is the primary entrypoint for volume plugins. diff --git a/pkg/volume/storageos/storageos_test.go b/pkg/volume/storageos/storageos_test.go index 43229bed236..6b2ac71e7ea 100644 --- a/pkg/volume/storageos/storageos_test.go +++ b/pkg/volume/storageos/storageos_test.go @@ -22,15 +22,16 @@ import ( "path/filepath" "testing" + "k8s.io/utils/exec/testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" - "k8s.io/utils/exec/testing" ) func TestCanSupport(t *testing.T) { diff --git a/pkg/volume/storageos/storageos_util_test.go b/pkg/volume/storageos/storageos_util_test.go index 0ce4ddf8749..df509e40557 100644 --- a/pkg/volume/storageos/storageos_util_test.go +++ b/pkg/volume/storageos/storageos_util_test.go @@ -19,15 +19,15 @@ package storageos import ( "fmt" "os" + "testing" storageostypes "github.com/storageos/go-api/types" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" - - "testing" ) var testVolName = "storageos-test-vol" diff --git a/pkg/volume/testing/BUILD b/pkg/volume/testing/BUILD index 2bbc87a9014..d4a7b3cbbcf 100644 --- a/pkg/volume/testing/BUILD +++ b/pkg/volume/testing/BUILD @@ -13,7 +13,6 @@ go_library( ], importpath = "k8s.io/kubernetes/pkg/volume/testing", deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -37,6 +36,7 @@ go_library( "//vendor/github.com/stretchr/testify/mock:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/exec/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/testing/testing.go b/pkg/volume/testing/testing.go index 8e0abbf6c21..7e9cce332a4 100644 --- a/pkg/volume/testing/testing.go +++ b/pkg/volume/testing/testing.go @@ -26,6 +26,11 @@ import ( "testing" "time" + "k8s.io/utils/exec" + "k8s.io/utils/exec/testing" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + authenticationv1 "k8s.io/api/authentication/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -40,17 +45,12 @@ import ( "k8s.io/client-go/tools/record" utiltesting "k8s.io/client-go/util/testing" cloudprovider "k8s.io/cloud-provider" - "k8s.io/utils/exec" - "k8s.io/utils/exec/testing" - - "k8s.io/kubernetes/pkg/util/mount" . "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" "k8s.io/kubernetes/pkg/volume/util/recyclerclient" "k8s.io/kubernetes/pkg/volume/util/subpath" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) const ( diff --git a/pkg/volume/util/BUILD b/pkg/volume/util/BUILD index 705296fd66c..5e279f5173a 100644 --- a/pkg/volume/util/BUILD +++ b/pkg/volume/util/BUILD @@ -23,7 +23,6 @@ go_library( "//pkg/api/v1/pod:go_default_library", "//pkg/apis/core/v1/helper:go_default_library", "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/util/resizefs:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util/types:go_default_library", @@ -45,6 +44,7 @@ go_library( "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) diff --git a/pkg/volume/util/fsquota/BUILD b/pkg/volume/util/fsquota/BUILD index 2079e4357a8..523b56debbc 100644 --- a/pkg/volume/util/fsquota/BUILD +++ b/pkg/volume/util/fsquota/BUILD @@ -12,10 +12,10 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//pkg/volume/util/fsquota/common:go_default_library", @@ -40,21 +40,21 @@ go_test( deps = select({ "@io_bazel_rules_go//go/platform:android": [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume/util/fsquota/common:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume/util/fsquota/common:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), diff --git a/pkg/volume/util/fsquota/quota.go b/pkg/volume/util/fsquota/quota.go index 877b8fe9d28..40e30d5d66c 100644 --- a/pkg/volume/util/fsquota/quota.go +++ b/pkg/volume/util/fsquota/quota.go @@ -17,11 +17,12 @@ limitations under the License. package fsquota import ( + "k8s.io/utils/mount" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" ) // Interface -- quota interface diff --git a/pkg/volume/util/fsquota/quota_linux.go b/pkg/volume/util/fsquota/quota_linux.go index 65c24c52070..70de9c309e6 100644 --- a/pkg/volume/util/fsquota/quota_linux.go +++ b/pkg/volume/util/fsquota/quota_linux.go @@ -25,11 +25,12 @@ import ( "path/filepath" "sync" + "k8s.io/klog" + "k8s.io/utils/mount" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume/util/fsquota/common" ) @@ -110,7 +111,7 @@ func clearBackingDev(path string) { // Breaking this up helps with testing func detectMountpointInternal(m mount.Interface, path string) (string, error) { for path != "" && path != "/" { - // per pkg/util/mount/mount_linux this detects all but + // per k8s.io/utils/mount/mount_linux this detects all but // a bind mount from one part of a mount to another. // For our purposes that's fine; we simply want the "true" // mount point diff --git a/pkg/volume/util/fsquota/quota_linux_test.go b/pkg/volume/util/fsquota/quota_linux_test.go index 1e542f02e23..d429f395903 100644 --- a/pkg/volume/util/fsquota/quota_linux_test.go +++ b/pkg/volume/util/fsquota/quota_linux_test.go @@ -25,12 +25,13 @@ import ( "strings" "testing" + "k8s.io/utils/mount" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume/util/fsquota/common" ) diff --git a/pkg/volume/util/fsquota/quota_unsupported.go b/pkg/volume/util/fsquota/quota_unsupported.go index f1ae4cdd1f4..a192122b712 100644 --- a/pkg/volume/util/fsquota/quota_unsupported.go +++ b/pkg/volume/util/fsquota/quota_unsupported.go @@ -20,9 +20,11 @@ package fsquota import ( "errors" + + "k8s.io/utils/mount" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" ) // Dummy quota implementation for systems that do not implement support diff --git a/pkg/volume/util/hostutil/BUILD b/pkg/volume/util/hostutil/BUILD index 87840d31cff..71cb37e5913 100644 --- a/pkg/volume/util/hostutil/BUILD +++ b/pkg/volume/util/hostutil/BUILD @@ -12,7 +12,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/util/hostutil", visibility = ["//visibility:public"], deps = [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//vendor/golang.org/x/sys/unix:go_default_library", diff --git a/pkg/volume/util/hostutil/fake_hostutil.go b/pkg/volume/util/hostutil/fake_hostutil.go index d098e91a1b5..688e28ecc87 100644 --- a/pkg/volume/util/hostutil/fake_hostutil.go +++ b/pkg/volume/util/hostutil/fake_hostutil.go @@ -21,7 +21,7 @@ import ( "os" "sync" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // FakeHostUtil is a fake HostUtils implementation for testing diff --git a/pkg/volume/util/hostutil/hostutil.go b/pkg/volume/util/hostutil/hostutil.go index 68e5c7e999c..ceb067dbf04 100644 --- a/pkg/volume/util/hostutil/hostutil.go +++ b/pkg/volume/util/hostutil/hostutil.go @@ -20,7 +20,7 @@ import ( "fmt" "os" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // FileType enumerates the known set of possible file types. diff --git a/pkg/volume/util/hostutil/hostutil_linux.go b/pkg/volume/util/hostutil/hostutil_linux.go index 87979911fd9..8e7efc129fc 100644 --- a/pkg/volume/util/hostutil/hostutil_linux.go +++ b/pkg/volume/util/hostutil/hostutil_linux.go @@ -27,11 +27,9 @@ import ( "syscall" "golang.org/x/sys/unix" - "k8s.io/klog" + "k8s.io/utils/mount" utilpath "k8s.io/utils/path" - - "k8s.io/kubernetes/pkg/util/mount" ) const ( diff --git a/pkg/volume/util/hostutil/hostutil_unsupported.go b/pkg/volume/util/hostutil/hostutil_unsupported.go index a5e9081f919..303da14965c 100644 --- a/pkg/volume/util/hostutil/hostutil_unsupported.go +++ b/pkg/volume/util/hostutil/hostutil_unsupported.go @@ -22,7 +22,7 @@ import ( "errors" "os" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) // HostUtil is an HostUtils implementation that allows compilation on diff --git a/pkg/volume/util/hostutil/hostutil_windows.go b/pkg/volume/util/hostutil/hostutil_windows.go index bb74e939e72..d8d05365f1d 100644 --- a/pkg/volume/util/hostutil/hostutil_windows.go +++ b/pkg/volume/util/hostutil/hostutil_windows.go @@ -26,9 +26,8 @@ import ( "strings" "k8s.io/klog" + "k8s.io/utils/mount" utilpath "k8s.io/utils/path" - - "k8s.io/kubernetes/pkg/util/mount" ) // HostUtil implements HostUtils for Windows platforms. diff --git a/pkg/volume/util/operationexecutor/BUILD b/pkg/volume/util/operationexecutor/BUILD index c600f89ed53..f9bb907bbab 100644 --- a/pkg/volume/util/operationexecutor/BUILD +++ b/pkg/volume/util/operationexecutor/BUILD @@ -17,7 +17,6 @@ go_library( deps = [ "//pkg/features:go_default_library", "//pkg/kubelet/events:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/hostutil:go_default_library", @@ -35,6 +34,7 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume/errors:go_default_library", "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/util/operationexecutor/operation_executor.go b/pkg/volume/util/operationexecutor/operation_executor.go index 18dd1f5655e..c95029e6fd7 100644 --- a/pkg/volume/util/operationexecutor/operation_executor.go +++ b/pkg/volume/util/operationexecutor/operation_executor.go @@ -25,11 +25,11 @@ import ( "time" "k8s.io/klog" + "k8s.io/utils/mount" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/hostutil" diff --git a/pkg/volume/util/resize_util.go b/pkg/volume/util/resize_util.go index b35daba380d..0f10f1d57bb 100644 --- a/pkg/volume/util/resize_util.go +++ b/pkg/volume/util/resize_util.go @@ -20,6 +20,8 @@ import ( "encoding/json" "fmt" + "k8s.io/utils/mount" + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/resource" @@ -28,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" clientset "k8s.io/client-go/kubernetes" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/resizefs" "k8s.io/kubernetes/pkg/volume" volumetypes "k8s.io/kubernetes/pkg/volume/util/types" diff --git a/pkg/volume/util/subpath/BUILD b/pkg/volume/util/subpath/BUILD index 9a8249105d3..3830dc9ae00 100644 --- a/pkg/volume/util/subpath/BUILD +++ b/pkg/volume/util/subpath/BUILD @@ -12,54 +12,54 @@ go_library( visibility = ["//visibility:public"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:darwin": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:dragonfly": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:freebsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:ios": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:nacl": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:netbsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:openbsd": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:plan9": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:solaris": [ - "//pkg/util/mount:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ - "//pkg/util/mount:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/nsenter:go_default_library", ], "//conditions:default": [], @@ -75,12 +75,12 @@ go_test( embed = [":go_default_library"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ "//vendor/github.com/stretchr/testify/assert:go_default_library", diff --git a/pkg/volume/util/subpath/subpath_linux.go b/pkg/volume/util/subpath/subpath_linux.go index 164ed51a64f..7778c1af02c 100644 --- a/pkg/volume/util/subpath/subpath_linux.go +++ b/pkg/volume/util/subpath/subpath_linux.go @@ -28,10 +28,8 @@ import ( "syscall" "golang.org/x/sys/unix" - "k8s.io/klog" - - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) const ( diff --git a/pkg/volume/util/subpath/subpath_linux_test.go b/pkg/volume/util/subpath/subpath_linux_test.go index 638b523d1b3..154d761e6bf 100644 --- a/pkg/volume/util/subpath/subpath_linux_test.go +++ b/pkg/volume/util/subpath/subpath_linux_test.go @@ -30,8 +30,7 @@ import ( "testing" "k8s.io/klog" - - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) func TestSafeMakeDir(t *testing.T) { diff --git a/pkg/volume/util/subpath/subpath_unsupported.go b/pkg/volume/util/subpath/subpath_unsupported.go index a1fd600a286..9b937adcfef 100644 --- a/pkg/volume/util/subpath/subpath_unsupported.go +++ b/pkg/volume/util/subpath/subpath_unsupported.go @@ -22,7 +22,7 @@ import ( "errors" "os" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" "k8s.io/utils/nsenter" ) diff --git a/pkg/volume/util/subpath/subpath_windows.go b/pkg/volume/util/subpath/subpath_windows.go index 2bbb3c52716..f8987397b63 100644 --- a/pkg/volume/util/subpath/subpath_windows.go +++ b/pkg/volume/util/subpath/subpath_windows.go @@ -26,7 +26,7 @@ import ( "syscall" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" "k8s.io/utils/nsenter" ) diff --git a/pkg/volume/util/util.go b/pkg/volume/util/util.go index 581895715fd..e3baaa7c3a6 100644 --- a/pkg/volume/util/util.go +++ b/pkg/volume/util/util.go @@ -25,6 +25,11 @@ import ( "runtime" "strings" + "k8s.io/klog" + utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" storage "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -35,18 +40,13 @@ import ( "k8s.io/apimachinery/pkg/util/sets" utilfeature "k8s.io/apiserver/pkg/util/feature" clientset "k8s.io/client-go/kubernetes" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/api/legacyscheme" podutil "k8s.io/kubernetes/pkg/api/v1/pod" v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/types" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilexec "k8s.io/utils/exec" - utilstrings "k8s.io/utils/strings" ) const ( diff --git a/pkg/volume/util/volumepathhandler/BUILD b/pkg/volume/util/volumepathhandler/BUILD index 23b791e6c30..fdbc4b8b33e 100644 --- a/pkg/volume/util/volumepathhandler/BUILD +++ b/pkg/volume/util/volumepathhandler/BUILD @@ -10,10 +10,10 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/util/volumepathhandler", visibility = ["//visibility:public"], deps = [ - "//pkg/util/mount:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//vendor/golang.org/x/sys/unix:go_default_library", diff --git a/pkg/volume/util/volumepathhandler/volume_path_handler.go b/pkg/volume/util/volumepathhandler/volume_path_handler.go index e12a9137fed..9c0983bbf73 100644 --- a/pkg/volume/util/volumepathhandler/volume_path_handler.go +++ b/pkg/volume/util/volumepathhandler/volume_path_handler.go @@ -23,8 +23,8 @@ import ( "path/filepath" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" utilexec "k8s.io/utils/exec" + "k8s.io/utils/mount" "k8s.io/apimachinery/pkg/types" ) diff --git a/pkg/volume/vsphere_volume/BUILD b/pkg/volume/vsphere_volume/BUILD index 4995fc2ca93..b4bab5c5ef9 100644 --- a/pkg/volume/vsphere_volume/BUILD +++ b/pkg/volume/vsphere_volume/BUILD @@ -21,7 +21,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/vsphere_volume", deps = [ "//pkg/features:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", "//pkg/volume/util/volumepathhandler:go_default_library", @@ -36,6 +35,7 @@ go_library( "//staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], ) @@ -49,7 +49,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/testing:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -61,6 +60,7 @@ go_test( "//staging/src/k8s.io/legacy-cloud-providers/vsphere:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) diff --git a/pkg/volume/vsphere_volume/attacher.go b/pkg/volume/vsphere_volume/attacher.go index bce39b701ae..8c247167858 100644 --- a/pkg/volume/vsphere_volume/attacher.go +++ b/pkg/volume/vsphere_volume/attacher.go @@ -25,14 +25,15 @@ import ( "runtime" "time" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/keymutex" + "k8s.io/utils/mount" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/legacy-cloud-providers/vsphere" - "k8s.io/utils/keymutex" ) type vsphereVMDKAttacher struct { diff --git a/pkg/volume/vsphere_volume/vsphere_volume.go b/pkg/volume/vsphere_volume/vsphere_volume.go index b78a1886ff0..2d023da3b1f 100644 --- a/pkg/volume/vsphere_volume/vsphere_volume.go +++ b/pkg/volume/vsphere_volume/vsphere_volume.go @@ -25,18 +25,19 @@ import ( "runtime" "strings" - "k8s.io/api/core/v1" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilfeature "k8s.io/apiserver/pkg/util/feature" volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" ) // This is the primary entrypoint for volume plugins. diff --git a/pkg/volume/vsphere_volume/vsphere_volume_block.go b/pkg/volume/vsphere_volume/vsphere_volume_block.go index 37d52d6159b..657fd611ebe 100644 --- a/pkg/volume/vsphere_volume/vsphere_volume_block.go +++ b/pkg/volume/vsphere_volume/vsphere_volume_block.go @@ -23,14 +23,15 @@ import ( "path/filepath" "strings" + "k8s.io/klog" + "k8s.io/utils/mount" + utilstrings "k8s.io/utils/strings" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" - utilstrings "k8s.io/utils/strings" ) var _ volume.BlockVolumePlugin = &vsphereVolumePlugin{} diff --git a/pkg/volume/vsphere_volume/vsphere_volume_test.go b/pkg/volume/vsphere_volume/vsphere_volume_test.go index 49939a18d6f..80671b8d58e 100644 --- a/pkg/volume/vsphere_volume/vsphere_volume_test.go +++ b/pkg/volume/vsphere_volume/vsphere_volume_test.go @@ -24,12 +24,13 @@ import ( "path/filepath" "testing" + "k8s.io/utils/mount" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utiltesting "k8s.io/client-go/util/testing" cloudprovider "k8s.io/cloud-provider" "k8s.io/cloud-provider/fake" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumetest "k8s.io/kubernetes/pkg/volume/testing" "k8s.io/legacy-cloud-providers/vsphere" diff --git a/pkg/volume/vsphere_volume/vsphere_volume_util_linux.go b/pkg/volume/vsphere_volume/vsphere_volume_util_linux.go index 9e30e1c1442..7e1efcc2c9c 100644 --- a/pkg/volume/vsphere_volume/vsphere_volume_util_linux.go +++ b/pkg/volume/vsphere_volume/vsphere_volume_util_linux.go @@ -21,7 +21,7 @@ package vsphere_volume import ( "fmt" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) func verifyDevicePath(path string) (string, error) { diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.mod b/staging/src/k8s.io/apiextensions-apiserver/go.mod index 1449d6213bb..4845f5fcc7b 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.mod +++ b/staging/src/k8s.io/apiextensions-apiserver/go.mod @@ -29,7 +29,7 @@ require ( k8s.io/component-base v0.0.0 k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/yaml v1.1.0 ) diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.sum b/staging/src/k8s.io/apiextensions-apiserver/go.sum index 3620a486d58..b7bcfef98d6 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.sum +++ b/staging/src/k8s.io/apiextensions-apiserver/go.sum @@ -437,8 +437,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/apiserver/go.mod b/staging/src/k8s.io/apiserver/go.mod index 71361ceb865..2d5281f3cd4 100644 --- a/staging/src/k8s.io/apiserver/go.mod +++ b/staging/src/k8s.io/apiserver/go.mod @@ -49,7 +49,7 @@ require ( k8s.io/component-base v0.0.0 k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 sigs.k8s.io/yaml v1.1.0 ) diff --git a/staging/src/k8s.io/apiserver/go.sum b/staging/src/k8s.io/apiserver/go.sum index 3b1450e5166..e4d78fb14f7 100644 --- a/staging/src/k8s.io/apiserver/go.sum +++ b/staging/src/k8s.io/apiserver/go.sum @@ -353,8 +353,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU= diff --git a/staging/src/k8s.io/cli-runtime/go.sum b/staging/src/k8s.io/cli-runtime/go.sum index ca958845a22..50c14422d51 100644 --- a/staging/src/k8s.io/cli-runtime/go.sum +++ b/staging/src/k8s.io/cli-runtime/go.sum @@ -239,8 +239,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= diff --git a/staging/src/k8s.io/client-go/go.mod b/staging/src/k8s.io/client-go/go.mod index a6b2b2bdb53..f60e1d08124 100644 --- a/staging/src/k8s.io/client-go/go.mod +++ b/staging/src/k8s.io/client-go/go.mod @@ -31,7 +31,7 @@ require ( k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 k8s.io/klog v1.0.0 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/yaml v1.1.0 ) diff --git a/staging/src/k8s.io/client-go/go.sum b/staging/src/k8s.io/client-go/go.sum index fc48bbc6d98..9cb6acd2290 100644 --- a/staging/src/k8s.io/client-go/go.sum +++ b/staging/src/k8s.io/client-go/go.sum @@ -198,8 +198,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/cloud-provider/go.mod b/staging/src/k8s.io/cloud-provider/go.mod index dc521c8afc6..745757a09a9 100644 --- a/staging/src/k8s.io/cloud-provider/go.mod +++ b/staging/src/k8s.io/cloud-provider/go.mod @@ -9,7 +9,7 @@ require ( k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 k8s.io/klog v1.0.0 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f ) replace ( diff --git a/staging/src/k8s.io/cloud-provider/go.sum b/staging/src/k8s.io/cloud-provider/go.sum index 425d1930297..3e0a59ee864 100644 --- a/staging/src/k8s.io/cloud-provider/go.sum +++ b/staging/src/k8s.io/cloud-provider/go.sum @@ -180,8 +180,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/component-base/go.mod b/staging/src/k8s.io/component-base/go.mod index 9488819a40c..6d550e6cf8d 100644 --- a/staging/src/k8s.io/component-base/go.mod +++ b/staging/src/k8s.io/component-base/go.mod @@ -15,7 +15,7 @@ require ( k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 k8s.io/klog v1.0.0 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f ) replace ( diff --git a/staging/src/k8s.io/component-base/go.sum b/staging/src/k8s.io/component-base/go.sum index ffec4ceb465..899d114ae40 100644 --- a/staging/src/k8s.io/component-base/go.sum +++ b/staging/src/k8s.io/component-base/go.sum @@ -219,8 +219,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/csi-translation-lib/go.sum b/staging/src/k8s.io/csi-translation-lib/go.sum index 9802884aceb..4645a922e17 100644 --- a/staging/src/k8s.io/csi-translation-lib/go.sum +++ b/staging/src/k8s.io/csi-translation-lib/go.sum @@ -162,7 +162,7 @@ k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/kube-aggregator/go.mod b/staging/src/k8s.io/kube-aggregator/go.mod index 1cadbca1369..721f77850e7 100644 --- a/staging/src/k8s.io/kube-aggregator/go.mod +++ b/staging/src/k8s.io/kube-aggregator/go.mod @@ -21,7 +21,7 @@ require ( k8s.io/component-base v0.0.0 k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f ) replace ( diff --git a/staging/src/k8s.io/kube-aggregator/go.sum b/staging/src/k8s.io/kube-aggregator/go.sum index d53fc8af7d3..677fe1d88ce 100644 --- a/staging/src/k8s.io/kube-aggregator/go.sum +++ b/staging/src/k8s.io/kube-aggregator/go.sum @@ -388,8 +388,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/kube-controller-manager/go.sum b/staging/src/k8s.io/kube-controller-manager/go.sum index 9d8cb1b7b4f..a29776deb2b 100644 --- a/staging/src/k8s.io/kube-controller-manager/go.sum +++ b/staging/src/k8s.io/kube-controller-manager/go.sum @@ -192,8 +192,8 @@ k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/kube-proxy/go.sum b/staging/src/k8s.io/kube-proxy/go.sum index 9d8cb1b7b4f..a29776deb2b 100644 --- a/staging/src/k8s.io/kube-proxy/go.sum +++ b/staging/src/k8s.io/kube-proxy/go.sum @@ -192,8 +192,8 @@ k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/kube-scheduler/go.sum b/staging/src/k8s.io/kube-scheduler/go.sum index 9d8cb1b7b4f..a29776deb2b 100644 --- a/staging/src/k8s.io/kube-scheduler/go.sum +++ b/staging/src/k8s.io/kube-scheduler/go.sum @@ -192,8 +192,8 @@ k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/kubectl/go.mod b/staging/src/k8s.io/kubectl/go.mod index 6ad180bede4..df65d1a91e6 100644 --- a/staging/src/k8s.io/kubectl/go.mod +++ b/staging/src/k8s.io/kubectl/go.mod @@ -44,7 +44,7 @@ require ( k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a k8s.io/metrics v0.0.0 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/kustomize v2.0.3+incompatible sigs.k8s.io/yaml v1.1.0 vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc diff --git a/staging/src/k8s.io/kubectl/go.sum b/staging/src/k8s.io/kubectl/go.sum index 36aa4c26254..b94bd07f47b 100644 --- a/staging/src/k8s.io/kubectl/go.sum +++ b/staging/src/k8s.io/kubectl/go.sum @@ -325,8 +325,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.mod b/staging/src/k8s.io/legacy-cloud-providers/go.mod index da1440561a0..2505e779f57 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.mod +++ b/staging/src/k8s.io/legacy-cloud-providers/go.mod @@ -22,7 +22,6 @@ require ( github.com/vmware/govmomi v0.20.3 golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 gopkg.in/gcfg.v1 v1.2.0 gopkg.in/warnings.v0 v0.1.1 // indirect @@ -34,7 +33,7 @@ require ( k8s.io/component-base v0.0.0 k8s.io/csi-translation-lib v0.0.0 k8s.io/klog v1.0.0 - k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d + k8s.io/utils v0.0.0-20191114184206-e782cd3c129f sigs.k8s.io/yaml v1.1.0 ) diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.sum b/staging/src/k8s.io/legacy-cloud-providers/go.sum index 1ca60c092b4..ef52f4ca5ec 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.sum +++ b/staging/src/k8s.io/legacy-cloud-providers/go.sum @@ -349,8 +349,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD index 370a5006dca..7f989c1fde3 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD @@ -39,7 +39,6 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", "//staging/src/k8s.io/component-base/metrics:go_default_library", "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount:go_default_library", "//vendor/github.com/gophercloud/gophercloud:go_default_library", "//vendor/github.com/gophercloud/gophercloud/openstack:go_default_library", "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions:go_default_library", @@ -68,6 +67,7 @@ go_library( "//vendor/gopkg.in/gcfg.v1:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], ) @@ -102,9 +102,6 @@ filegroup( filegroup( name = "all-srcs", - srcs = [ - ":package-srcs", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount:all-srcs", - ], + srcs = [":package-srcs"], tags = ["automanaged"], ) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/metadata.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/metadata.go index 7562a684562..c1b65de0c4d 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/metadata.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/metadata.go @@ -30,8 +30,8 @@ import ( "strings" "k8s.io/klog" - osmount "k8s.io/legacy-cloud-providers/openstack/util/mount" "k8s.io/utils/exec" + "k8s.io/utils/mount" ) const ( @@ -125,7 +125,7 @@ func getMetadataFromConfigDrive(metadataVersion string) (*Metadata, error) { klog.V(4).Infof("Attempting to mount configdrive %s on %s", dev, mntdir) - mounter := osmount.New("" /* default mount path */) + mounter := mount.New("" /* default mount path */) err = mounter.Mount(dev, mntdir, "iso9660", []string{"ro"}) if err != nil { err = mounter.Mount(dev, mntdir, "vfat", []string{"ro"}) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD deleted file mode 100644 index c77bcb5c3e9..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD +++ /dev/null @@ -1,51 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "mount.go", - "mount_linux.go", - "mount_unsupported.go", - "mount_windows.go", - ], - importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/openstack/util/mount", - importpath = "k8s.io/legacy-cloud-providers/openstack/util/mount", - visibility = ["//visibility:public"], - deps = select({ - "@io_bazel_rules_go//go/platform:android": [ - "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", - "//vendor/golang.org/x/sys/unix:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - "//vendor/k8s.io/utils/exec:go_default_library", - "//vendor/k8s.io/utils/io:go_default_library", - "//vendor/k8s.io/utils/path:go_default_library", - ], - "@io_bazel_rules_go//go/platform:linux": [ - "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", - "//vendor/golang.org/x/sys/unix:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - "//vendor/k8s.io/utils/exec:go_default_library", - "//vendor/k8s.io/utils/io:go_default_library", - "//vendor/k8s.io/utils/path:go_default_library", - ], - "@io_bazel_rules_go//go/platform:windows": [ - "//vendor/k8s.io/klog:go_default_library", - "//vendor/k8s.io/utils/path:go_default_library", - ], - "//conditions:default": [], - }), -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go deleted file mode 100644 index 06a512ef412..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go +++ /dev/null @@ -1,380 +0,0 @@ -// +build !providerless - -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package mount provides a linux-centric library for mounting filesystems/ -// Vendored for the OpenStack provider and will be removed in 1.17 -package mount - -import ( - "fmt" - "os" - "path/filepath" - "strings" -) - -// FileType is one of the types of supported Linux file types. -type FileType string - -// A complete list of the support file types in the mount package. -const ( - // Default mount command if mounter path is not specified - defaultMountCommand = "mount" - MountsInGlobalPDPath = "mounts" - FileTypeDirectory FileType = "Directory" - FileTypeFile FileType = "File" - FileTypeSocket FileType = "Socket" - FileTypeCharDev FileType = "CharDevice" - FileTypeBlockDev FileType = "BlockDevice" -) - -// Interface is the general interface to filesystem mounts. -type Interface interface { - // Mount mounts source to target as fstype with given options. - Mount(source string, target string, fstype string, options []string) error - // Unmount unmounts given target. - Unmount(target string) error - // List returns a list of all mounted filesystems. This can be large. - // On some platforms, reading mounts is not guaranteed consistent (i.e. - // it could change between chunked reads). This is guaranteed to be - // consistent. - List() ([]MntPoint, error) - // IsMountPointMatch determines if the mountpoint matches the dir - IsMountPointMatch(mp MntPoint, dir string) bool - // IsNotMountPoint determines if a directory is a mountpoint. - // It should return ErrNotExist when the directory does not exist. - // IsNotMountPoint is more expensive than IsLikelyNotMountPoint. - // IsNotMountPoint detects bind mounts in linux. - // IsNotMountPoint enumerates all the mountpoints using List() and - // the list of mountpoints may be large, then it uses - // IsMountPointMatch to evaluate whether the directory is a mountpoint - IsNotMountPoint(file string) (bool, error) - // IsLikelyNotMountPoint uses heuristics to determine if a directory - // is a mountpoint. - // It should return ErrNotExist when the directory does not exist. - // IsLikelyNotMountPoint does NOT properly detect all mountpoint types - // most notably linux bind mounts. - IsLikelyNotMountPoint(file string) (bool, error) - // DeviceOpened determines if the device is in use elsewhere - // on the system, i.e. still mounted. - DeviceOpened(pathname string) (bool, error) - // PathIsDevice determines if a path is a device. - PathIsDevice(pathname string) (bool, error) - // GetDeviceNameFromMount finds the device name by checking the mount path - // to get the global mount path which matches its plugin directory - GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) - // MakeRShared checks that given path is on a mount with 'rshared' mount - // propagation. If not, it bind-mounts the path as rshared. - MakeRShared(path string) error - // GetFileType checks for file/directory/socket/block/character devices. - // Will operate in the host mount namespace if kubelet is running in a container - GetFileType(pathname string) (FileType, error) - // MakeFile creates an empty file. - // Will operate in the host mount namespace if kubelet is running in a container - MakeFile(pathname string) error - // MakeDir creates a new directory. - // Will operate in the host mount namespace if kubelet is running in a container - MakeDir(pathname string) error - // SafeMakeDir creates subdir within given base. It makes sure that the - // created directory does not escape given base directory mis-using - // symlinks. Note that the function makes sure that it creates the directory - // somewhere under the base, nothing else. E.g. if the directory already - // exists, it may exist outside of the base due to symlinks. - // This method should be used if the directory to create is inside volume - // that's under user control. User must not be able to use symlinks to - // escape the volume to create directories somewhere else. - SafeMakeDir(subdir string, base string, perm os.FileMode) error - // Will operate in the host mount namespace if kubelet is running in a container. - // Error is returned on any other error than "file not found". - ExistsPath(pathname string) (bool, error) - // EvalHostSymlinks returns the path name after evaluating symlinks. - // Will operate in the host mount namespace if kubelet is running in a container. - EvalHostSymlinks(pathname string) (string, error) - // CleanSubPaths removes any bind-mounts created by PrepareSafeSubpath in given - // pod volume directory. - CleanSubPaths(podDir string, volumeName string) error - // PrepareSafeSubpath does everything that's necessary to prepare a subPath - // that's 1) inside given volumePath and 2) immutable after this call. - // - // newHostPath - location of prepared subPath. It should be used instead of - // hostName when running the container. - // cleanupAction - action to run when the container is running or it failed to start. - // - // CleanupAction must be called immediately after the container with given - // subpath starts. On the other hand, Interface.CleanSubPaths must be called - // when the pod finishes. - PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) - // GetMountRefs finds all mount references to the path, returns a - // list of paths. Path could be a mountpoint path, device or a normal - // directory (for bind mount). - GetMountRefs(pathname string) ([]string, error) - // GetFSGroup returns FSGroup of the path. - GetFSGroup(pathname string) (int64, error) - // GetSELinuxSupport returns true if given path is on a mount that supports - // SELinux. - GetSELinuxSupport(pathname string) (bool, error) - // GetMode returns permissions of the path. - GetMode(pathname string) (os.FileMode, error) -} - -// Subpath is the string path of the volume mount. -type Subpath struct { - // index of the VolumeMount for this container - VolumeMountIndex int - // Full path to the subpath directory on the host - Path string - // name of the volume that is a valid directory name. - VolumeName string - // Full path to the volume path - VolumePath string - // Path to the pod's directory, including pod UID - PodDir string - // Name of the container - ContainerName string -} - -// Exec executes command where mount utilities are. This can be either the host, -// container where kubelet runs or even a remote pod with mount utilities. -// Usual pkg/util/exec interface is not used because kubelet.RunInContainer does -// not provide stdin/stdout/stderr streams. -type Exec interface { - // Run executes a command and returns its stdout + stderr combined in one - // stream. - Run(cmd string, args ...string) ([]byte, error) -} - -// Compile-time check to ensure all Mounter implementations satisfy -// the mount interface -var _ Interface = &Mounter{} - -// MntPoint represents a single line in /proc/mounts or /etc/fstab. -type MntPoint struct { - Device string - Path string - Type string - Opts []string - Freq int - Pass int -} - -// SafeFormatAndMount probes a device to see if it is formatted. -// Namely it checks to see if a file system is present. If so it -// mounts it otherwise the device is formatted first then mounted. -type SafeFormatAndMount struct { - Interface - Exec -} - -// FormatAndMount formats the given disk, if needed, and mounts it. -// That is if the disk is not formatted and it is not being mounted as -// read-only it will format it first then mount it. Otherwise, if the -// disk is already formatted or it is being mounted as read-only, it -// will be mounted without formatting. -func (mounter *SafeFormatAndMount) FormatAndMount(source string, target string, fstype string, options []string) error { - return mounter.formatAndMount(source, target, fstype, options) -} - -// GetDeviceNameFromMount when given a mnt point, find the device from /proc/mounts -// returns the device name, reference count, and error code. -func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, error) { - mps, err := mounter.List() - if err != nil { - return "", 0, err - } - - // Find the device name. - // FIXME if multiple devices mounted on the same mount path, only the first one is returned - device := "" - // If mountPath is symlink, need get its target path. - slTarget, err := filepath.EvalSymlinks(mountPath) - if err != nil { - slTarget = mountPath - } - for i := range mps { - if mps[i].Path == slTarget { - device = mps[i].Device - break - } - } - - // Find all references to the device. - refCount := 0 - for i := range mps { - if mps[i].Device == device { - refCount++ - } - } - return device, refCount, nil -} - -// IsNotMountPoint determines if a directory is a mountpoint. -// It should return ErrNotExist when the directory does not exist. -// This method uses the List() of all mountpoints -// It is more extensive than IsLikelyNotMountPoint -// and it detects bind mounts in linux -func IsNotMountPoint(mounter Interface, file string) (bool, error) { - // IsLikelyNotMountPoint provides a quick check - // to determine whether file IS A mountpoint - notMnt, notMntErr := mounter.IsLikelyNotMountPoint(file) - if notMntErr != nil && os.IsPermission(notMntErr) { - // We were not allowed to do the simple stat() check, e.g. on NFS with - // root_squash. Fall back to /proc/mounts check below. - notMnt = true - notMntErr = nil - } - if notMntErr != nil { - return notMnt, notMntErr - } - // identified as mountpoint, so return this fact - if notMnt == false { - return notMnt, nil - } - - // Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts - resolvedFile, err := mounter.EvalHostSymlinks(file) - if err != nil { - return true, err - } - - // check all mountpoints since IsLikelyNotMountPoint - // is not reliable for some mountpoint types - mountPoints, mountPointsErr := mounter.List() - if mountPointsErr != nil { - return notMnt, mountPointsErr - } - for _, mp := range mountPoints { - if mounter.IsMountPointMatch(mp, resolvedFile) { - notMnt = false - break - } - } - return notMnt, nil -} - -// isBind detects whether a bind mount is being requested and makes the remount options to -// use in case of bind mount, due to the fact that bind mount doesn't respect mount options. -// The list equals: -// options - 'bind' + 'remount' (no duplicate) -func isBind(options []string) (bool, []string, []string) { - // Because we have an FD opened on the subpath bind mount, the "bind" option - // needs to be included, otherwise the mount target will error as busy if you - // remount as readonly. - // - // As a consequence, all read only bind mounts will no longer change the underlying - // volume mount to be read only. - bindRemountOpts := []string{"bind", "remount"} - bind := false - bindOpts := []string{"bind"} - - // _netdev is a userspace mount option and does not automatically get added when - // bind mount is created and hence we must carry it over. - if checkForNetDev(options) { - bindOpts = append(bindOpts, "_netdev") - } - - for _, option := range options { - switch option { - case "bind": - bind = true - case "remount": - default: - bindRemountOpts = append(bindRemountOpts, option) - } - } - - return bind, bindOpts, bindRemountOpts -} - -func checkForNetDev(options []string) bool { - for _, option := range options { - if option == "_netdev" { - return true - } - } - return false -} - -// HasMountRefs checks the mountPath contains any of the mountRefs. -// This is a workaround for the unmount device issue caused by gci mounter. -// In GCI cluster, if gci mounter is used for mounting, the container started by mounter -// script will cause additional mounts created in the container. Since these mounts are -// irrelevant to the original mounts, they should be not considered when checking the -// mount references. Current solution is to filter out those mount paths that contain -// the string of original mount path. -// Plan to work on better approach to solve this issue. -func HasMountRefs(mountPath string, mountRefs []string) bool { - count := 0 - for _, ref := range mountRefs { - if !strings.Contains(ref, mountPath) { - count = count + 1 - } - } - return count > 0 -} - -// PathWithinBase checks if give path is within given base directory. -func PathWithinBase(fullPath, basePath string) bool { - rel, err := filepath.Rel(basePath, fullPath) - if err != nil { - return false - } - if startsWithBackstep(rel) { - // Needed to escape the base path - return false - } - return true -} - -// startsWithBackstep checks if the given path starts with a backstep segment -func startsWithBackstep(rel string) bool { - // normalize to / and check for ../ - return rel == ".." || strings.HasPrefix(filepath.ToSlash(rel), "../") -} - -// getFileType checks for file/directory/socket and block/character devices -func getFileType(pathname string) (FileType, error) { - var pathType FileType - info, err := os.Stat(pathname) - if os.IsNotExist(err) { - return pathType, fmt.Errorf("path %q does not exist", pathname) - } - // err in call to os.Stat - if err != nil { - return pathType, err - } - - // checks whether the mode is the target mode - isSpecificMode := func(mode, targetMode os.FileMode) bool { - return mode&targetMode == targetMode - } - - mode := info.Mode() - if mode.IsDir() { - return FileTypeDirectory, nil - } else if mode.IsRegular() { - return FileTypeFile, nil - } else if isSpecificMode(mode, os.ModeSocket) { - return FileTypeSocket, nil - } else if isSpecificMode(mode, os.ModeDevice) { - if isSpecificMode(mode, os.ModeCharDevice) { - return FileTypeCharDev, nil - } - return FileTypeBlockDev, nil - } - - return pathType, fmt.Errorf("only recognise file, directory, socket, block device and character device") -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go deleted file mode 100644 index 23a66539b56..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go +++ /dev/null @@ -1,1345 +0,0 @@ -// +build linux,!providerless - -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path" - "path/filepath" - "strconv" - "strings" - "syscall" - - "golang.org/x/sys/unix" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/klog" - utilexec "k8s.io/utils/exec" - utilio "k8s.io/utils/io" - utilpath "k8s.io/utils/path" -) - -const ( - // How many times to retry for a consistent read of /proc/mounts. - maxListTries = 3 - // Number of fields per line in /proc/mounts as per the fstab man page. - expectedNumFieldsPerLine = 6 - // At least number of fields per line in /proc//mountinfo. - expectedAtLeastNumFieldsPerMountInfo = 10 - // Location of the mount file to use - procMountsPath = "/proc/mounts" - // Location of the mountinfo file - procMountInfoPath = "/proc/self/mountinfo" - // 'fsck' found errors and corrected them - fsckErrorsCorrected = 1 - // 'fsck' found errors but exited without correcting them - fsckErrorsUncorrected = 4 - - // place for subpath mounts - containerSubPathDirectoryName = "volume-subpaths" - // syscall.Openat flags used to traverse directories not following symlinks - nofollowFlags = unix.O_RDONLY | unix.O_NOFOLLOW - // flags for getting file descriptor without following the symlink - openFDFlags = unix.O_NOFOLLOW | unix.O_PATH -) - -// Mounter provides the default implementation of mount.Interface -// for the linux platform. This implementation assumes that the -// kubelet is running in the host's root mount namespace. -type Mounter struct { - mounterPath string - withSystemd bool -} - -// New returns a mount.Interface for the current system. -// It provides options to override the default mounter behavior. -// mounterPath allows using an alternative to `/bin/mount` for mounting. -func New(mounterPath string) Interface { - return &Mounter{ - mounterPath: mounterPath, - withSystemd: detectSystemd(), - } -} - -// Mount mounts source to target as fstype with given options. 'source' and 'fstype' must -// be an empty string in case it's not required, e.g. for remount, or for auto filesystem -// type, where kernel handles fstype for you. The mount 'options' is a list of options, -// currently come from mount(8), e.g. "ro", "remount", "bind", etc. If no more option is -// required, call Mount with an empty string list or nil. -func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error { - // Path to mounter binary if containerized mounter is needed. Otherwise, it is set to empty. - // All Linux distros are expected to be shipped with a mount utility that a support bind mounts. - mounterPath := "" - bind, bindOpts, bindRemountOpts := isBind(options) - if bind { - err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts) - if err != nil { - return err - } - return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindRemountOpts) - } - // The list of filesystems that require containerized mounter on GCI image cluster - fsTypesNeedMounter := sets.NewString("nfs", "glusterfs", "ceph", "cifs") - if fsTypesNeedMounter.Has(fstype) { - mounterPath = mounter.mounterPath - } - return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, options) -} - -// doMount runs the mount command. mounterPath is the path to mounter binary if containerized mounter is used. -func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source string, target string, fstype string, options []string) error { - mountArgs := makeMountArgs(source, target, fstype, options) - if len(mounterPath) > 0 { - mountArgs = append([]string{mountCmd}, mountArgs...) - mountCmd = mounterPath - } - - if mounter.withSystemd { - // Try to run mount via systemd-run --scope. This will escape the - // service where kubelet runs and any fuse daemons will be started in a - // specific scope. kubelet service than can be restarted without killing - // these fuse daemons. - // - // Complete command line (when mounterPath is not used): - // systemd-run --description=... --scope -- mount -t - // - // Expected flow: - // * systemd-run creates a transient scope (=~ cgroup) and executes its - // argument (/bin/mount) there. - // * mount does its job, forks a fuse daemon if necessary and finishes. - // (systemd-run --scope finishes at this point, returning mount's exit - // code and stdout/stderr - thats one of --scope benefits). - // * systemd keeps the fuse daemon running in the scope (i.e. in its own - // cgroup) until the fuse daemon dies (another --scope benefit). - // Kubelet service can be restarted and the fuse daemon survives. - // * When the fuse daemon dies (e.g. during unmount) systemd removes the - // scope automatically. - // - // systemd-mount is not used because it's too new for older distros - // (CentOS 7, Debian Jessie). - mountCmd, mountArgs = addSystemdScope("systemd-run", target, mountCmd, mountArgs) - } //else { - // No systemd-run on the host (or we failed to check it), assume kubelet - // does not run as a systemd service. - // No code here, mountCmd and mountArgs are already populated. - //} - - klog.V(4).Infof("Mounting cmd (%s) with arguments (%s)", mountCmd, mountArgs) - command := exec.Command(mountCmd, mountArgs...) - output, err := command.CombinedOutput() - if err != nil { - args := strings.Join(mountArgs, " ") - klog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, args, string(output)) - return fmt.Errorf("mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s", - err, mountCmd, args, string(output)) - } - return err -} - -// detectSystemd returns true if OS runs with systemd as init. When not sure -// (permission errors, ...), it returns false. -// There may be different ways how to detect systemd, this one makes sure that -// systemd-runs (needed by Mount()) works. -func detectSystemd() bool { - if _, err := exec.LookPath("systemd-run"); err != nil { - klog.V(2).Info("Detected OS without systemd") - return false - } - // Try to run systemd-run --scope /bin/true, that should be enough - // to make sure that systemd is really running and not just installed, - // which happens when running in a container with a systemd-based image - // but with different pid 1. - cmd := exec.Command("systemd-run", "--description=Kubernetes systemd probe", "--scope", "true") - output, err := cmd.CombinedOutput() - if err != nil { - klog.V(2).Infof("Cannot run systemd-run, assuming non-systemd OS") - klog.V(4).Infof("systemd-run failed with: %v", err) - klog.V(4).Infof("systemd-run output: %s", string(output)) - return false - } - klog.V(2).Info("Detected OS with systemd") - return true -} - -// makeMountArgs makes the arguments to the mount(8) command. -func makeMountArgs(source, target, fstype string, options []string) []string { - // Build mount command as follows: - // mount [-t $fstype] [-o $options] [$source] $target - mountArgs := []string{} - if len(fstype) > 0 { - mountArgs = append(mountArgs, "-t", fstype) - } - if len(options) > 0 { - mountArgs = append(mountArgs, "-o", strings.Join(options, ",")) - } - if len(source) > 0 { - mountArgs = append(mountArgs, source) - } - mountArgs = append(mountArgs, target) - - return mountArgs -} - -// addSystemdScope adds "system-run --scope" to given command line -func addSystemdScope(systemdRunPath, mountName, command string, args []string) (string, []string) { - descriptionArg := fmt.Sprintf("--description=Kubernetes transient mount for %s", mountName) - systemdRunArgs := []string{descriptionArg, "--scope", "--", command} - return systemdRunPath, append(systemdRunArgs, args...) -} - -// Unmount unmounts the target. -func (mounter *Mounter) Unmount(target string) error { - klog.V(4).Infof("Unmounting %s", target) - command := exec.Command("umount", target) - output, err := command.CombinedOutput() - if err != nil { - return fmt.Errorf("unmount failed: %v\nUnmounting arguments: %s\nOutput: %s", err, target, string(output)) - } - return nil -} - -// List returns a list of all mounted filesystems. -func (*Mounter) List() ([]MntPoint, error) { - return listProcMounts(procMountsPath) -} - -// IsMountPointMatch determines if a directory is a mountpoint. -func (mounter *Mounter) IsMountPointMatch(mp MntPoint, dir string) bool { - deletedDir := fmt.Sprintf("%s\\040(deleted)", dir) - return ((mp.Path == dir) || (mp.Path == deletedDir)) -} - -// IsNotMountPoint determines if a directory is not a mountpoint. -func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) { - return IsNotMountPoint(mounter, dir) -} - -// IsLikelyNotMountPoint determines if a directory is not a mountpoint. -// It is fast but not necessarily ALWAYS correct. If the path is in fact -// a bind mount from one part of a mount to another it will not be detected. -// mkdir /tmp/a /tmp/b; mount --bin /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") -// will return true. When in fact /tmp/b is a mount point. If this situation -// if of interest to you, don't use this function... -func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { - stat, err := os.Stat(file) - if err != nil { - return true, err - } - rootStat, err := os.Lstat(filepath.Dir(strings.TrimSuffix(file, "/"))) - if err != nil { - return true, err - } - // If the directory has a different device as parent, then it is a mountpoint. - if stat.Sys().(*syscall.Stat_t).Dev != rootStat.Sys().(*syscall.Stat_t).Dev { - return false, nil - } - - return true, nil -} - -// DeviceOpened checks if block device in use by calling Open with O_EXCL flag. -// If pathname is not a device, log and return false with nil error. -// If open returns errno EBUSY, return true with nil error. -// If open returns nil, return false with nil error. -// Otherwise, return false with error -func (mounter *Mounter) DeviceOpened(pathname string) (bool, error) { - return exclusiveOpenFailsOnDevice(pathname) -} - -// PathIsDevice uses FileInfo returned from os.Stat to check if path refers -// to a device. -func (mounter *Mounter) PathIsDevice(pathname string) (bool, error) { - pathType, err := mounter.GetFileType(pathname) - isDevice := pathType == FileTypeCharDev || pathType == FileTypeBlockDev - return isDevice, err -} - -func exclusiveOpenFailsOnDevice(pathname string) (bool, error) { - var isDevice bool - finfo, err := os.Stat(pathname) - if os.IsNotExist(err) { - isDevice = false - } - // err in call to os.Stat - if err != nil { - return false, fmt.Errorf( - "PathIsDevice failed for path %q: %v", - pathname, - err) - } - // path refers to a device - if finfo.Mode()&os.ModeDevice != 0 { - isDevice = true - } - - if !isDevice { - klog.Errorf("Path %q is not referring to a device.", pathname) - return false, nil - } - fd, errno := unix.Open(pathname, unix.O_RDONLY|unix.O_EXCL, 0) - // If the device is in use, open will return an invalid fd. - // When this happens, it is expected that Close will fail and throw an error. - defer unix.Close(fd) - if errno == nil { - // device not in use - return false, nil - } else if errno == unix.EBUSY { - // device is in use - return true, nil - } - // error during call to Open - return false, errno -} - -// GetDeviceNameFromMount when given a mount point, finds the device name from its global -// mount point -func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) { - return getDeviceNameFromMount(mounter, mountPath, pluginDir) -} - -// getDeviceNameFromMount find the device name from /proc/mounts in which -// the mount path reference should match the given plugin directory. In case no mount path reference -// matches, returns the volume name taken from its given mountPath -func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) { - refs, err := mounter.GetMountRefs(mountPath) - if err != nil { - klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) - return "", err - } - if len(refs) == 0 { - klog.V(4).Infof("Directory %s is not mounted", mountPath) - return "", fmt.Errorf("directory %s is not mounted", mountPath) - } - basemountPath := path.Join(pluginDir, MountsInGlobalPDPath) - for _, ref := range refs { - if strings.HasPrefix(ref, basemountPath) { - volumeID, err := filepath.Rel(basemountPath, ref) - if err != nil { - klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) - return "", err - } - return volumeID, nil - } - } - - return path.Base(mountPath), nil -} - -func listProcMounts(mountFilePath string) ([]MntPoint, error) { - content, err := utilio.ConsistentRead(mountFilePath, maxListTries) - if err != nil { - return nil, err - } - return parseProcMounts(content) -} - -func parseProcMounts(content []byte) ([]MntPoint, error) { - out := []MntPoint{} - lines := strings.Split(string(content), "\n") - for _, line := range lines { - if line == "" { - // the last split() item is empty string following the last \n - continue - } - fields := strings.Fields(line) - if len(fields) != expectedNumFieldsPerLine { - return nil, fmt.Errorf("wrong number of fields (expected %d, got %d): %s", expectedNumFieldsPerLine, len(fields), line) - } - - mp := MntPoint{ - Device: fields[0], - Path: fields[1], - Type: fields[2], - Opts: strings.Split(fields[3], ","), - } - - freq, err := strconv.Atoi(fields[4]) - if err != nil { - return nil, err - } - mp.Freq = freq - - pass, err := strconv.Atoi(fields[5]) - if err != nil { - return nil, err - } - mp.Pass = pass - - out = append(out, mp) - } - return out, nil -} - -// MakeRShared makes the bind mount rshared if needed. -func (mounter *Mounter) MakeRShared(path string) error { - return doMakeRShared(path, procMountInfoPath) -} - -// GetFileType returns the string FileType of the path. -func (mounter *Mounter) GetFileType(pathname string) (FileType, error) { - return getFileType(pathname) -} - -// MakeDir creates a directory at the specified path. -func (mounter *Mounter) MakeDir(pathname string) error { - err := os.MkdirAll(pathname, os.FileMode(0755)) - if err != nil { - if !os.IsExist(err) { - return err - } - } - return nil -} - -// MakeFile creates a file with permissions 0644 at the specified path. -func (mounter *Mounter) MakeFile(pathname string) error { - f, err := os.OpenFile(pathname, os.O_CREATE, os.FileMode(0644)) - if err != nil { - if !os.IsExist(err) { - return err - } - defer f.Close() - } - return nil -} - -// ExistsPath returns true if the specified path exists. -func (mounter *Mounter) ExistsPath(pathname string) (bool, error) { - return utilpath.Exists(utilpath.CheckFollowSymlink, pathname) -} - -// EvalHostSymlinks returns the actual path a symlink points to. -func (mounter *Mounter) EvalHostSymlinks(pathname string) (string, error) { - return filepath.EvalSymlinks(pathname) -} - -// formatAndMount uses unix utils to format and mount the given disk -func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, fstype string, options []string) error { - readOnly := false - for _, option := range options { - if option == "ro" { - readOnly = true - break - } - } - - options = append(options, "defaults") - - if !readOnly { - // Run fsck on the disk to fix repairable issues, only do this for volumes requested as rw. - klog.V(4).Infof("Checking for issues with fsck on disk: %s", source) - args := []string{"-a", source} - out, err := mounter.Exec.Run("fsck", args...) - if err != nil { - ee, isExitError := err.(utilexec.ExitError) - switch { - case err == utilexec.ErrExecutableNotFound: - klog.Warning("'fsck' not found on system; continuing mount without running 'fsck'") - case isExitError && ee.ExitStatus() == fsckErrorsCorrected: - klog.Infof("Device %s has errors which were corrected by fsck", source) - case isExitError && ee.ExitStatus() == fsckErrorsUncorrected: - return fmt.Errorf("'fsck' found errors on device %s but could not correct them: %s", source, string(out)) - case isExitError && ee.ExitStatus() > fsckErrorsUncorrected: - klog.Infof("`fsck` error %s", string(out)) - } - } - } - - // Try to mount the disk - klog.V(4).Infof("Attempting to mount disk: %s %s %s", fstype, source, target) - mountErr := mounter.Interface.Mount(source, target, fstype, options) - if mountErr != nil { - // Mount failed. This indicates either that the disk is unformatted or - // it contains an unexpected filesystem. - existingFormat, err := mounter.GetDiskFormat(source) - if err != nil { - return err - } - if existingFormat == "" { - if readOnly { - // Don't attempt to format if mounting as readonly, return an error to reflect this. - return errors.New("failed to mount unformatted volume as read only") - } - - // Disk is unformatted so format it. - args := []string{source} - // Use 'ext4' as the default - if len(fstype) == 0 { - fstype = "ext4" - } - - if fstype == "ext4" || fstype == "ext3" { - args = []string{ - "-F", // Force flag - "-m0", // Zero blocks reserved for super-user - source, - } - } - klog.Infof("Disk %q appears to be unformatted, attempting to format as type: %q with options: %v", source, fstype, args) - _, err := mounter.Exec.Run("mkfs."+fstype, args...) - if err == nil { - // the disk has been formatted successfully try to mount it again. - klog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target) - return mounter.Interface.Mount(source, target, fstype, options) - } - klog.Errorf("format of disk %q failed: type:(%q) target:(%q) options:(%q)error:(%v)", source, fstype, target, options, err) - return err - } - // Disk is already formatted and failed to mount - if len(fstype) == 0 || fstype == existingFormat { - // This is mount error - return mountErr - } - // Block device is formatted with unexpected filesystem, let the user know - return fmt.Errorf("failed to mount the volume as %q, it already contains %s. Mount error: %v", fstype, existingFormat, mountErr) - } - return mountErr -} - -// GetDiskFormat uses 'blkid' to see if the given disk is unformatted -func (mounter *SafeFormatAndMount) GetDiskFormat(disk string) (string, error) { - args := []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", disk} - klog.V(4).Infof("Attempting to determine if disk %q is formatted using blkid with args: (%v)", disk, args) - dataOut, err := mounter.Exec.Run("blkid", args...) - output := string(dataOut) - klog.V(4).Infof("Output: %q, err: %v", output, err) - - if err != nil { - if exit, ok := err.(utilexec.ExitError); ok { - if exit.ExitStatus() == 2 { - // Disk device is unformatted. - // For `blkid`, if the specified token (TYPE/PTTYPE, etc) was - // not found, or no (specified) devices could be identified, an - // exit code of 2 is returned. - return "", nil - } - } - klog.Errorf("Could not determine if disk %q is formatted (%v)", disk, err) - return "", err - } - - var fstype, pttype string - - lines := strings.Split(output, "\n") - for _, l := range lines { - if len(l) <= 0 { - // Ignore empty line. - continue - } - cs := strings.Split(l, "=") - if len(cs) != 2 { - return "", fmt.Errorf("blkid returns invalid output: %s", output) - } - // TYPE is filesystem type, and PTTYPE is partition table type, according - // to https://www.kernel.org/pub/linux/utils/util-linux/v2.21/libblkid-docs/. - if cs[0] == "TYPE" { - fstype = cs[1] - } else if cs[0] == "PTTYPE" { - pttype = cs[1] - } - } - - if len(pttype) > 0 { - klog.V(4).Infof("Disk %s detected partition table type: %s", disk, pttype) - // Returns a special non-empty string as filesystem type, then kubelet - // will not format it. - return "unknown data, probably partitions", nil - } - - return fstype, nil -} - -// isShared returns true, if given path is on a mount point that has shared -// mount propagation. -func isShared(mount string, mountInfoPath string) (bool, error) { - info, err := findMountInfo(mount, mountInfoPath) - if err != nil { - return false, err - } - - // parse optional parameters - for _, opt := range info.optionalFields { - if strings.HasPrefix(opt, "shared:") { - return true, nil - } - } - return false, nil -} - -// This represents a single line in /proc//mountinfo. -type mountInfo struct { - // Unique ID for the mount (maybe reused after umount). - id int - // The ID of the parent mount (or of self for the root of this mount namespace's mount tree). - parentID int - // The value of `st_dev` for files on this filesystem. - majorMinor string - // The pathname of the directory in the filesystem which forms the root of this mount. - root string - // Mount source, filesystem-specific information. e.g. device, tmpfs name. - source string - // Mount point, the pathname of the mount point. - mountPoint string - // Optional fields, zero or more fields of the form "tag[:value]". - optionalFields []string - // The filesystem type in the form "type[.subtype]". - fsType string - // Per-mount options. - mountOptions []string - // Per-superblock options. - superOptions []string -} - -// parseMountInfo parses /proc/xxx/mountinfo. -func parseMountInfo(filename string) ([]mountInfo, error) { - content, err := utilio.ConsistentRead(filename, maxListTries) - if err != nil { - return []mountInfo{}, err - } - contentStr := string(content) - infos := []mountInfo{} - - for _, line := range strings.Split(contentStr, "\n") { - if line == "" { - // the last split() item is empty string following the last \n - continue - } - // See `man proc` for authoritative description of format of the file. - fields := strings.Fields(line) - if len(fields) < expectedAtLeastNumFieldsPerMountInfo { - return nil, fmt.Errorf("wrong number of fields in (expected at least %d, got %d): %s", expectedAtLeastNumFieldsPerMountInfo, len(fields), line) - } - id, err := strconv.Atoi(fields[0]) - if err != nil { - return nil, err - } - parentID, err := strconv.Atoi(fields[1]) - if err != nil { - return nil, err - } - info := mountInfo{ - id: id, - parentID: parentID, - majorMinor: fields[2], - root: fields[3], - mountPoint: fields[4], - mountOptions: strings.Split(fields[5], ","), - } - // All fields until "-" are "optional fields". - i := 6 - for ; i < len(fields) && fields[i] != "-"; i++ { - info.optionalFields = append(info.optionalFields, fields[i]) - } - // Parse the rest 3 fields. - i++ - if len(fields)-i < 3 { - return nil, fmt.Errorf("expect 3 fields in %s, got %d", line, len(fields)-i) - } - info.fsType = fields[i] - info.source = fields[i+1] - info.superOptions = strings.Split(fields[i+2], ",") - infos = append(infos, info) - } - return infos, nil -} - -func findMountInfo(path, mountInfoPath string) (mountInfo, error) { - infos, err := parseMountInfo(mountInfoPath) - if err != nil { - return mountInfo{}, err - } - - // process /proc/xxx/mountinfo in backward order and find the first mount - // point that is prefix of 'path' - that's the mount where path resides - var info *mountInfo - for i := len(infos) - 1; i >= 0; i-- { - if PathWithinBase(path, infos[i].mountPoint) { - info = &infos[i] - break - } - } - if info == nil { - return mountInfo{}, fmt.Errorf("cannot find mount point for %q", path) - } - return *info, nil -} - -// doMakeRShared is common implementation of MakeRShared on Linux. It checks if -// path is shared and bind-mounts it as rshared if needed. mountCmd and -// mountArgs are expected to contain mount-like command, doMakeRShared will add -// '--bind ' and '--make-rshared ' to mountArgs. -func doMakeRShared(path string, mountInfoFilename string) error { - shared, err := isShared(path, mountInfoFilename) - if err != nil { - return err - } - if shared { - klog.V(4).Infof("Directory %s is already on a shared mount", path) - return nil - } - - klog.V(2).Infof("Bind-mounting %q with shared mount propagation", path) - // mount --bind /var/lib/kubelet /var/lib/kubelet - if err := syscall.Mount(path, path, "" /*fstype*/, syscall.MS_BIND, "" /*data*/); err != nil { - return fmt.Errorf("failed to bind-mount %s: %v", path, err) - } - - // mount --make-rshared /var/lib/kubelet - if err := syscall.Mount(path, path, "" /*fstype*/, syscall.MS_SHARED|syscall.MS_REC, "" /*data*/); err != nil { - return fmt.Errorf("failed to make %s rshared: %v", path, err) - } - - return nil -} - -// getSELinuxSupport is common implementation of GetSELinuxSupport on Linux. -func getSELinuxSupport(path string, mountInfoFilename string) (bool, error) { - info, err := findMountInfo(path, mountInfoFilename) - if err != nil { - return false, err - } - - // "seclabel" can be both in mount options and super options. - for _, opt := range info.superOptions { - if opt == "seclabel" { - return true, nil - } - } - for _, opt := range info.mountOptions { - if opt == "seclabel" { - return true, nil - } - } - return false, nil -} - -// PrepareSafeSubpath safely creates a new subpath. -func (mounter *Mounter) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) { - newHostPath, err = doBindSubPath(mounter, subPath) - - // There is no action when the container starts. Bind-mount will be cleaned - // when container stops by CleanSubPaths. - cleanupAction = nil - return newHostPath, cleanupAction, err -} - -// This implementation is shared between Linux and NsEnterMounter -func safeOpenSubPath(mounter Interface, subpath Subpath) (int, error) { - if !PathWithinBase(subpath.Path, subpath.VolumePath) { - return -1, fmt.Errorf("subpath %q not within volume path %q", subpath.Path, subpath.VolumePath) - } - fd, err := doSafeOpen(subpath.Path, subpath.VolumePath) - if err != nil { - return -1, fmt.Errorf("error opening subpath %v: %v", subpath.Path, err) - } - return fd, nil -} - -// prepareSubpathTarget creates target for bind-mount of subpath. It returns -// "true" when the target already exists and something is mounted there. -// Given Subpath must have all paths with already resolved symlinks and with -// paths relevant to kubelet (when it runs in a container). -// This function is called also by NsEnterMounter. It works because -// /var/lib/kubelet is mounted from the host into the container with Kubelet as -// /var/lib/kubelet too. -func prepareSubpathTarget(mounter Interface, subpath Subpath) (bool, string, error) { - // Early check for already bind-mounted subpath. - bindPathTarget := getSubpathBindTarget(subpath) - notMount, err := IsNotMountPoint(mounter, bindPathTarget) - if err != nil { - if !os.IsNotExist(err) { - return false, "", fmt.Errorf("error checking path %s for mount: %s", bindPathTarget, err) - } - // Ignore ErrorNotExist: the file/directory will be created below if it does not exist yet. - notMount = true - } - if !notMount { - // It's already mounted - klog.V(5).Infof("Skipping bind-mounting subpath %s: already mounted", bindPathTarget) - return true, bindPathTarget, nil - } - - // bindPathTarget is in /var/lib/kubelet and thus reachable without any - // translation even to containerized kubelet. - bindParent := filepath.Dir(bindPathTarget) - err = os.MkdirAll(bindParent, 0750) - if err != nil && !os.IsExist(err) { - return false, "", fmt.Errorf("error creating directory %s: %s", bindParent, err) - } - - t, err := os.Lstat(subpath.Path) - if err != nil { - return false, "", fmt.Errorf("lstat %s failed: %s", subpath.Path, err) - } - - if t.Mode()&os.ModeDir > 0 { - if err = os.Mkdir(bindPathTarget, 0750); err != nil && !os.IsExist(err) { - return false, "", fmt.Errorf("error creating directory %s: %s", bindPathTarget, err) - } - } else { - // "/bin/touch ". - // A file is enough for all possible targets (symlink, device, pipe, - // socket, ...), bind-mounting them into a file correctly changes type - // of the target file. - if err = ioutil.WriteFile(bindPathTarget, []byte{}, 0640); err != nil { - return false, "", fmt.Errorf("error creating file %s: %s", bindPathTarget, err) - } - } - return false, bindPathTarget, nil -} - -func getSubpathBindTarget(subpath Subpath) string { - // containerName is DNS label, i.e. safe as a directory name. - return filepath.Join(subpath.PodDir, containerSubPathDirectoryName, subpath.VolumeName, subpath.ContainerName, strconv.Itoa(subpath.VolumeMountIndex)) -} - -func doBindSubPath(mounter Interface, subpath Subpath) (hostPath string, err error) { - // Linux, kubelet runs on the host: - // - safely open the subpath - // - bind-mount /proc//fd/ to subpath target - // User can't change /proc//fd/ to point to a bad place. - - // Evaluate all symlinks here once for all subsequent functions. - newVolumePath, err := filepath.EvalSymlinks(subpath.VolumePath) - if err != nil { - return "", fmt.Errorf("error resolving symlinks in %q: %v", subpath.VolumePath, err) - } - newPath, err := filepath.EvalSymlinks(subpath.Path) - if err != nil { - return "", fmt.Errorf("error resolving symlinks in %q: %v", subpath.Path, err) - } - klog.V(5).Infof("doBindSubPath %q (%q) for volumepath %q", subpath.Path, newPath, subpath.VolumePath) - subpath.VolumePath = newVolumePath - subpath.Path = newPath - - fd, err := safeOpenSubPath(mounter, subpath) - if err != nil { - return "", err - } - defer syscall.Close(fd) - - alreadyMounted, bindPathTarget, err := prepareSubpathTarget(mounter, subpath) - if err != nil { - return "", err - } - if alreadyMounted { - return bindPathTarget, nil - } - - success := false - defer func() { - // Cleanup subpath on error - if !success { - klog.V(4).Infof("doBindSubPath() failed for %q, cleaning up subpath", bindPathTarget) - if cleanErr := cleanSubPath(mounter, subpath); cleanErr != nil { - klog.Errorf("Failed to clean subpath %q: %v", bindPathTarget, cleanErr) - } - } - }() - - kubeletPid := os.Getpid() - mountSource := fmt.Sprintf("/proc/%d/fd/%v", kubeletPid, fd) - - // Do the bind mount - options := []string{"bind"} - klog.V(5).Infof("bind mounting %q at %q", mountSource, bindPathTarget) - if err = mounter.Mount(mountSource, bindPathTarget, "" /*fstype*/, options); err != nil { - return "", fmt.Errorf("error mounting %s: %s", subpath.Path, err) - } - success = true - - klog.V(3).Infof("Bound SubPath %s into %s", subpath.Path, bindPathTarget) - return bindPathTarget, nil -} - -// CleanSubPaths cleans up the subpath mounts for the volume in the pod directory. -func (mounter *Mounter) CleanSubPaths(podDir string, volumeName string) error { - return doCleanSubPaths(mounter, podDir, volumeName) -} - -// This implementation is shared between Linux and NsEnterMounter -func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error { - // scan /var/lib/kubelet/pods//volume-subpaths//* - subPathDir := filepath.Join(podDir, containerSubPathDirectoryName, volumeName) - klog.V(4).Infof("Cleaning up subpath mounts for %s", subPathDir) - - containerDirs, err := ioutil.ReadDir(subPathDir) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return fmt.Errorf("error reading %s: %s", subPathDir, err) - } - - for _, containerDir := range containerDirs { - if !containerDir.IsDir() { - klog.V(4).Infof("Container file is not a directory: %s", containerDir.Name()) - continue - } - klog.V(4).Infof("Cleaning up subpath mounts for container %s", containerDir.Name()) - - // scan /var/lib/kubelet/pods//volume-subpaths///* - fullContainerDirPath := filepath.Join(subPathDir, containerDir.Name()) - subPaths, err := ioutil.ReadDir(fullContainerDirPath) - if err != nil { - return fmt.Errorf("error reading %s: %s", fullContainerDirPath, err) - } - for _, subPath := range subPaths { - if err = doCleanSubPath(mounter, fullContainerDirPath, subPath.Name()); err != nil { - return err - } - } - // Whole container has been processed, remove its directory. - if err := os.Remove(fullContainerDirPath); err != nil { - return fmt.Errorf("error deleting %s: %s", fullContainerDirPath, err) - } - klog.V(5).Infof("Removed %s", fullContainerDirPath) - } - // Whole pod volume subpaths have been cleaned up, remove its subpath directory. - if err := os.Remove(subPathDir); err != nil { - return fmt.Errorf("error deleting %s: %s", subPathDir, err) - } - klog.V(5).Infof("Removed %s", subPathDir) - - // Remove entire subpath directory if it's the last one - podSubPathDir := filepath.Join(podDir, containerSubPathDirectoryName) - if err := os.Remove(podSubPathDir); err != nil && !os.IsExist(err) { - return fmt.Errorf("error deleting %s: %s", podSubPathDir, err) - } - klog.V(5).Infof("Removed %s", podSubPathDir) - return nil -} - -// doCleanSubPath tears down the single subpath bind mount -func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string) error { - // process /var/lib/kubelet/pods//volume-subpaths/// - klog.V(4).Infof("Cleaning up subpath mounts for subpath %v", subPathIndex) - fullSubPath := filepath.Join(fullContainerDirPath, subPathIndex) - notMnt, err := IsNotMountPoint(mounter, fullSubPath) - if err != nil { - return fmt.Errorf("error checking %s for mount: %s", fullSubPath, err) - } - // Unmount it - if !notMnt { - if err = mounter.Unmount(fullSubPath); err != nil { - return fmt.Errorf("error unmounting %s: %s", fullSubPath, err) - } - klog.V(5).Infof("Unmounted %s", fullSubPath) - } - // Remove it *non*-recursively, just in case there were some hiccups. - if err = os.Remove(fullSubPath); err != nil { - return fmt.Errorf("error deleting %s: %s", fullSubPath, err) - } - klog.V(5).Infof("Removed %s", fullSubPath) - return nil -} - -// cleanSubPath will teardown the subpath bind mount and any remove any directories if empty -func cleanSubPath(mounter Interface, subpath Subpath) error { - containerDir := filepath.Join(subpath.PodDir, containerSubPathDirectoryName, subpath.VolumeName, subpath.ContainerName) - - // Clean subdir bindmount - if err := doCleanSubPath(mounter, containerDir, strconv.Itoa(subpath.VolumeMountIndex)); err != nil && !os.IsNotExist(err) { - return err - } - - // Recursively remove directories if empty - if err := removeEmptyDirs(subpath.PodDir, containerDir); err != nil { - return err - } - - return nil -} - -// removeEmptyDirs works backwards from endDir to baseDir and removes each directory -// if it is empty. It stops once it encounters a directory that has content -func removeEmptyDirs(baseDir, endDir string) error { - if !PathWithinBase(endDir, baseDir) { - return fmt.Errorf("endDir %q is not within baseDir %q", endDir, baseDir) - } - - for curDir := endDir; curDir != baseDir; curDir = filepath.Dir(curDir) { - s, err := os.Stat(curDir) - if err != nil { - if os.IsNotExist(err) { - klog.V(5).Infof("curDir %q doesn't exist, skipping", curDir) - continue - } - return fmt.Errorf("error stat %q: %v", curDir, err) - } - if !s.IsDir() { - return fmt.Errorf("path %q not a directory", curDir) - } - - err = os.Remove(curDir) - if os.IsExist(err) { - klog.V(5).Infof("Directory %q not empty, not removing", curDir) - break - } else if err != nil { - return fmt.Errorf("error removing directory %q: %v", curDir, err) - } - klog.V(5).Infof("Removed directory %q", curDir) - } - return nil -} - -// SafeMakeDir safely creates a subdirectory at the specified path base -func (mounter *Mounter) SafeMakeDir(subdir string, base string, perm os.FileMode) error { - realBase, err := filepath.EvalSymlinks(base) - if err != nil { - return fmt.Errorf("error resolving symlinks in %s: %s", base, err) - } - - realFullPath := filepath.Join(realBase, subdir) - - return doSafeMakeDir(realFullPath, realBase, perm) -} - -// GetMountRefs finds all of the mount references to the source. -func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) { - if _, err := os.Stat(pathname); os.IsNotExist(err) { - return []string{}, nil - } else if err != nil { - return nil, err - } - realpath, err := filepath.EvalSymlinks(pathname) - if err != nil { - return nil, err - } - return searchMountPoints(realpath, procMountInfoPath) -} - -// GetSELinuxSupport is common implementation of GetSELinuxSupport on Linux. -func (mounter *Mounter) GetSELinuxSupport(pathname string) (bool, error) { - return getSELinuxSupport(pathname, procMountInfoPath) -} - -// GetFSGroup returns the filesystem group for the path name. -func (mounter *Mounter) GetFSGroup(pathname string) (int64, error) { - realpath, err := filepath.EvalSymlinks(pathname) - if err != nil { - return 0, err - } - return getFSGroup(realpath) -} - -// GetMode returns the unix filesystem mode for the path. -func (mounter *Mounter) GetMode(pathname string) (os.FileMode, error) { - return getMode(pathname) -} - -// This implementation is shared between Linux and NsEnterMounter -func getFSGroup(pathname string) (int64, error) { - info, err := os.Stat(pathname) - if err != nil { - return 0, err - } - return int64(info.Sys().(*syscall.Stat_t).Gid), nil -} - -// This implementation is shared between Linux and NsEnterMounter -func getMode(pathname string) (os.FileMode, error) { - info, err := os.Stat(pathname) - if err != nil { - return 0, err - } - return info.Mode(), nil -} - -// This implementation is shared between Linux and NsEnterMounter. Both pathname -// and base must be either already resolved symlinks or that will be resolved in -// kubelet's mount namespace (in case it runs containerized). -func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { - klog.V(4).Infof("Creating directory %q within base %q", pathname, base) - - if !PathWithinBase(pathname, base) { - return fmt.Errorf("path %s is outside of allowed base %s", pathname, base) - } - - // Quick check if the directory already exists - s, err := os.Stat(pathname) - if err == nil { - // Path exists - if s.IsDir() { - // The directory already exists. It can be outside of the parent, - // but there is no race-proof check. - klog.V(4).Infof("Directory %s already exists", pathname) - return nil - } - return &os.PathError{Op: "mkdir", Path: pathname, Err: syscall.ENOTDIR} - } - - // Find all existing directories - existingPath, toCreate, err := findExistingPrefix(base, pathname) - if err != nil { - return fmt.Errorf("error opening directory %s: %s", pathname, err) - } - // Ensure the existing directory is inside allowed base - fullExistingPath, err := filepath.EvalSymlinks(existingPath) - if err != nil { - return fmt.Errorf("error opening directory %s: %s", existingPath, err) - } - if !PathWithinBase(fullExistingPath, base) { - return fmt.Errorf("path %s is outside of allowed base %s", fullExistingPath, err) - } - - klog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) - parentFD, err := doSafeOpen(fullExistingPath, base) - if err != nil { - return fmt.Errorf("cannot open directory %s: %s", existingPath, err) - } - childFD := -1 - defer func() { - if parentFD != -1 { - if err = syscall.Close(parentFD); err != nil { - klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) - } - } - if childFD != -1 { - if err = syscall.Close(childFD); err != nil { - klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", childFD, pathname, err) - } - } - }() - - currentPath := fullExistingPath - // create the directories one by one, making sure nobody can change - // created directory into symlink. - for _, dir := range toCreate { - currentPath = filepath.Join(currentPath, dir) - klog.V(4).Infof("Creating %s", dir) - err = syscall.Mkdirat(parentFD, currentPath, uint32(perm)) - if err != nil { - return fmt.Errorf("cannot create directory %s: %s", currentPath, err) - } - // Dive into the created directory - childFD, err = syscall.Openat(parentFD, dir, nofollowFlags, 0) - if err != nil { - return fmt.Errorf("cannot open %s: %s", currentPath, err) - } - // We can be sure that childFD is safe to use. It could be changed - // by user after Mkdirat() and before Openat(), however: - // - it could not be changed to symlink - we use nofollowFlags - // - it could be changed to a file (or device, pipe, socket, ...) - // but either subsequent Mkdirat() fails or we mount this file - // to user's container. Security is no violated in both cases - // and user either gets error or the file that it can already access. - - if err = syscall.Close(parentFD); err != nil { - klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) - } - parentFD = childFD - childFD = -1 - } - - // Everything was created. mkdirat(..., perm) above was affected by current - // umask and we must apply the right permissions to the last directory - // (that's the one that will be available to the container as subpath) - // so user can read/write it. This is the behavior of previous code. - // TODO: chmod all created directories, not just the last one. - // parentFD is the last created directory. - - // Translate perm (os.FileMode) to uint32 that fchmod() expects - kernelPerm := uint32(perm & os.ModePerm) - if perm&os.ModeSetgid > 0 { - kernelPerm |= syscall.S_ISGID - } - if perm&os.ModeSetuid > 0 { - kernelPerm |= syscall.S_ISUID - } - if perm&os.ModeSticky > 0 { - kernelPerm |= syscall.S_ISVTX - } - if err = syscall.Fchmod(parentFD, kernelPerm); err != nil { - return fmt.Errorf("chmod %q failed: %s", currentPath, err) - } - return nil -} - -// findExistingPrefix finds prefix of pathname that exists. In addition, it -// returns list of remaining directories that don't exist yet. -func findExistingPrefix(base, pathname string) (string, []string, error) { - rel, err := filepath.Rel(base, pathname) - if err != nil { - return base, nil, err - } - dirs := strings.Split(rel, string(filepath.Separator)) - - // Do OpenAt in a loop to find the first non-existing dir. Resolve symlinks. - // This should be faster than looping through all dirs and calling os.Stat() - // on each of them, as the symlinks are resolved only once with OpenAt(). - currentPath := base - fd, err := syscall.Open(currentPath, syscall.O_RDONLY, 0) - if err != nil { - return pathname, nil, fmt.Errorf("error opening %s: %s", currentPath, err) - } - defer func() { - if err = syscall.Close(fd); err != nil { - klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) - } - }() - for i, dir := range dirs { - // Using O_PATH here will prevent hangs in case user replaces directory with - // fifo - childFD, err := syscall.Openat(fd, dir, unix.O_PATH, 0) - if err != nil { - if os.IsNotExist(err) { - return currentPath, dirs[i:], nil - } - return base, nil, err - } - if err = syscall.Close(fd); err != nil { - klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) - } - fd = childFD - currentPath = filepath.Join(currentPath, dir) - } - return pathname, []string{}, nil -} - -// This implementation is shared between Linux and NsEnterMounter -// Open path and return its fd. -// Symlinks are disallowed (pathname must already resolve symlinks), -// and the path must be within the base directory. -func doSafeOpen(pathname string, base string) (int, error) { - pathname = filepath.Clean(pathname) - base = filepath.Clean(base) - - // Calculate segments to follow - subpath, err := filepath.Rel(base, pathname) - if err != nil { - return -1, err - } - segments := strings.Split(subpath, string(filepath.Separator)) - - // Assumption: base is the only directory that we have under control. - // Base dir is not allowed to be a symlink. - parentFD, err := syscall.Open(base, nofollowFlags, 0) - if err != nil { - return -1, fmt.Errorf("cannot open directory %s: %s", base, err) - } - defer func() { - if parentFD != -1 { - if err = syscall.Close(parentFD); err != nil { - klog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", parentFD, pathname, err) - } - } - }() - - childFD := -1 - defer func() { - if childFD != -1 { - if err = syscall.Close(childFD); err != nil { - klog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", childFD, pathname, err) - } - } - }() - - currentPath := base - - // Follow the segments one by one using openat() to make - // sure the user cannot change already existing directories into symlinks. - for _, seg := range segments { - currentPath = filepath.Join(currentPath, seg) - if !PathWithinBase(currentPath, base) { - return -1, fmt.Errorf("path %s is outside of allowed base %s", currentPath, base) - } - - klog.V(5).Infof("Opening path %s", currentPath) - childFD, err = syscall.Openat(parentFD, seg, openFDFlags, 0) - if err != nil { - return -1, fmt.Errorf("cannot open %s: %s", currentPath, err) - } - - var deviceStat unix.Stat_t - err := unix.Fstat(childFD, &deviceStat) - if err != nil { - return -1, fmt.Errorf("Error running fstat on %s with %v", currentPath, err) - } - fileFmt := deviceStat.Mode & syscall.S_IFMT - if fileFmt == syscall.S_IFLNK { - return -1, fmt.Errorf("Unexpected symlink found %s", currentPath) - } - - // Close parentFD - if err = syscall.Close(parentFD); err != nil { - return -1, fmt.Errorf("closing fd for %q failed: %v", filepath.Dir(currentPath), err) - } - // Set child to new parent - parentFD = childFD - childFD = -1 - } - - // We made it to the end, return this fd, don't close it - finalFD := parentFD - parentFD = -1 - - return finalFD, nil -} - -// searchMountPoints finds all mount references to the source, returns a list of -// mountpoints. -// This function assumes source cannot be device. -// Some filesystems may share a source name, e.g. tmpfs. And for bind mounting, -// it's possible to mount a non-root path of a filesystem, so we need to use -// root path and major:minor to represent mount source uniquely. -// This implementation is shared between Linux and NsEnterMounter -func searchMountPoints(hostSource, mountInfoPath string) ([]string, error) { - mis, err := parseMountInfo(mountInfoPath) - if err != nil { - return nil, err - } - - mountID := 0 - rootPath := "" - majorMinor := "" - - // Finding the underlying root path and major:minor if possible. - // We need search in backward order because it's possible for later mounts - // to overlap earlier mounts. - for i := len(mis) - 1; i >= 0; i-- { - if hostSource == mis[i].mountPoint || PathWithinBase(hostSource, mis[i].mountPoint) { - // If it's a mount point or path under a mount point. - mountID = mis[i].id - rootPath = filepath.Join(mis[i].root, strings.TrimPrefix(hostSource, mis[i].mountPoint)) - majorMinor = mis[i].majorMinor - break - } - } - - if rootPath == "" || majorMinor == "" { - return nil, fmt.Errorf("failed to get root path and major:minor for %s", hostSource) - } - - var refs []string - for i := range mis { - if mis[i].id == mountID { - // Ignore mount entry for mount source itself. - continue - } - if mis[i].root == rootPath && mis[i].majorMinor == majorMinor { - refs = append(refs, mis[i].mountPoint) - } - } - - return refs, nil -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_unsupported.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_unsupported.go deleted file mode 100644 index cab7aecc3ba..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_unsupported.go +++ /dev/null @@ -1,162 +0,0 @@ -// +build !linux,!windows,!providerless - -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "errors" - "os" -) - -// Mounter provides the default unsupported implementation of mount.Interface -type Mounter struct { - mounterPath string -} - -var errUnsupported = errors.New(" util/mount on this platform is not supported") - -// New returns a mount.Interface for the current system. -// It provides options to override the default mounter behavior. -// mounterPath allows using an alternative to `/bin/mount` for mounting. -func New(mounterPath string) Interface { - return &Mounter{ - mounterPath: mounterPath, - } -} - -// Mount returns an error -func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error { - return errUnsupported -} - -// Unmount returns an error -func (mounter *Mounter) Unmount(target string) error { - return errUnsupported -} - -// List returns an error -func (mounter *Mounter) List() ([]MntPoint, error) { - return []MntPoint{}, errUnsupported -} - -// IsMountPointMatch returns an error -func (mounter *Mounter) IsMountPointMatch(mp MntPoint, dir string) bool { - return (mp.Path == dir) -} - -// IsNotMountPoint returns an error -func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) { - return IsNotMountPoint(mounter, dir) -} - -// IsLikelyNotMountPoint returns an error -func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { - return true, errUnsupported -} - -// GetDeviceNameFromMount returns an error -func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) { - return "", errUnsupported -} - -func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) { - return "", errUnsupported -} - -// DeviceOpened returns an error -func (mounter *Mounter) DeviceOpened(pathname string) (bool, error) { - return false, errUnsupported -} - -// PathIsDevice returns an error -func (mounter *Mounter) PathIsDevice(pathname string) (bool, error) { - return true, errUnsupported -} - -// MakeRShared returns an error -func (mounter *Mounter) MakeRShared(path string) error { - return errUnsupported -} - -func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, fstype string, options []string) error { - return mounter.Interface.Mount(source, target, fstype, options) -} - -func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, error) { - return true, errUnsupported -} - -// GetFileType returns an error -func (mounter *Mounter) GetFileType(pathname string) (FileType, error) { - return FileType("fake"), errUnsupported -} - -// MakeDir returns an error -func (mounter *Mounter) MakeDir(pathname string) error { - return errUnsupported -} - -// MakeFile returns an error -func (mounter *Mounter) MakeFile(pathname string) error { - return errUnsupported -} - -// ExistsPath returns an error -func (mounter *Mounter) ExistsPath(pathname string) (bool, error) { - return true, errors.New("not implemented") -} - -// EvalHostSymlinks returns an error -func (mounter *Mounter) EvalHostSymlinks(pathname string) (string, error) { - return "", errUnsupported -} - -// PrepareSafeSubpath returns an error -func (mounter *Mounter) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) { - return subPath.Path, nil, errUnsupported -} - -// CleanSubPaths returns an error -func (mounter *Mounter) CleanSubPaths(podDir string, volumeName string) error { - return errUnsupported -} - -// SafeMakeDir returns an error -func (mounter *Mounter) SafeMakeDir(pathname string, base string, perm os.FileMode) error { - return errUnsupported -} - -// GetMountRefs returns an error -func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) { - return nil, errors.New("not implemented") -} - -// GetFSGroup returns an error -func (mounter *Mounter) GetFSGroup(pathname string) (int64, error) { - return -1, errors.New("not implemented") -} - -// GetSELinuxSupport returns an error -func (mounter *Mounter) GetSELinuxSupport(pathname string) (bool, error) { - return false, errors.New("not implemented") -} - -// GetMode returns an error -func (mounter *Mounter) GetMode(pathname string) (os.FileMode, error) { - return 0, errors.New("not implemented") -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go deleted file mode 100644 index 18fb28417c7..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go +++ /dev/null @@ -1,613 +0,0 @@ -// +build windows,!providerless - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mount - -import ( - "fmt" - "os" - "os/exec" - "path" - "path/filepath" - "strconv" - "strings" - "syscall" - - "k8s.io/klog" - - utilpath "k8s.io/utils/path" -) - -// Mounter provides the default implementation of mount.Interface -// for the windows platform. This implementation assumes that the -// kubelet is running in the host's root mount namespace. -type Mounter struct { - mounterPath string -} - -// New returns a mount.Interface for the current system. -// It provides options to override the default mounter behavior. -// mounterPath allows using an alternative to `/bin/mount` for mounting. -func New(mounterPath string) Interface { - return &Mounter{ - mounterPath: mounterPath, - } -} - -// Mount : mounts source to target as NTFS with given options. -func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error { - target = normalizeWindowsPath(target) - - if source == "tmpfs" { - klog.V(3).Infof("azureMount: mounting source (%q), target (%q), with options (%q)", source, target, options) - return os.MkdirAll(target, 0755) - } - - parentDir := filepath.Dir(target) - if err := os.MkdirAll(parentDir, 0755); err != nil { - return err - } - - klog.V(4).Infof("azureMount: mount options(%q) source:%q, target:%q, fstype:%q, begin to mount", - options, source, target, fstype) - bindSource := "" - - // tell it's going to mount azure disk or azure file according to options - if bind, _, _ := isBind(options); bind { - // mount azure disk - bindSource = normalizeWindowsPath(source) - } else { - if len(options) < 2 { - klog.Warningf("azureMount: mount options(%q) command number(%d) less than 2, source:%q, target:%q, skip mounting", - options, len(options), source, target) - return nil - } - - // currently only cifs mount is supported - if strings.ToLower(fstype) != "cifs" { - return fmt.Errorf("azureMount: only cifs mount is supported now, fstype: %q, mounting source (%q), target (%q), with options (%q)", fstype, source, target, options) - } - - bindSource = source - - // use PowerShell Environment Variables to store user input string to prevent command line injection - // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-5.1 - cmdLine := fmt.Sprintf(`$PWord = ConvertTo-SecureString -String $Env:smbpassword -AsPlainText -Force` + - `;$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Env:smbuser, $PWord` + - `;New-SmbGlobalMapping -RemotePath $Env:smbremotepath -Credential $Credential`) - - cmd := exec.Command("powershell", "/c", cmdLine) - cmd.Env = append(os.Environ(), - fmt.Sprintf("smbuser=%s", options[0]), - fmt.Sprintf("smbpassword=%s", options[1]), - fmt.Sprintf("smbremotepath=%s", source)) - if output, err := cmd.CombinedOutput(); err != nil { - return fmt.Errorf("azureMount: SmbGlobalMapping failed: %v, only SMB mount is supported now, output: %q", err, string(output)) - } - } - - if output, err := exec.Command("cmd", "/c", "mklink", "/D", target, bindSource).CombinedOutput(); err != nil { - klog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, bindSource, target, string(output)) - return err - } - - return nil -} - -// Unmount unmounts the target. -func (mounter *Mounter) Unmount(target string) error { - klog.V(4).Infof("azureMount: Unmount target (%q)", target) - target = normalizeWindowsPath(target) - if output, err := exec.Command("cmd", "/c", "rmdir", target).CombinedOutput(); err != nil { - klog.Errorf("rmdir failed: %v, output: %q", err, string(output)) - return err - } - return nil -} - -// List returns a list of all mounted filesystems. todo -func (mounter *Mounter) List() ([]MntPoint, error) { - return []MntPoint{}, nil -} - -// IsMountPointMatch determines if the mountpoint matches the dir -func (mounter *Mounter) IsMountPointMatch(mp MntPoint, dir string) bool { - return mp.Path == dir -} - -// IsNotMountPoint determines if a directory is a mountpoint. -func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) { - return IsNotMountPoint(mounter, dir) -} - -// IsLikelyNotMountPoint determines if a directory is not a mountpoint. -func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { - stat, err := os.Lstat(file) - if err != nil { - return true, err - } - // If current file is a symlink, then it is a mountpoint. - if stat.Mode()&os.ModeSymlink != 0 { - target, err := os.Readlink(file) - if err != nil { - return true, fmt.Errorf("readlink error: %v", err) - } - exists, err := mounter.ExistsPath(target) - if err != nil { - return true, err - } - return !exists, nil - } - - return true, nil -} - -// GetDeviceNameFromMount given a mnt point, find the device -func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) { - return getDeviceNameFromMount(mounter, mountPath, pluginDir) -} - -// getDeviceNameFromMount find the device(drive) name in which -// the mount path reference should match the given plugin directory. In case no mount path reference -// matches, returns the volume name taken from its given mountPath -func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) { - refs, err := mounter.GetMountRefs(mountPath) - if err != nil { - klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) - return "", err - } - if len(refs) == 0 { - return "", fmt.Errorf("directory %s is not mounted", mountPath) - } - basemountPath := normalizeWindowsPath(path.Join(pluginDir, MountsInGlobalPDPath)) - for _, ref := range refs { - if strings.Contains(ref, basemountPath) { - volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref) - if err != nil { - klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) - return "", err - } - return volumeID, nil - } - } - - return path.Base(mountPath), nil -} - -// DeviceOpened determines if the device is in use elsewhere -func (mounter *Mounter) DeviceOpened(pathname string) (bool, error) { - return false, nil -} - -// PathIsDevice determines if a path is a device. -func (mounter *Mounter) PathIsDevice(pathname string) (bool, error) { - return false, nil -} - -// MakeRShared checks that given path is on a mount with 'rshared' mount -// propagation. Empty implementation here. -func (mounter *Mounter) MakeRShared(path string) error { - return nil -} - -// GetFileType checks for sockets/block/character devices -func (mounter *Mounter) GetFileType(pathname string) (FileType, error) { - return getFileType(pathname) -} - -// MakeDir creates a new directory -func (mounter *Mounter) MakeDir(pathname string) error { - err := os.MkdirAll(pathname, os.FileMode(0755)) - if err != nil { - if !os.IsExist(err) { - return err - } - } - return nil -} - -// MakeFile creates an empty file -func (mounter *Mounter) MakeFile(pathname string) error { - f, err := os.OpenFile(pathname, os.O_CREATE, os.FileMode(0644)) - defer f.Close() - if err != nil { - if !os.IsExist(err) { - return err - } - } - return nil -} - -// ExistsPath checks whether the path exists -func (mounter *Mounter) ExistsPath(pathname string) (bool, error) { - return utilpath.Exists(utilpath.CheckFollowSymlink, pathname) -} - -// EvalHostSymlinks returns the path name after evaluating symlinks -func (mounter *Mounter) EvalHostSymlinks(pathname string) (string, error) { - return filepath.EvalSymlinks(pathname) -} - -// check whether hostPath is within volume path -// this func will lock all intermediate subpath directories, need to close handle outside of this func after container started -func lockAndCheckSubPath(volumePath, hostPath string) ([]uintptr, error) { - if len(volumePath) == 0 || len(hostPath) == 0 { - return []uintptr{}, nil - } - - finalSubPath, err := filepath.EvalSymlinks(hostPath) - if err != nil { - return []uintptr{}, fmt.Errorf("cannot read link %s: %s", hostPath, err) - } - finalVolumePath, err := filepath.EvalSymlinks(volumePath) - if err != nil { - return []uintptr{}, fmt.Errorf("cannot read link %s: %s", volumePath, err) - } - - return lockAndCheckSubPathWithoutSymlink(finalVolumePath, finalSubPath) -} - -// lock all intermediate subPath directories and check they are all within volumePath -// volumePath & subPath should not contain any symlink, otherwise it will return error -func lockAndCheckSubPathWithoutSymlink(volumePath, subPath string) ([]uintptr, error) { - if len(volumePath) == 0 || len(subPath) == 0 { - return []uintptr{}, nil - } - - // get relative path to volumePath - relSubPath, err := filepath.Rel(volumePath, subPath) - if err != nil { - return []uintptr{}, fmt.Errorf("Rel(%s, %s) error: %v", volumePath, subPath, err) - } - if startsWithBackstep(relSubPath) { - return []uintptr{}, fmt.Errorf("SubPath %q not within volume path %q", subPath, volumePath) - } - - if relSubPath == "." { - // volumePath and subPath are equal - return []uintptr{}, nil - } - - fileHandles := []uintptr{} - var errorResult error - - currentFullPath := volumePath - dirs := strings.Split(relSubPath, string(os.PathSeparator)) - for _, dir := range dirs { - // lock intermediate subPath directory first - currentFullPath = filepath.Join(currentFullPath, dir) - handle, err := lockPath(currentFullPath) - if err != nil { - errorResult = fmt.Errorf("cannot lock path %s: %s", currentFullPath, err) - break - } - fileHandles = append(fileHandles, handle) - - // make sure intermediate subPath directory does not contain symlink any more - stat, err := os.Lstat(currentFullPath) - if err != nil { - errorResult = fmt.Errorf("Lstat(%q) error: %v", currentFullPath, err) - break - } - if stat.Mode()&os.ModeSymlink != 0 { - errorResult = fmt.Errorf("subpath %q is an unexpected symlink after EvalSymlinks", currentFullPath) - break - } - - if !PathWithinBase(currentFullPath, volumePath) { - errorResult = fmt.Errorf("SubPath %q not within volume path %q", currentFullPath, volumePath) - break - } - } - - return fileHandles, errorResult -} - -// unlockPath unlock directories -func unlockPath(fileHandles []uintptr) { - if fileHandles != nil { - for _, handle := range fileHandles { - syscall.CloseHandle(syscall.Handle(handle)) - } - } -} - -// lockPath locks a directory or symlink, return handle, exec "syscall.CloseHandle(handle)" to unlock the path -func lockPath(path string) (uintptr, error) { - if len(path) == 0 { - return uintptr(syscall.InvalidHandle), syscall.ERROR_FILE_NOT_FOUND - } - pathp, err := syscall.UTF16PtrFromString(path) - if err != nil { - return uintptr(syscall.InvalidHandle), err - } - access := uint32(syscall.GENERIC_READ) - sharemode := uint32(syscall.FILE_SHARE_READ) - createmode := uint32(syscall.OPEN_EXISTING) - flags := uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS | syscall.FILE_FLAG_OPEN_REPARSE_POINT) - fd, err := syscall.CreateFile(pathp, access, sharemode, nil, createmode, flags, 0) - return uintptr(fd), err -} - -// PrepareSafeSubpath locks all directories in subPath and check they're not symlinks. -func (mounter *Mounter) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) { - handles, err := lockAndCheckSubPath(subPath.VolumePath, subPath.Path) - - // Unlock the directories when the container starts - cleanupAction = func() { - unlockPath(handles) - } - return subPath.Path, cleanupAction, err -} - -// CleanSubPaths no bind-mounts for subpaths are necessary on Windows -func (mounter *Mounter) CleanSubPaths(podDir string, volumeName string) error { - return nil -} - -func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, fstype string, options []string) error { - // Try to mount the disk - klog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, source, target) - - if err := ValidateDiskNumber(source); err != nil { - klog.Errorf("diskMount: formatAndMount failed, err: %v", err) - return err - } - - if len(fstype) == 0 { - // Use 'NTFS' as the default - fstype = "NTFS" - } - - // format disk if it is unformatted(raw) - cmd := fmt.Sprintf("Get-Disk -Number %s | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru"+ - " | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem %s -Confirm:$false", source, fstype) - if output, err := mounter.Exec.Run("powershell", "/c", cmd); err != nil { - return fmt.Errorf("diskMount: format disk failed, error: %v, output: %q", err, string(output)) - } - klog.V(4).Infof("diskMount: Disk successfully formatted, disk: %q, fstype: %q", source, fstype) - - driveLetter, err := getDriveLetterByDiskNumber(source, mounter.Exec) - if err != nil { - return err - } - driverPath := driveLetter + ":" - target = normalizeWindowsPath(target) - klog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, driverPath, target) - if output, err := mounter.Exec.Run("cmd", "/c", "mklink", "/D", target, driverPath); err != nil { - klog.Errorf("mklink failed: %v, output: %q", err, string(output)) - return err - } - return nil -} - -func normalizeWindowsPath(path string) string { - normalizedPath := strings.Replace(path, "/", "\\", -1) - if strings.HasPrefix(normalizedPath, "\\") { - normalizedPath = "c:" + normalizedPath - } - return normalizedPath -} - -// ValidateDiskNumber : disk number should be a number in [0, 99] -func ValidateDiskNumber(disk string) error { - diskNum, err := strconv.Atoi(disk) - if err != nil { - return fmt.Errorf("wrong disk number format: %q, err:%v", disk, err) - } - - if diskNum < 0 || diskNum > 99 { - return fmt.Errorf("disk number out of range: %q", disk) - } - - return nil -} - -// Get drive letter according to windows disk number -func getDriveLetterByDiskNumber(diskNum string, exec Exec) (string, error) { - cmd := fmt.Sprintf("(Get-Partition -DiskNumber %s).DriveLetter", diskNum) - output, err := exec.Run("powershell", "/c", cmd) - if err != nil { - return "", fmt.Errorf("azureMount: Get Drive Letter failed: %v, output: %q", err, string(output)) - } - if len(string(output)) < 1 { - return "", fmt.Errorf("azureMount: Get Drive Letter failed, output is empty") - } - return string(output)[:1], nil -} - -// getAllParentLinks walks all symbolic links and return all the parent targets recursively -func getAllParentLinks(path string) ([]string, error) { - const maxIter = 255 - links := []string{} - for { - links = append(links, path) - if len(links) > maxIter { - return links, fmt.Errorf("unexpected length of parent links: %v", links) - } - - fi, err := os.Lstat(path) - if err != nil { - return links, fmt.Errorf("Lstat: %v", err) - } - if fi.Mode()&os.ModeSymlink == 0 { - break - } - - path, err = os.Readlink(path) - if err != nil { - return links, fmt.Errorf("Readlink error: %v", err) - } - } - - return links, nil -} - -// GetMountRefs : empty implementation here since there is no place to query all mount points on Windows -func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) { - if _, err := os.Stat(normalizeWindowsPath(pathname)); os.IsNotExist(err) { - return []string{}, nil - } else if err != nil { - return nil, err - } - return []string{pathname}, nil -} - -// GetFSGroup always returns 0. We actually don't set FSGroup on -// windows platform, see SetVolumeOwnership implementation. -func (mounter *Mounter) GetFSGroup(pathname string) (int64, error) { - return 0, nil -} - -// GetSELinuxSupport returns false -func (mounter *Mounter) GetSELinuxSupport(pathname string) (bool, error) { - // Windows does not support SELinux. - return false, nil -} - -// GetMode returns the filesystem mode. -func (mounter *Mounter) GetMode(pathname string) (os.FileMode, error) { - info, err := os.Stat(pathname) - if err != nil { - return 0, err - } - return info.Mode(), nil -} - -// SafeMakeDir makes sure that the created directory does not escape given base directory mis-using symlinks. -func (mounter *Mounter) SafeMakeDir(subdir string, base string, perm os.FileMode) error { - realBase, err := filepath.EvalSymlinks(base) - if err != nil { - return fmt.Errorf("error resolving symlinks in %s: %s", base, err) - } - - realFullPath := filepath.Join(realBase, subdir) - return doSafeMakeDir(realFullPath, realBase, perm) -} - -func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { - klog.V(4).Infof("Creating directory %q within base %q", pathname, base) - - if !PathWithinBase(pathname, base) { - return fmt.Errorf("path %s is outside of allowed base %s", pathname, base) - } - - // Quick check if the directory already exists - s, err := os.Stat(pathname) - if err == nil { - // Path exists - if s.IsDir() { - // The directory already exists. It can be outside of the parent, - // but there is no race-proof check. - klog.V(4).Infof("Directory %s already exists", pathname) - return nil - } - return &os.PathError{Op: "mkdir", Path: pathname, Err: syscall.ENOTDIR} - } - - // Find all existing directories - existingPath, toCreate, err := findExistingPrefix(base, pathname) - if err != nil { - return fmt.Errorf("error opening directory %s: %s", pathname, err) - } - if len(toCreate) == 0 { - return nil - } - - // Ensure the existing directory is inside allowed base - fullExistingPath, err := filepath.EvalSymlinks(existingPath) - if err != nil { - return fmt.Errorf("error opening existing directory %s: %s", existingPath, err) - } - fullBasePath, err := filepath.EvalSymlinks(base) - if err != nil { - return fmt.Errorf("cannot read link %s: %s", base, err) - } - if !PathWithinBase(fullExistingPath, fullBasePath) { - return fmt.Errorf("path %s is outside of allowed base %s", fullExistingPath, err) - } - - // lock all intermediate directories from fullBasePath to fullExistingPath (top to bottom) - fileHandles, err := lockAndCheckSubPathWithoutSymlink(fullBasePath, fullExistingPath) - defer unlockPath(fileHandles) - if err != nil { - return err - } - - klog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) - currentPath := fullExistingPath - // create the directories one by one, making sure nobody can change - // created directory into symlink by lock that directory immediately - for _, dir := range toCreate { - currentPath = filepath.Join(currentPath, dir) - klog.V(4).Infof("Creating %s", dir) - if err := os.Mkdir(currentPath, perm); err != nil { - return fmt.Errorf("cannot create directory %s: %s", currentPath, err) - } - handle, err := lockPath(currentPath) - if err != nil { - return fmt.Errorf("cannot lock path %s: %s", currentPath, err) - } - defer syscall.CloseHandle(syscall.Handle(handle)) - // make sure newly created directory does not contain symlink after lock - stat, err := os.Lstat(currentPath) - if err != nil { - return fmt.Errorf("Lstat(%q) error: %v", currentPath, err) - } - if stat.Mode()&os.ModeSymlink != 0 { - return fmt.Errorf("subpath %q is an unexpected symlink after Mkdir", currentPath) - } - } - - return nil -} - -// findExistingPrefix finds prefix of pathname that exists. In addition, it -// returns list of remaining directories that don't exist yet. -func findExistingPrefix(base, pathname string) (string, []string, error) { - rel, err := filepath.Rel(base, pathname) - if err != nil { - return base, nil, err - } - - if startsWithBackstep(rel) { - return base, nil, fmt.Errorf("pathname(%s) is not within base(%s)", pathname, base) - } - - if rel == "." { - // base and pathname are equal - return pathname, []string{}, nil - } - - dirs := strings.Split(rel, string(filepath.Separator)) - - parent := base - currentPath := base - for i, dir := range dirs { - parent = currentPath - currentPath = filepath.Join(parent, dir) - if _, err := os.Lstat(currentPath); err != nil { - if os.IsNotExist(err) { - return parent, dirs[i:], nil - } - return base, nil, err - } - } - - return pathname, []string{}, nil -} diff --git a/staging/src/k8s.io/metrics/go.sum b/staging/src/k8s.io/metrics/go.sum index bd1a8fa29e4..d27d1b92029 100644 --- a/staging/src/k8s.io/metrics/go.sum +++ b/staging/src/k8s.io/metrics/go.sum @@ -219,8 +219,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/node-api/go.sum b/staging/src/k8s.io/node-api/go.sum index c18523feeef..4e673127d18 100644 --- a/staging/src/k8s.io/node-api/go.sum +++ b/staging/src/k8s.io/node-api/go.sum @@ -223,8 +223,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/sample-apiserver/go.sum b/staging/src/k8s.io/sample-apiserver/go.sum index 52040a5bebc..1a1e5d8b7cb 100644 --- a/staging/src/k8s.io/sample-apiserver/go.sum +++ b/staging/src/k8s.io/sample-apiserver/go.sum @@ -385,8 +385,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/staging/src/k8s.io/sample-cli-plugin/go.sum b/staging/src/k8s.io/sample-cli-plugin/go.sum index ca958845a22..50c14422d51 100644 --- a/staging/src/k8s.io/sample-cli-plugin/go.sum +++ b/staging/src/k8s.io/sample-cli-plugin/go.sum @@ -239,8 +239,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= diff --git a/staging/src/k8s.io/sample-controller/go.sum b/staging/src/k8s.io/sample-controller/go.sum index e93eaec773f..9e7dcf00f8c 100644 --- a/staging/src/k8s.io/sample-controller/go.sum +++ b/staging/src/k8s.io/sample-controller/go.sum @@ -224,8 +224,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= -k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/test/e2e/framework/.import-restrictions b/test/e2e/framework/.import-restrictions index 095fd44ae0b..a797fe9020e 100644 --- a/test/e2e/framework/.import-restrictions +++ b/test/e2e/framework/.import-restrictions @@ -92,7 +92,6 @@ "k8s.io/kubernetes/pkg/util/filesystem", "k8s.io/kubernetes/pkg/util/hash", "k8s.io/kubernetes/pkg/util/labels", - "k8s.io/kubernetes/pkg/util/mount", "k8s.io/kubernetes/pkg/util/node", "k8s.io/kubernetes/pkg/util/parsers", "k8s.io/kubernetes/pkg/util/resizefs", @@ -165,4 +164,3 @@ } ] } - diff --git a/test/e2e_node/BUILD b/test/e2e_node/BUILD index 8a3647533ea..c9429394e02 100644 --- a/test/e2e_node/BUILD +++ b/test/e2e_node/BUILD @@ -60,7 +60,6 @@ go_library( "//vendor/k8s.io/klog:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ - "//pkg/util/mount:go_default_library", "//pkg/util/procfs:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", @@ -78,9 +77,9 @@ go_library( "//vendor/github.com/google/cadvisor/client/v2:go_default_library", "//vendor/github.com/google/cadvisor/info/v2:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//pkg/util/mount:go_default_library", "//pkg/util/procfs:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", @@ -98,6 +97,7 @@ go_library( "//vendor/github.com/google/cadvisor/client/v2:go_default_library", "//vendor/github.com/google/cadvisor/info/v2:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ], "//conditions:default": [], }), @@ -166,7 +166,6 @@ go_test( "//pkg/kubelet/metrics:go_default_library", "//pkg/kubelet/types:go_default_library", "//pkg/security/apparmor:go_default_library", - "//pkg/util/mount:go_default_library", "//pkg/volume/util/fsquota:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/scheduling/v1:go_default_library", @@ -207,6 +206,7 @@ go_test( "//vendor/github.com/onsi/gomega/types:go_default_library", "//vendor/github.com/prometheus/common/model:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/mount:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ "//pkg/kubelet/stats/pidlimit:go_default_library", diff --git a/test/e2e_node/quota_lsci_test.go b/test/e2e_node/quota_lsci_test.go index 0b3121b5dbe..6b3640777ed 100644 --- a/test/e2e_node/quota_lsci_test.go +++ b/test/e2e_node/quota_lsci_test.go @@ -21,17 +21,17 @@ import ( "path/filepath" "time" + "github.com/onsi/ginkgo" + "k8s.io/utils/mount" + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/features" kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" - "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume/util/fsquota" "k8s.io/kubernetes/test/e2e/framework" imageutils "k8s.io/kubernetes/test/utils/image" - - "github.com/onsi/ginkgo" ) const ( diff --git a/test/e2e_node/util_xfs_linux.go b/test/e2e_node/util_xfs_linux.go index 5f758134a0b..560674ffa59 100644 --- a/test/e2e_node/util_xfs_linux.go +++ b/test/e2e_node/util_xfs_linux.go @@ -22,7 +22,7 @@ import ( "path/filepath" "syscall" - "k8s.io/kubernetes/pkg/util/mount" + "k8s.io/utils/mount" ) func detectMountpoint(m mount.Interface, path string) string { diff --git a/vendor/BUILD b/vendor/BUILD index 3279faf7462..4b42a7a3963 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -493,6 +493,7 @@ filegroup( "//vendor/k8s.io/utils/integer:all-srcs", "//vendor/k8s.io/utils/io:all-srcs", "//vendor/k8s.io/utils/keymutex:all-srcs", + "//vendor/k8s.io/utils/mount:all-srcs", "//vendor/k8s.io/utils/net:all-srcs", "//vendor/k8s.io/utils/nsenter:all-srcs", "//vendor/k8s.io/utils/path:all-srcs", diff --git a/pkg/util/mount/BUILD b/vendor/k8s.io/utils/mount/BUILD similarity index 74% rename from pkg/util/mount/BUILD rename to vendor/k8s.io/utils/mount/BUILD index a24ce6d68e0..bef3ec2cf55 100644 --- a/pkg/util/mount/BUILD +++ b/vendor/k8s.io/utils/mount/BUILD @@ -1,10 +1,9 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = [ "doc.go", - "fake_exec.go", "fake_mounter.go", "mount.go", "mount_helper_common.go", @@ -14,7 +13,8 @@ go_library( "mount_unsupported.go", "mount_windows.go", ], - importpath = "k8s.io/kubernetes/pkg/util/mount", + importmap = "k8s.io/kubernetes/vendor/k8s.io/utils/mount", + importpath = "k8s.io/utils/mount", visibility = ["//visibility:public"], deps = [ "//vendor/k8s.io/klog:go_default_library", @@ -61,29 +61,6 @@ go_library( }), ) -go_test( - name = "go_default_test", - srcs = [ - "mount_helper_test.go", - "mount_helper_unix_test.go", - "mount_helper_windows_test.go", - "mount_linux_test.go", - "mount_test.go", - "mount_windows_test.go", - "safe_format_and_mount_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//vendor/k8s.io/utils/exec:go_default_library", - "//vendor/k8s.io/utils/exec/testing:go_default_library", - ] + select({ - "@io_bazel_rules_go//go/platform:windows": [ - "//vendor/github.com/stretchr/testify/assert:go_default_library", - ], - "//conditions:default": [], - }), -) - filegroup( name = "package-srcs", srcs = glob(["**"]), diff --git a/pkg/util/mount/OWNERS b/vendor/k8s.io/utils/mount/OWNERS similarity index 100% rename from pkg/util/mount/OWNERS rename to vendor/k8s.io/utils/mount/OWNERS diff --git a/pkg/util/mount/doc.go b/vendor/k8s.io/utils/mount/doc.go similarity index 91% rename from pkg/util/mount/doc.go rename to vendor/k8s.io/utils/mount/doc.go index 15179e53f2d..c81b426ce8c 100644 --- a/pkg/util/mount/doc.go +++ b/vendor/k8s.io/utils/mount/doc.go @@ -15,4 +15,4 @@ limitations under the License. */ // Package mount defines an interface to mounting filesystems. -package mount // import "k8s.io/kubernetes/pkg/util/mount" +package mount // import "k8s.io/utils/mount" diff --git a/pkg/util/mount/fake_mounter.go b/vendor/k8s.io/utils/mount/fake_mounter.go similarity index 96% rename from pkg/util/mount/fake_mounter.go rename to vendor/k8s.io/utils/mount/fake_mounter.go index 315bba6941f..d3a82f415c2 100644 --- a/pkg/util/mount/fake_mounter.go +++ b/vendor/k8s.io/utils/mount/fake_mounter.go @@ -36,6 +36,7 @@ type FakeMounter struct { UnmountFunc UnmountFunc } +// UnmountFunc is a function callback to be executed during the Unmount() call. type UnmountFunc func(path string) error var _ Interface = &FakeMounter{} @@ -55,6 +56,8 @@ type FakeAction struct { FSType string // applies only to "mount" actions } +// NewFakeMounter returns a FakeMounter struct that implements Interface and is +// suitable for testing purposes. func NewFakeMounter(mps []MountPoint) *FakeMounter { return &FakeMounter{ MountPoints: mps, diff --git a/pkg/util/mount/mount.go b/vendor/k8s.io/utils/mount/mount.go similarity index 100% rename from pkg/util/mount/mount.go rename to vendor/k8s.io/utils/mount/mount.go diff --git a/pkg/util/mount/mount_helper_common.go b/vendor/k8s.io/utils/mount/mount_helper_common.go similarity index 100% rename from pkg/util/mount/mount_helper_common.go rename to vendor/k8s.io/utils/mount/mount_helper_common.go diff --git a/pkg/util/mount/mount_helper_unix.go b/vendor/k8s.io/utils/mount/mount_helper_unix.go similarity index 100% rename from pkg/util/mount/mount_helper_unix.go rename to vendor/k8s.io/utils/mount/mount_helper_unix.go diff --git a/pkg/util/mount/mount_helper_windows.go b/vendor/k8s.io/utils/mount/mount_helper_windows.go similarity index 93% rename from pkg/util/mount/mount_helper_windows.go rename to vendor/k8s.io/utils/mount/mount_helper_windows.go index 5e6b1dd9adc..516f970d282 100644 --- a/pkg/util/mount/mount_helper_windows.go +++ b/vendor/k8s.io/utils/mount/mount_helper_windows.go @@ -70,6 +70,9 @@ func IsCorruptedMnt(err error) bool { return false } +// NormalizeWindowsPath makes sure the given path is a valid path on Windows +// systems by making sure all instances of `/` are replaced with `\\`, and the +// path beings with `c:` func NormalizeWindowsPath(path string) string { normalizedPath := strings.Replace(path, "/", "\\", -1) if strings.HasPrefix(normalizedPath, "\\") { diff --git a/pkg/util/mount/mount_linux.go b/vendor/k8s.io/utils/mount/mount_linux.go similarity index 100% rename from pkg/util/mount/mount_linux.go rename to vendor/k8s.io/utils/mount/mount_linux.go diff --git a/pkg/util/mount/mount_unsupported.go b/vendor/k8s.io/utils/mount/mount_unsupported.go similarity index 100% rename from pkg/util/mount/mount_unsupported.go rename to vendor/k8s.io/utils/mount/mount_unsupported.go diff --git a/pkg/util/mount/mount_windows.go b/vendor/k8s.io/utils/mount/mount_windows.go similarity index 100% rename from pkg/util/mount/mount_windows.go rename to vendor/k8s.io/utils/mount/mount_windows.go diff --git a/vendor/modules.txt b/vendor/modules.txt index f08c58daefb..ed1d2e8ab0b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1836,7 +1836,6 @@ k8s.io/legacy-cloud-providers/azure k8s.io/legacy-cloud-providers/azure/auth k8s.io/legacy-cloud-providers/gce k8s.io/legacy-cloud-providers/openstack -k8s.io/legacy-cloud-providers/openstack/util/mount k8s.io/legacy-cloud-providers/vsphere k8s.io/legacy-cloud-providers/vsphere/testing k8s.io/legacy-cloud-providers/vsphere/vclib @@ -1891,7 +1890,7 @@ k8s.io/sample-apiserver/pkg/registry/wardle/fischer k8s.io/sample-apiserver/pkg/registry/wardle/flunder # k8s.io/system-validators v1.0.4 => k8s.io/system-validators v1.0.4 k8s.io/system-validators/validators -# k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d => k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d +# k8s.io/utils v0.0.0-20191114184206-e782cd3c129f => k8s.io/utils v0.0.0-20191114184206-e782cd3c129f k8s.io/utils/buffer k8s.io/utils/clock k8s.io/utils/exec @@ -1900,6 +1899,7 @@ k8s.io/utils/inotify k8s.io/utils/integer k8s.io/utils/io k8s.io/utils/keymutex +k8s.io/utils/mount k8s.io/utils/net k8s.io/utils/nsenter k8s.io/utils/path