mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
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"
|
||||
)
|
||||
|
||||
const (
|
||||
attachContextKey = "context"
|
||||
attachHostKey = "host"
|
||||
)
|
||||
|
||||
// This is the primary entrypoint for volume plugins.
|
||||
func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
return []volume.VolumePlugin{&portworxVolumePlugin{nil, nil}}
|
||||
@ -205,7 +210,7 @@ type portworxManager interface {
|
||||
// Deletes a volume
|
||||
DeleteVolume(deleter *portworxVolumeDeleter) error
|
||||
// Attach a volume
|
||||
AttachVolume(mounter *portworxVolumeMounter) (string, error)
|
||||
AttachVolume(mounter *portworxVolumeMounter, attachOptions map[string]string) (string, error)
|
||||
// Detach a volume
|
||||
DetachVolume(unmounter *portworxVolumeUnmounter) error
|
||||
// Mount a volume
|
||||
@ -274,7 +279,10 @@ func (b *portworxVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ type fakePortworxManager struct {
|
||||
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
|
||||
return "", nil
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ const (
|
||||
pxdDriverName = "pxd"
|
||||
pvcClaimLabel = "pvc"
|
||||
pxServiceName = "portworx-service"
|
||||
pxDriverName = "pxd-sched"
|
||||
)
|
||||
|
||||
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.
|
||||
// We still need to call SpecFromOpts() here to handle cases where someone is running Portworx 1.2.8 and lower.
|
||||
specHandler := osdspec.NewSpecHandler()
|
||||
spec, _ := specHandler.SpecFromOpts(p.options.Parameters)
|
||||
spec, locator, source, _ := specHandler.SpecFromOpts(p.options.Parameters)
|
||||
if spec == nil {
|
||||
spec = specHandler.DefaultSpec()
|
||||
}
|
||||
|
||||
// Pass all parameters as volume labels for Portworx server-side processing.
|
||||
spec.VolumeLabels = p.options.Parameters
|
||||
|
||||
// Update the requested size in the spec
|
||||
spec.Size = uint64(requestGB * 1024 * 1024 * 1024)
|
||||
source := osdapi.Source{}
|
||||
locator := osdapi.VolumeLocator{
|
||||
Name: p.options.PVName,
|
||||
// Change the Portworx Volume name to PV name
|
||||
if locator == nil {
|
||||
locator = &osdapi.VolumeLocator{
|
||||
VolumeLabels: make(map[string]string),
|
||||
}
|
||||
}
|
||||
locator.Name = p.options.PVName
|
||||
|
||||
// Add claim Name as a part of Portworx Volume Labels
|
||||
locator.VolumeLabels = make(map[string]string)
|
||||
locator.VolumeLabels[pvcClaimLabel] = p.options.PVC.Name
|
||||
volumeID, err := driver.Create(&locator, &source, spec)
|
||||
volumeID, err := driver.Create(locator, source, spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Error creating Portworx Volume : %v", err)
|
||||
}
|
||||
@ -102,14 +106,14 @@ func (util *PortworxVolumeUtil) DeleteVolume(d *portworxVolumeDeleter) error {
|
||||
}
|
||||
|
||||
// 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*/)
|
||||
if err != nil || driver == nil {
|
||||
glog.Errorf("Failed to get portworx driver. Err: %v", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
devicePath, err := driver.Attach(m.volName)
|
||||
devicePath, err := driver.Attach(m.volName, attachOptions)
|
||||
if err != nil {
|
||||
glog.Errorf("Error attaching Portworx Volume (%v): %v", m.volName, err)
|
||||
return "", err
|
||||
@ -125,7 +129,7 @@ func (util *PortworxVolumeUtil) DetachVolume(u *portworxVolumeUnmounter) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = driver.Detach(u.volName)
|
||||
err = driver.Detach(u.volName, false /*doNotForceDetach*/)
|
||||
if err != nil {
|
||||
glog.Errorf("Error detaching Portworx Volume (%v): %v", u.volName, err)
|
||||
return err
|
||||
@ -181,7 +185,7 @@ func isClientValid(client *osdclient.Client) (bool, error) {
|
||||
|
||||
func createDriverClient(hostname string) (*osdclient.Client, error) {
|
||||
client, err := volumeclient.NewDriverClient("http://"+hostname+":"+osdMgmtPort,
|
||||
pxdDriverName, osdDriverVersion)
|
||||
pxdDriverName, osdDriverVersion, pxDriverName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user