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
a967937a
Commit
a967937a
authored
Sep 07, 2017
by
Aditya Dani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Portworx driver changes dependent on updated vendor'ed code.
parent
b59855d4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
portworx.go
pkg/volume/portworx/portworx.go
+10
-2
portworx_test.go
pkg/volume/portworx/portworx_test.go
+1
-1
portworx_util.go
pkg/volume/portworx/portworx_util.go
+15
-11
No files found.
pkg/volume/portworx/portworx.go
View file @
a967937a
...
@@ -31,6 +31,11 @@ import (
...
@@ -31,6 +31,11 @@ import (
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
)
const
(
attachContextKey
=
"context"
attachHostKey
=
"host"
)
// This is the primary entrypoint for volume plugins.
// This is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
portworxVolumePlugin
{
nil
,
nil
}}
return
[]
volume
.
VolumePlugin
{
&
portworxVolumePlugin
{
nil
,
nil
}}
...
@@ -205,7 +210,7 @@ type portworxManager interface {
...
@@ -205,7 +210,7 @@ type portworxManager interface {
// Deletes a volume
// Deletes a volume
DeleteVolume
(
deleter
*
portworxVolumeDeleter
)
error
DeleteVolume
(
deleter
*
portworxVolumeDeleter
)
error
// Attach a volume
// Attach a volume
AttachVolume
(
mounter
*
portworxVolumeMounter
)
(
string
,
error
)
AttachVolume
(
mounter
*
portworxVolumeMounter
,
attachOptions
map
[
string
]
string
)
(
string
,
error
)
// Detach a volume
// Detach a volume
DetachVolume
(
unmounter
*
portworxVolumeUnmounter
)
error
DetachVolume
(
unmounter
*
portworxVolumeUnmounter
)
error
// Mount a volume
// Mount a volume
...
@@ -274,7 +279,10 @@ func (b *portworxVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -274,7 +279,10 @@ func (b *portworxVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
nil
return
nil
}
}
if
_
,
err
:=
b
.
manager
.
AttachVolume
(
b
);
err
!=
nil
{
attachOptions
:=
make
(
map
[
string
]
string
)
attachOptions
[
attachContextKey
]
=
dir
attachOptions
[
attachHostKey
]
=
b
.
plugin
.
host
.
GetHostName
()
if
_
,
err
:=
b
.
manager
.
AttachVolume
(
b
,
attachOptions
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/portworx/portworx_test.go
View file @
a967937a
...
@@ -97,7 +97,7 @@ type fakePortworxManager struct {
...
@@ -97,7 +97,7 @@ type fakePortworxManager struct {
mountCalled
bool
mountCalled
bool
}
}
func
(
fake
*
fakePortworxManager
)
AttachVolume
(
b
*
portworxVolumeMounter
)
(
string
,
error
)
{
func
(
fake
*
fakePortworxManager
)
AttachVolume
(
b
*
portworxVolumeMounter
,
attachOptions
map
[
string
]
string
)
(
string
,
error
)
{
fake
.
attachCalled
=
true
fake
.
attachCalled
=
true
return
""
,
nil
return
""
,
nil
}
}
...
...
pkg/volume/portworx/portworx_util.go
View file @
a967937a
...
@@ -35,6 +35,7 @@ const (
...
@@ -35,6 +35,7 @@ const (
pxdDriverName
=
"pxd"
pxdDriverName
=
"pxd"
pvcClaimLabel
=
"pvc"
pvcClaimLabel
=
"pvc"
pxServiceName
=
"portworx-service"
pxServiceName
=
"portworx-service"
pxDriverName
=
"pxd-sched"
)
)
type
PortworxVolumeUtil
struct
{
type
PortworxVolumeUtil
struct
{
...
@@ -60,23 +61,26 @@ func (util *PortworxVolumeUtil) CreateVolume(p *portworxVolumeProvisioner) (stri
...
@@ -60,23 +61,26 @@ func (util *PortworxVolumeUtil) CreateVolume(p *portworxVolumeProvisioner) (stri
// doesn't support new parameters, the server-side processing will parse it correctly.
// doesn't support new parameters, the server-side processing will parse it correctly.
// We still need to call SpecFromOpts() here to handle cases where someone is running Portworx 1.2.8 and lower.
// We still need to call SpecFromOpts() here to handle cases where someone is running Portworx 1.2.8 and lower.
specHandler
:=
osdspec
.
NewSpecHandler
()
specHandler
:=
osdspec
.
NewSpecHandler
()
spec
,
_
:=
specHandler
.
SpecFromOpts
(
p
.
options
.
Parameters
)
spec
,
locator
,
source
,
_
:=
specHandler
.
SpecFromOpts
(
p
.
options
.
Parameters
)
if
spec
==
nil
{
if
spec
==
nil
{
spec
=
specHandler
.
DefaultSpec
()
spec
=
specHandler
.
DefaultSpec
()
}
}
// Pass all parameters as volume labels for Portworx server-side processing.
// Pass all parameters as volume labels for Portworx server-side processing.
spec
.
VolumeLabels
=
p
.
options
.
Parameters
spec
.
VolumeLabels
=
p
.
options
.
Parameters
// Update the requested size in the spec
spec
.
Size
=
uint64
(
requestGB
*
1024
*
1024
*
1024
)
spec
.
Size
=
uint64
(
requestGB
*
1024
*
1024
*
1024
)
source
:=
osdapi
.
Source
{}
// Change the Portworx Volume name to PV name
locator
:=
osdapi
.
VolumeLocator
{
if
locator
==
nil
{
Name
:
p
.
options
.
PVName
,
locator
=
&
osdapi
.
VolumeLocator
{
VolumeLabels
:
make
(
map
[
string
]
string
),
}
}
}
locator
.
Name
=
p
.
options
.
PVName
// Add claim Name as a part of Portworx Volume Labels
// Add claim Name as a part of Portworx Volume Labels
locator
.
VolumeLabels
=
make
(
map
[
string
]
string
)
locator
.
VolumeLabels
[
pvcClaimLabel
]
=
p
.
options
.
PVC
.
Name
locator
.
VolumeLabels
[
pvcClaimLabel
]
=
p
.
options
.
PVC
.
Name
volumeID
,
err
:=
driver
.
Create
(
&
locator
,
&
source
,
spec
)
volumeID
,
err
:=
driver
.
Create
(
locator
,
source
,
spec
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error creating Portworx Volume : %v"
,
err
)
glog
.
Errorf
(
"Error creating Portworx Volume : %v"
,
err
)
}
}
...
@@ -102,14 +106,14 @@ func (util *PortworxVolumeUtil) DeleteVolume(d *portworxVolumeDeleter) error {
...
@@ -102,14 +106,14 @@ func (util *PortworxVolumeUtil) DeleteVolume(d *portworxVolumeDeleter) error {
}
}
// AttachVolume attaches a Portworx Volume
// AttachVolume attaches a Portworx Volume
func
(
util
*
PortworxVolumeUtil
)
AttachVolume
(
m
*
portworxVolumeMounter
)
(
string
,
error
)
{
func
(
util
*
PortworxVolumeUtil
)
AttachVolume
(
m
*
portworxVolumeMounter
,
attachOptions
map
[
string
]
string
)
(
string
,
error
)
{
driver
,
err
:=
util
.
getPortworxDriver
(
m
.
plugin
.
host
,
true
/*localOnly*/
)
driver
,
err
:=
util
.
getPortworxDriver
(
m
.
plugin
.
host
,
true
/*localOnly*/
)
if
err
!=
nil
||
driver
==
nil
{
if
err
!=
nil
||
driver
==
nil
{
glog
.
Errorf
(
"Failed to get portworx driver. Err: %v"
,
err
)
glog
.
Errorf
(
"Failed to get portworx driver. Err: %v"
,
err
)
return
""
,
err
return
""
,
err
}
}
devicePath
,
err
:=
driver
.
Attach
(
m
.
volName
)
devicePath
,
err
:=
driver
.
Attach
(
m
.
volName
,
attachOptions
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error attaching Portworx Volume (%v): %v"
,
m
.
volName
,
err
)
glog
.
Errorf
(
"Error attaching Portworx Volume (%v): %v"
,
m
.
volName
,
err
)
return
""
,
err
return
""
,
err
...
@@ -125,7 +129,7 @@ func (util *PortworxVolumeUtil) DetachVolume(u *portworxVolumeUnmounter) error {
...
@@ -125,7 +129,7 @@ func (util *PortworxVolumeUtil) DetachVolume(u *portworxVolumeUnmounter) error {
return
err
return
err
}
}
err
=
driver
.
Detach
(
u
.
volName
)
err
=
driver
.
Detach
(
u
.
volName
,
false
/*doNotForceDetach*/
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error detaching Portworx Volume (%v): %v"
,
u
.
volName
,
err
)
glog
.
Errorf
(
"Error detaching Portworx Volume (%v): %v"
,
u
.
volName
,
err
)
return
err
return
err
...
@@ -181,7 +185,7 @@ func isClientValid(client *osdclient.Client) (bool, error) {
...
@@ -181,7 +185,7 @@ func isClientValid(client *osdclient.Client) (bool, error) {
func
createDriverClient
(
hostname
string
)
(
*
osdclient
.
Client
,
error
)
{
func
createDriverClient
(
hostname
string
)
(
*
osdclient
.
Client
,
error
)
{
client
,
err
:=
volumeclient
.
NewDriverClient
(
"http://"
+
hostname
+
":"
+
osdMgmtPort
,
client
,
err
:=
volumeclient
.
NewDriverClient
(
"http://"
+
hostname
+
":"
+
osdMgmtPort
,
pxdDriverName
,
osdDriverVersion
)
pxdDriverName
,
osdDriverVersion
,
pxDriverName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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