-
Notifications
You must be signed in to change notification settings - Fork 21
Use type parameter to dispatch custom logic #135
Use type parameter to dispatch custom logic #135
Conversation
pkg/provisioner/core/provisioner.go
Outdated
|
||
fsType := getFsTypeWithDefault(storageClass.Parameters["fsType"]) | ||
|
||
provisioner, ok := p.storageClassProvisioners[fsType] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @garthy highlighted offline this breaks down when the following happens:
- You Provision a volume with a given fsType
- The volume provisioner is restarted
- Delete is called before a Provision with the same fsType
pkg/provisioner/core/provisioner.go
Outdated
return getFsTypeWithDefault(options.Parameters["fsType"]) | ||
} | ||
|
||
func getFsTypeWithDefault(fsType string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would fold this into resolveFSType()
and add a const along the lines of defaultFSType
rather than hardcoding the constant here.
@@ -48,7 +48,9 @@ func TestResolveFSTypeWhenNotConfigured(t *testing.T) { | |||
|
|||
func TestResolveFSTypeWhenConfigured(t *testing.T) { | |||
// test default fsType of 'ext3' is always returned when configured. | |||
options := controller.VolumeOptions{Parameters: map[string]string{fsType: "ext3"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is preferable IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was breaking for some reason on vsCode but worked out why and I will change back.
pkg/provisioner/core/provisioner.go
Outdated
@@ -109,16 +109,29 @@ func mapAvailabilityDomainToFailureDomain(AD string) string { | |||
return parts[len(parts)-1] | |||
} | |||
|
|||
func resolveFSType(options controller.VolumeOptions) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to deduplicate this (pkg/provisioner/block/block.go
)?
pkg/provisioner/core/provisioner.go
Outdated
provisioner, ok := p.storageClassProvisioners[volume.Spec.StorageClassName] | ||
storageClass, err := p.kubeClient.Storage().StorageClasses().Get(volume.Spec.StorageClassName, metav1.GetOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("Could not find storage class with the associated name '%s'", volume.Spec.StorageClassName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("could not find storage class %q", volume.Spec.StorageClassName)
pkg/provisioner/core/provisioner.go
Outdated
// Provision creates a storage asset and returns a PV object representing it. | ||
func (p *OCIProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) { | ||
availabilityDomainName, availabilityDomain, err := p.chooseAvailabilityDomain(options.PVC) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
provisioner, ok := p.storageClassProvisioners[*options.PVC.Spec.StorageClassName] | ||
fsType := resolveFSType(options) | ||
provisioner, ok := p.storageClassProvisioners[fsType] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not overly happy with the overloading of fsType here. For one thing, it means creating multiple copies of the block storage provisioner in p.storageClassProvisioners
unnecessarily. More importantly, it's not really what I'd expect as a user as throughout Kubernetes FSType
is used to denote the filesystem type rather than the storage backend:
// Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
// +optional
FSType string
I suggest we do something akin to what hyperkube does with symlinks in the flexvolume driver DaemonSet and then dispatch on provisioner
in the StorageClass (i.e. oracle/oci-block-storage
/ oracle/oci-filesystem-storage
).
@@ -87,8 +87,8 @@ func NewOCIProvisioner(kubeClient kubernetes.Interface, nodeInformer informersv1 | |||
nodeLister: nodeInformer.Lister(), | |||
nodeListerSynced: nodeInformer.Informer().HasSynced, | |||
storageClassProvisioners: map[string]plugin.ProvisionerPlugin{ | |||
"oci": blockProvisioner, | |||
"oci-ext3": blockProvisioner, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispatching here should be done on some additional parameter e.g. type: block, type: nfs. This allows us to support FSS and Block. The block provisioner gets the volume options passed in so it can lookup the fsType directly without it being passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this as an option yesterday. Personally I prefer the symlink approach but this to overloading fsType
also.
cf364ff
to
c392a06
Compare
c392a06
to
1fa59fa
Compare
1fa59fa
to
18ecaa5
Compare
* Add OCI proxy support
Resolves #131
Changelog