Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7019fb88
Commit
7019fb88
authored
Mar 24, 2016
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23446 from vishh/hostpath-accounting
Do not track resource usage for host path volumes.
parents
eebfc1ef
9e5ddcb8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
55 deletions
+6
-55
host_path.go
pkg/volume/host_path/host_path.go
+6
-8
host_path_test.go
pkg/volume/host_path/host_path_test.go
+0
-47
No files found.
pkg/volume/host_path/host_path.go
View file @
7019fb88
...
@@ -97,13 +97,13 @@ func (plugin *hostPathPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volu
...
@@ -97,13 +97,13 @@ func (plugin *hostPathPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volu
if
spec
.
Volume
!=
nil
&&
spec
.
Volume
.
HostPath
!=
nil
{
if
spec
.
Volume
!=
nil
&&
spec
.
Volume
.
HostPath
!=
nil
{
path
:=
spec
.
Volume
.
HostPath
.
Path
path
:=
spec
.
Volume
.
HostPath
.
Path
return
&
hostPathBuilder
{
return
&
hostPathBuilder
{
hostPath
:
&
hostPath
{
path
:
path
,
MetricsProvider
:
volume
.
NewMetricsDu
(
path
)
},
hostPath
:
&
hostPath
{
path
:
path
},
readOnly
:
false
,
readOnly
:
false
,
},
nil
},
nil
}
else
{
}
else
{
path
:=
spec
.
PersistentVolume
.
Spec
.
HostPath
.
Path
path
:=
spec
.
PersistentVolume
.
Spec
.
HostPath
.
Path
return
&
hostPathBuilder
{
return
&
hostPathBuilder
{
hostPath
:
&
hostPath
{
path
:
path
,
MetricsProvider
:
volume
.
NewMetricsDu
(
path
)
},
hostPath
:
&
hostPath
{
path
:
path
},
readOnly
:
spec
.
ReadOnly
,
readOnly
:
spec
.
ReadOnly
,
},
nil
},
nil
}
}
...
@@ -112,7 +112,6 @@ func (plugin *hostPathPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volu
...
@@ -112,7 +112,6 @@ func (plugin *hostPathPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volu
func
(
plugin
*
hostPathPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
hostPathPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
return
&
hostPathCleaner
{
&
hostPath
{
return
&
hostPathCleaner
{
&
hostPath
{
path
:
""
,
path
:
""
,
MetricsProvider
:
volume
.
NewMetricsDu
(
""
),
}},
nil
}},
nil
}
}
...
@@ -142,7 +141,6 @@ func newRecycler(spec *volume.Spec, host volume.VolumeHost, config volume.Volume
...
@@ -142,7 +141,6 @@ func newRecycler(spec *volume.Spec, host volume.VolumeHost, config volume.Volume
host
:
host
,
host
:
host
,
config
:
config
,
config
:
config
,
timeout
:
volume
.
CalculateTimeoutForVolume
(
config
.
RecyclerMinimumTimeout
,
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
),
timeout
:
volume
.
CalculateTimeoutForVolume
(
config
.
RecyclerMinimumTimeout
,
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
),
MetricsProvider
:
volume
.
NewMetricsDu
(
path
),
},
nil
},
nil
}
}
...
@@ -151,7 +149,7 @@ func newDeleter(spec *volume.Spec, host volume.VolumeHost) (volume.Deleter, erro
...
@@ -151,7 +149,7 @@ func newDeleter(spec *volume.Spec, host volume.VolumeHost) (volume.Deleter, erro
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.HostPath is nil"
)
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.HostPath is nil"
)
}
}
path
:=
spec
.
PersistentVolume
.
Spec
.
HostPath
.
Path
path
:=
spec
.
PersistentVolume
.
Spec
.
HostPath
.
Path
return
&
hostPathDeleter
{
spec
.
Name
(),
path
,
host
,
volume
.
NewMetricsDu
(
path
)
},
nil
return
&
hostPathDeleter
{
name
:
spec
.
Name
(),
path
:
path
,
host
:
host
},
nil
}
}
func
newProvisioner
(
options
volume
.
VolumeOptions
,
host
volume
.
VolumeHost
)
(
volume
.
Provisioner
,
error
)
{
func
newProvisioner
(
options
volume
.
VolumeOptions
,
host
volume
.
VolumeHost
)
(
volume
.
Provisioner
,
error
)
{
...
@@ -162,7 +160,7 @@ func newProvisioner(options volume.VolumeOptions, host volume.VolumeHost) (volum
...
@@ -162,7 +160,7 @@ func newProvisioner(options volume.VolumeOptions, host volume.VolumeHost) (volum
// The direct at the specified path will be directly exposed to the container.
// The direct at the specified path will be directly exposed to the container.
type
hostPath
struct
{
type
hostPath
struct
{
path
string
path
string
volume
.
Metrics
Provider
volume
.
Metrics
Nil
}
}
func
(
hp
*
hostPath
)
GetPath
()
string
{
func
(
hp
*
hostPath
)
GetPath
()
string
{
...
@@ -222,7 +220,7 @@ type hostPathRecycler struct {
...
@@ -222,7 +220,7 @@ type hostPathRecycler struct {
host
volume
.
VolumeHost
host
volume
.
VolumeHost
config
volume
.
VolumeConfig
config
volume
.
VolumeConfig
timeout
int64
timeout
int64
volume
.
Metrics
Provider
volume
.
Metrics
Nil
}
}
func
(
r
*
hostPathRecycler
)
GetPath
()
string
{
func
(
r
*
hostPathRecycler
)
GetPath
()
string
{
...
@@ -291,7 +289,7 @@ type hostPathDeleter struct {
...
@@ -291,7 +289,7 @@ type hostPathDeleter struct {
name
string
name
string
path
string
path
string
host
volume
.
VolumeHost
host
volume
.
VolumeHost
volume
.
Metrics
Provider
volume
.
Metrics
Nil
}
}
func
(
r
*
hostPathDeleter
)
GetPath
()
string
{
func
(
r
*
hostPathDeleter
)
GetPath
()
string
{
...
...
pkg/volume/host_path/host_path_test.go
View file @
7019fb88
...
@@ -20,7 +20,6 @@ package host_path
...
@@ -20,7 +20,6 @@ package host_path
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"os"
"os"
"testing"
"testing"
...
@@ -272,49 +271,3 @@ func TestPersistentClaimReadOnlyFlag(t *testing.T) {
...
@@ -272,49 +271,3 @@ func TestPersistentClaimReadOnlyFlag(t *testing.T) {
t
.
Errorf
(
"Expected true for builder.IsReadOnly"
)
t
.
Errorf
(
"Expected true for builder.IsReadOnly"
)
}
}
}
}
// TestMetrics tests that MetricProvider methods return sane values.
func
TestMetrics
(
t
*
testing
.
T
)
{
// Create an empty temp directory for the volume
tmpDir
,
err
:=
ioutil
.
TempDir
(
os
.
TempDir
(),
"host_path_test"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Can't make a tmp dir: %v"
,
err
)
}
defer
os
.
RemoveAll
(
tmpDir
)
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
.
InitPlugins
(
ProbeVolumePlugins
(
volume
.
VolumeConfig
{}),
volumetest
.
NewFakeVolumeHost
(
tmpDir
,
nil
,
nil
))
plug
,
err
:=
plugMgr
.
FindPluginByName
(
"kubernetes.io/host-path"
)
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
tmpDir
}},
}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{})
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
expectedEmptyDirUsage
,
err
:=
volumetest
.
FindEmptyDirectoryUsageOnTmpfs
()
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error finding expected empty directory usage on tmpfs: %v"
,
err
)
}
metrics
,
err
:=
builder
.
GetMetrics
()
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error when calling GetMetrics %v"
,
err
)
}
if
e
,
a
:=
expectedEmptyDirUsage
.
Value
(),
metrics
.
Used
.
Value
();
e
!=
a
{
t
.
Errorf
(
"Unexpected value for empty directory; expected %v, got %v"
,
e
,
a
)
}
if
metrics
.
Capacity
.
Value
()
<=
0
{
t
.
Errorf
(
"Expected Capacity to be greater than 0"
)
}
if
metrics
.
Available
.
Value
()
<=
0
{
t
.
Errorf
(
"Expected Available to be greater than 0"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment