Portworx driver changes dependent on updated vendor'ed code.
This commit is contained in:
parent
b59855d48a
commit
a967937ac5
@ -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 {
|
|||||||
// 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 {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
// 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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 {
|
|||||||
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) {
|
|||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user