diff --git a/pkg/controller/.import-restrictions b/pkg/controller/.import-restrictions index db246c010a..11cfe737a3 100644 --- a/pkg/controller/.import-restrictions +++ b/pkg/controller/.import-restrictions @@ -321,8 +321,7 @@ "k8s.io/kubernetes/pkg/util/resizefs", "k8s.io/kubernetes/pkg/util/version", "k8s.io/kubernetes/pkg/apis/apps", - "k8s.io/kubernetes/pkg/version", - "k8s.io/kubernetes/pkg/util/io" + "k8s.io/kubernetes/pkg/version" ] }, { @@ -343,6 +342,8 @@ "k8s.io/metrics/pkg/client/custom_metrics/fake", "k8s.io/metrics/pkg/client/external_metrics", "k8s.io/metrics/pkg/client/external_metrics/fake", + "k8s.io/utils/nsenter", + "k8s.io/utils/io", "k8s.io/utils/pointer", "k8s.io/utils/exec" ] diff --git a/pkg/kubectl/.import-restrictions b/pkg/kubectl/.import-restrictions index 72be55c189..ea5dcc52d3 100644 --- a/pkg/kubectl/.import-restrictions +++ b/pkg/kubectl/.import-restrictions @@ -131,7 +131,6 @@ "k8s.io/kubernetes/pkg/util/goroutinemap", "k8s.io/kubernetes/pkg/util/hash", "k8s.io/kubernetes/pkg/util/interrupt", - "k8s.io/kubernetes/pkg/util/io", "k8s.io/kubernetes/pkg/util/labels", "k8s.io/kubernetes/pkg/util/metrics", "k8s.io/kubernetes/pkg/util/mount", @@ -145,6 +144,8 @@ "k8s.io/kubernetes/pkg/version/prometheus", "k8s.io/kubernetes/pkg/volume", "k8s.io/kubernetes/pkg/volume/util", + "k8s.io/utils/nsenter", + "k8s.io/utils/io", "k8s.io/utils/pointer" ], "ForbiddenPrefixes": [] diff --git a/pkg/util/BUILD b/pkg/util/BUILD index e46513b965..335e605f07 100644 --- a/pkg/util/BUILD +++ b/pkg/util/BUILD @@ -28,7 +28,6 @@ filegroup( "//pkg/util/hash:all-srcs", "//pkg/util/initsystem:all-srcs", "//pkg/util/interrupt:all-srcs", - "//pkg/util/io:all-srcs", "//pkg/util/ipconfig:all-srcs", "//pkg/util/ipset:all-srcs", "//pkg/util/iptables:all-srcs", diff --git a/pkg/util/io/BUILD b/pkg/util/io/BUILD deleted file mode 100644 index 92e8f2ae78..0000000000 --- a/pkg/util/io/BUILD +++ /dev/null @@ -1,25 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", -) - -go_library( - name = "go_default_library", - srcs = ["consistentread.go"], - importpath = "k8s.io/kubernetes/pkg/util/io", -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/pkg/util/io/consistentread.go b/pkg/util/io/consistentread.go deleted file mode 100644 index 6e1f17b098..0000000000 --- a/pkg/util/io/consistentread.go +++ /dev/null @@ -1,45 +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 io - -import ( - "bytes" - "fmt" - "io/ioutil" -) - -// ConsistentRead repeatedly reads a file until it gets the same content twice. -// This is useful when reading files in /proc that are larger than page size -// and kernel may modify them between individual read() syscalls. -func ConsistentRead(filename string, attempts int) ([]byte, error) { - oldContent, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - for i := 0; i < attempts; i++ { - newContent, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - if bytes.Compare(oldContent, newContent) == 0 { - return newContent, nil - } - // Files are different, continue reading - oldContent = newContent - } - return nil, fmt.Errorf("could not get consistent content of %s after %d attempts", filename, attempts) -} diff --git a/pkg/util/mount/BUILD b/pkg/util/mount/BUILD index c9b9ce8a47..5e77382eec 100644 --- a/pkg/util/mount/BUILD +++ b/pkg/util/mount/BUILD @@ -36,10 +36,10 @@ go_library( ], "@io_bazel_rules_go//go/platform:linux": [ "//pkg/util/file:go_default_library", - "//pkg/util/io:go_default_library", "//pkg/util/nsenter:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/golang.org/x/sys/unix:go_default_library", + "//vendor/k8s.io/utils/io:go_default_library", ], "@io_bazel_rules_go//go/platform:nacl": [ "//pkg/util/nsenter:go_default_library", diff --git a/pkg/util/mount/mount_linux.go b/pkg/util/mount/mount_linux.go index 8e7604a22c..b0ef01bae4 100644 --- a/pkg/util/mount/mount_linux.go +++ b/pkg/util/mount/mount_linux.go @@ -34,8 +34,8 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog" utilfile "k8s.io/kubernetes/pkg/util/file" - utilio "k8s.io/kubernetes/pkg/util/io" utilexec "k8s.io/utils/exec" + utilio "k8s.io/utils/io" ) const (