Skip to content

Commit 7d40536

Browse files
authored
Merge pull request kubernetes#82024 from codenrhoden/mv-hostutil
Move HostUtil to pkg/volume/util/hostutil
2 parents f4887d6 + 935c23f commit 7d40536

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+496
-364
lines changed

cmd/kubelet/app/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ go_library(
107107
"//pkg/volume/scaleio:go_default_library",
108108
"//pkg/volume/secret:go_default_library",
109109
"//pkg/volume/storageos:go_default_library",
110+
"//pkg/volume/util/hostutil:go_default_library",
110111
"//pkg/volume/util/subpath:go_default_library",
111112
"//pkg/volume/vsphere_volume:go_default_library",
112113
"//staging/src/k8s.io/api/core/v1:go_default_library",

cmd/kubelet/app/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import (
9797
"k8s.io/kubernetes/pkg/util/rlimit"
9898
"k8s.io/kubernetes/pkg/version"
9999
"k8s.io/kubernetes/pkg/version/verflag"
100+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
100101
"k8s.io/kubernetes/pkg/volume/util/subpath"
101102
"k8s.io/utils/exec"
102103
)
@@ -369,7 +370,7 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
369370

370371
mounter := mount.New(s.ExperimentalMounterPath)
371372
subpather := subpath.New(mounter)
372-
hu := mount.NewHostUtil()
373+
hu := hostutil.NewHostUtil()
373374
var pluginRunner = exec.New()
374375

375376
var dockerClientConfig *dockershim.ClientConfig

pkg/kubelet/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ go_library(
112112
"//pkg/volume/csi:go_default_library",
113113
"//pkg/volume/util:go_default_library",
114114
"//pkg/volume/util/exec:go_default_library",
115+
"//pkg/volume/util/hostutil:go_default_library",
115116
"//pkg/volume/util/subpath:go_default_library",
116117
"//pkg/volume/util/types:go_default_library",
117118
"//pkg/volume/util/volumepathhandler:go_default_library",
@@ -220,6 +221,7 @@ go_test(
220221
"//pkg/volume/hostpath:go_default_library",
221222
"//pkg/volume/testing:go_default_library",
222223
"//pkg/volume/util:go_default_library",
224+
"//pkg/volume/util/hostutil:go_default_library",
223225
"//pkg/volume/util/subpath:go_default_library",
224226
"//staging/src/k8s.io/api/core/v1:go_default_library",
225227
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",

pkg/kubelet/kubelet.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ import (
117117
"k8s.io/kubernetes/pkg/util/selinux"
118118
"k8s.io/kubernetes/pkg/volume"
119119
"k8s.io/kubernetes/pkg/volume/csi"
120+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
120121
"k8s.io/kubernetes/pkg/volume/util/subpath"
121122
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
122123
utilexec "k8s.io/utils/exec"
@@ -254,7 +255,7 @@ type Dependencies struct {
254255
OnHeartbeatFailure func()
255256
KubeClient clientset.Interface
256257
Mounter mount.Interface
257-
HostUtil mount.HostUtils
258+
HostUtil hostutil.HostUtils
258259
OOMAdjuster *oom.OOMAdjuster
259260
OSInterface kubecontainer.OSInterface
260261
PodConfig *config.PodConfig
@@ -1105,7 +1106,7 @@ type Kubelet struct {
11051106
mounter mount.Interface
11061107

11071108
// hostutil to interact with filesystems
1108-
hostutil mount.HostUtils
1109+
hostutil hostutil.HostUtils
11091110

11101111
// subpather to execute subpath actions
11111112
subpather subpath.Interface

pkg/kubelet/kubelet_pods.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ import (
5959
"k8s.io/kubernetes/pkg/kubelet/status"
6060
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
6161
"k8s.io/kubernetes/pkg/kubelet/util/format"
62-
mountutil "k8s.io/kubernetes/pkg/util/mount"
6362
volumeutil "k8s.io/kubernetes/pkg/volume/util"
63+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
6464
"k8s.io/kubernetes/pkg/volume/util/subpath"
6565
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
6666
volumevalidation "k8s.io/kubernetes/pkg/volume/validation"
@@ -128,7 +128,7 @@ func (kl *Kubelet) makeBlockVolumes(pod *v1.Pod, container *v1.Container, podVol
128128
}
129129

130130
// makeMounts determines the mount points for the given container.
131-
func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, hostDomain, podIP string, podVolumes kubecontainer.VolumeMap, hu mountutil.HostUtils, subpather subpath.Interface, expandEnvs []kubecontainer.EnvVar) ([]kubecontainer.Mount, func(), error) {
131+
func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, hostDomain, podIP string, podVolumes kubecontainer.VolumeMap, hu hostutil.HostUtils, subpather subpath.Interface, expandEnvs []kubecontainer.EnvVar) ([]kubecontainer.Mount, func(), error) {
132132
// Kubernetes only mounts on /etc/hosts if:
133133
// - container is not an infrastructure (pause) container
134134
// - container is not already mounting on /etc/hosts

pkg/kubelet/kubelet_pods_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
"testing"
2323

2424
"github.com/stretchr/testify/assert"
25-
"k8s.io/api/core/v1"
25+
v1 "k8s.io/api/core/v1"
2626

2727
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
2828
_ "k8s.io/kubernetes/pkg/apis/core/install"
2929
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
30-
"k8s.io/kubernetes/pkg/util/mount"
3130
volumetest "k8s.io/kubernetes/pkg/volume/testing"
31+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
3232
"k8s.io/kubernetes/pkg/volume/util/subpath"
3333
)
3434

@@ -241,7 +241,7 @@ func TestMakeMounts(t *testing.T) {
241241

242242
for name, tc := range testCases {
243243
t.Run(name, func(t *testing.T) {
244-
fhu := &mount.FakeHostUtil{}
244+
fhu := hostutil.NewFakeHostUtil(nil)
245245
fsp := &subpath.FakeSubpath{}
246246
pod := v1.Pod{
247247
Spec: v1.PodSpec{

pkg/kubelet/kubelet_pods_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
"github.com/stretchr/testify/assert"
2929
"github.com/stretchr/testify/require"
30-
"k8s.io/api/core/v1"
30+
v1 "k8s.io/api/core/v1"
3131
apierrors "k8s.io/apimachinery/pkg/api/errors"
3232
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3333
"k8s.io/apimachinery/pkg/labels"
@@ -48,12 +48,12 @@ import (
4848
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
4949
"k8s.io/kubernetes/pkg/kubelet/server/portforward"
5050
"k8s.io/kubernetes/pkg/kubelet/server/remotecommand"
51-
"k8s.io/kubernetes/pkg/util/mount"
51+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
5252
"k8s.io/kubernetes/pkg/volume/util/subpath"
5353
)
5454

5555
func TestDisabledSubpath(t *testing.T) {
56-
fhu := &mount.FakeHostUtil{}
56+
fhu := hostutil.NewFakeHostUtil(nil)
5757
fsp := &subpath.FakeSubpath{}
5858
pod := v1.Pod{
5959
Spec: v1.PodSpec{

pkg/kubelet/kubelet_pods_windows_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"testing"
2121

2222
"github.com/stretchr/testify/assert"
23-
"k8s.io/api/core/v1"
23+
v1 "k8s.io/api/core/v1"
2424
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
25-
"k8s.io/kubernetes/pkg/util/mount"
25+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
2626
"k8s.io/kubernetes/pkg/volume/util/subpath"
2727
)
2828

@@ -82,7 +82,7 @@ func TestMakeMountsWindows(t *testing.T) {
8282
},
8383
}
8484

85-
fhu := &mount.FakeHostUtil{}
85+
fhu := hostutil.NewFakeHostUtil(nil)
8686
fsp := &subpath.FakeSubpath{}
8787
mounts, _, _ := makeMounts(&pod, "/pod", &container, "fakepodname", "", "", podVolumes, fhu, fsp, nil)
8888

pkg/kubelet/kubelet_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import (
7676
_ "k8s.io/kubernetes/pkg/volume/hostpath"
7777
volumetest "k8s.io/kubernetes/pkg/volume/testing"
7878
"k8s.io/kubernetes/pkg/volume/util"
79+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
7980
"k8s.io/kubernetes/pkg/volume/util/subpath"
8081
)
8182

@@ -162,7 +163,7 @@ func newTestKubeletWithImageList(
162163
kubelet.heartbeatClient = fakeKubeClient
163164
kubelet.os = &containertest.FakeOS{}
164165
kubelet.mounter = &mount.FakeMounter{}
165-
kubelet.hostutil = &mount.FakeHostUtil{}
166+
kubelet.hostutil = hostutil.NewFakeHostUtil(nil)
166167
kubelet.subpather = &subpath.FakeSubpath{}
167168

168169
kubelet.hostname = testKubeletHostname

pkg/kubelet/runonce_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"k8s.io/kubernetes/pkg/util/mount"
4747
"k8s.io/kubernetes/pkg/volume"
4848
volumetest "k8s.io/kubernetes/pkg/volume/testing"
49+
"k8s.io/kubernetes/pkg/volume/util/hostutil"
4950
)
5051

5152
func TestRunOnce(t *testing.T) {
@@ -85,7 +86,7 @@ func TestRunOnce(t *testing.T) {
8586
hostname: testKubeletHostname,
8687
nodeName: testKubeletHostname,
8788
runtimeState: newRuntimeState(time.Second),
88-
hostutil: &mount.FakeHostUtil{},
89+
hostutil: hostutil.NewFakeHostUtil(nil),
8990
}
9091
kb.containerManager = cm.NewStubContainerManager()
9192

0 commit comments

Comments
 (0)