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
6777dc74
Commit
6777dc74
authored
Aug 15, 2018
by
Srini Brahmaroutu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide Flex volume metrics if the plugin supports.
parent
4414ae3d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
2 deletions
+23
-2
driver-call.go
pkg/volume/flexvolume/driver-call.go
+2
-0
mounter.go
pkg/volume/flexvolume/mounter.go
+0
-1
plugin.go
pkg/volume/flexvolume/plugin.go
+18
-0
unmounter.go
pkg/volume/flexvolume/unmounter.go
+0
-1
volume.go
pkg/volume/flexvolume/volume.go
+3
-0
No files found.
pkg/volume/flexvolume/driver-call.go
View file @
6777dc74
...
@@ -222,12 +222,14 @@ type DriverStatus struct {
...
@@ -222,12 +222,14 @@ type DriverStatus struct {
type
DriverCapabilities
struct
{
type
DriverCapabilities
struct
{
Attach
bool
`json:"attach"`
Attach
bool
`json:"attach"`
SELinuxRelabel
bool
`json:"selinuxRelabel"`
SELinuxRelabel
bool
`json:"selinuxRelabel"`
SupportsMetrics
bool
`json:"supportsMetrics"`
}
}
func
defaultCapabilities
()
*
DriverCapabilities
{
func
defaultCapabilities
()
*
DriverCapabilities
{
return
&
DriverCapabilities
{
return
&
DriverCapabilities
{
Attach
:
true
,
Attach
:
true
,
SELinuxRelabel
:
true
,
SELinuxRelabel
:
true
,
SupportsMetrics
:
false
,
}
}
}
}
...
...
pkg/volume/flexvolume/mounter.go
View file @
6777dc74
...
@@ -32,7 +32,6 @@ type flexVolumeMounter struct {
...
@@ -32,7 +32,6 @@ type flexVolumeMounter struct {
// the considered volume spec
// the considered volume spec
spec
*
volume
.
Spec
spec
*
volume
.
Spec
readOnly
bool
readOnly
bool
volume
.
MetricsNil
}
}
var
_
volume
.
Mounter
=
&
flexVolumeMounter
{}
var
_
volume
.
Mounter
=
&
flexVolumeMounter
{}
...
...
pkg/volume/flexvolume/plugin.go
View file @
6777dc74
...
@@ -177,6 +177,14 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
...
@@ -177,6 +177,14 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
return
nil
,
err
return
nil
,
err
}
}
var
metricsProvider
volume
.
MetricsProvider
if
plugin
.
capabilities
.
SupportsMetrics
{
metricsProvider
=
volume
.
NewMetricsStatFS
(
plugin
.
host
.
GetPodVolumeDir
(
pod
.
UID
,
utilstrings
.
EscapeQualifiedNameForDisk
(
sourceDriver
),
spec
.
Name
()))
}
else
{
metricsProvider
=
&
volume
.
MetricsNil
{}
}
return
&
flexVolumeMounter
{
return
&
flexVolumeMounter
{
flexVolume
:
&
flexVolume
{
flexVolume
:
&
flexVolume
{
driverName
:
sourceDriver
,
driverName
:
sourceDriver
,
...
@@ -188,6 +196,7 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
...
@@ -188,6 +196,7 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
podNamespace
:
pod
.
Namespace
,
podNamespace
:
pod
.
Namespace
,
podServiceAccountName
:
pod
.
Spec
.
ServiceAccountName
,
podServiceAccountName
:
pod
.
Spec
.
ServiceAccountName
,
volName
:
spec
.
Name
(),
volName
:
spec
.
Name
(),
MetricsProvider
:
metricsProvider
,
},
},
runner
:
runner
,
runner
:
runner
,
spec
:
spec
,
spec
:
spec
,
...
@@ -202,6 +211,14 @@ func (plugin *flexVolumePlugin) NewUnmounter(volName string, podUID types.UID) (
...
@@ -202,6 +211,14 @@ func (plugin *flexVolumePlugin) NewUnmounter(volName string, podUID types.UID) (
// newUnmounterInternal is the internal unmounter routine to clean the volume.
// newUnmounterInternal is the internal unmounter routine to clean the volume.
func
(
plugin
*
flexVolumePlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
,
runner
exec
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
func
(
plugin
*
flexVolumePlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
,
runner
exec
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
var
metricsProvider
volume
.
MetricsProvider
if
plugin
.
capabilities
.
SupportsMetrics
{
metricsProvider
=
volume
.
NewMetricsStatFS
(
plugin
.
host
.
GetPodVolumeDir
(
podUID
,
utilstrings
.
EscapeQualifiedNameForDisk
(
plugin
.
driverName
),
volName
))
}
else
{
metricsProvider
=
&
volume
.
MetricsNil
{}
}
return
&
flexVolumeUnmounter
{
return
&
flexVolumeUnmounter
{
flexVolume
:
&
flexVolume
{
flexVolume
:
&
flexVolume
{
driverName
:
plugin
.
driverName
,
driverName
:
plugin
.
driverName
,
...
@@ -210,6 +227,7 @@ func (plugin *flexVolumePlugin) newUnmounterInternal(volName string, podUID type
...
@@ -210,6 +227,7 @@ func (plugin *flexVolumePlugin) newUnmounterInternal(volName string, podUID type
plugin
:
plugin
,
plugin
:
plugin
,
podUID
:
podUID
,
podUID
:
podUID
,
volName
:
volName
,
volName
:
volName
,
MetricsProvider
:
metricsProvider
,
},
},
runner
:
runner
,
runner
:
runner
,
},
nil
},
nil
...
...
pkg/volume/flexvolume/unmounter.go
View file @
6777dc74
...
@@ -31,7 +31,6 @@ type flexVolumeUnmounter struct {
...
@@ -31,7 +31,6 @@ type flexVolumeUnmounter struct {
*
flexVolume
*
flexVolume
// Runner used to teardown the volume.
// Runner used to teardown the volume.
runner
exec
.
Interface
runner
exec
.
Interface
volume
.
MetricsNil
}
}
var
_
volume
.
Unmounter
=
&
flexVolumeUnmounter
{}
var
_
volume
.
Unmounter
=
&
flexVolumeUnmounter
{}
...
...
pkg/volume/flexvolume/volume.go
View file @
6777dc74
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
)
)
type
flexVolume
struct
{
type
flexVolume
struct
{
...
@@ -42,6 +43,8 @@ type flexVolume struct {
...
@@ -42,6 +43,8 @@ type flexVolume struct {
volName
string
volName
string
// the underlying plugin
// the underlying plugin
plugin
*
flexVolumePlugin
plugin
*
flexVolumePlugin
// the metric plugin
volume
.
MetricsProvider
}
}
// volume.Volume interface
// volume.Volume interface
...
...
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