diff --git a/README.md b/README.md index 5da0f8a9188e..35a549ba50d3 100644 --- a/README.md +++ b/README.md @@ -81,39 +81,39 @@ for its support details. | Plugin | Features | Feature Status | CSI Driver Version | CSI Spec Version | Ceph Cluster Version | Kubernetes Version | | ------ | --------------------------------------------------------- | -------------- | ------------------ | ---------------- | -------------------- | ------------------ | -| RBD | Dynamically provision, de-provision Block mode RWO volume | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision Block mode RWX volume | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision Block mode RWOP volume| Alpha | >= v3.5.0 | >= v1.5.0 | Octopus (>=15.0.0) | >= v1.22.0 | -| | Dynamically provision, de-provision File mode RWO volume | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.5.0 | >= v1.5.0 | Octopus (>=15.0.0) | >= v1.22.0 | -| | Provision File Mode ROX volume from snapshot | Alpha | >= v3.0.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.17.0 | -| | Provision File Mode ROX volume from another volume | Alpha | >= v3.0.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.16.0 | -| | Provision Block Mode ROX volume from snapshot | Alpha | >= v3.0.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.17.0 | -| | Provision Block Mode ROX volume from another volume | Alpha | >= v3.0.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.16.0 | -| | Creating and deleting snapshot | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.17.0 | -| | Provision volume from snapshot | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.17.0 | -| | Provision volume from another volume | GA | >= v1.0.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.16.0 | -| | Expand volume | Beta | >= v2.0.0 | >= v1.1.0 | Octopus (>=15.0.0) | >= v1.15.0 | -| | Volume/PV Metrics of File Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Octopus (>=15.0.0) | >= v1.15.0 | -| | Volume/PV Metrics of Block Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Octopus (>=15.0.0) | >= v1.21.0 | -| | Topology Aware Provisioning Support | Alpha | >= v2.1.0 | >= v1.1.0 | Octopus (>=15.0.0) | >= v1.14.0 | -| CephFS | Dynamically provision, de-provision File mode RWO volume | GA | >= v1.1.0 | >= v1.0.0 | Octopus (>=15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode RWX volume | GA | >= v1.1.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode ROX volume | Alpha | >= v3.0.0 | >= v1.0.0 | Octopus (>=v15.0.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.5.0 | >= v1.5.0 | Octopus (>=15.0.0) | >= v1.22.0 | -| | Creating and deleting snapshot | GA | >= v3.1.0 | >= v1.0.0 | Octopus (>=v15.2.4) | >= v1.17.0 | -| | Provision volume from snapshot | GA | >= v3.1.0 | >= v1.0.0 | Octopus (>=v15.2.4) | >= v1.17.0 | -| | Provision volume from another volume | GA | >= v3.1.0 | >= v1.0.0 | Octopus (>=v15.2.4) | >= v1.16.0 | -| | Expand volume | Beta | >= v2.0.0 | >= v1.1.0 | Octopus (>=v15.0.0) | >= v1.15.0 | -| | Volume/PV Metrics of File Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Octopus (>=v15.0.0) | >= v1.15.0 | -| NFS | Dynamically provision, de-provision File mode RWO volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=16.2.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode RWX volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=16.2.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode ROX volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=16.2.0) | >= v1.14.0 | -| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.6.0 | >= v1.5.0 | Pacific (>=16.2.0) | >= v1.22.0 | -| | Expand volume | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=16.2.0) | >= v1.15.0 | -| | Creating and deleting snapshot | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=16.2.0) | >= v1.17.0 | -| | Provision volume from snapshot | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=16.2.0) | >= v1.17.0 | -| | Provision volume from another volume | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=16.2.0) | >= v1.16.0 | +| RBD | Dynamically provision, de-provision Block mode RWO volume | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision Block mode RWX volume | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision Block mode RWOP volume| Alpha | >= v3.5.0 | >= v1.5.0 | Pacific (>=v16.0.0) | >= v1.22.0 | +| | Dynamically provision, de-provision File mode RWO volume | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.5.0 | >= v1.5.0 | Pacific (>=v16.0.0) | >= v1.22.0 | +| | Provision File Mode ROX volume from snapshot | Alpha | >= v3.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision File Mode ROX volume from another volume | Alpha | >= v3.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.16.0 | +| | Provision Block Mode ROX volume from snapshot | Alpha | >= v3.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision Block Mode ROX volume from another volume | Alpha | >= v3.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.16.0 | +| | Creating and deleting snapshot | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision volume from snapshot | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision volume from another volume | GA | >= v1.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.16.0 | +| | Expand volume | Beta | >= v2.0.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.15.0 | +| | Volume/PV Metrics of File Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.15.0 | +| | Volume/PV Metrics of Block Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.21.0 | +| | Topology Aware Provisioning Support | Alpha | >= v2.1.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| CephFS | Dynamically provision, de-provision File mode RWO volume | GA | >= v1.1.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode RWX volume | GA | >= v1.1.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode ROX volume | Alpha | >= v3.0.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.5.0 | >= v1.5.0 | Pacific (>=v16.0.0) | >= v1.22.0 | +| | Creating and deleting snapshot | GA | >= v3.1.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision volume from snapshot | GA | >= v3.1.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.17.0 | +| | Provision volume from another volume | GA | >= v3.1.0 | >= v1.0.0 | Pacific (>=v16.0.0) | >= v1.16.0 | +| | Expand volume | Beta | >= v2.0.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.15.0 | +| | Volume/PV Metrics of File Mode Volume | GA | >= v1.2.0 | >= v1.1.0 | Pacific (>=v16.0.0) | >= v1.15.0 | +| NFS | Dynamically provision, de-provision File mode RWO volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=v16.2.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode RWX volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=v16.2.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode ROX volume | Alpha | >= v3.6.0 | >= v1.0.0 | Pacific (>=v16.2.0) | >= v1.14.0 | +| | Dynamically provision, de-provision File mode RWOP volume | Alpha | >= v3.6.0 | >= v1.5.0 | Pacific (>=v16.2.0) | >= v1.22.0 | +| | Expand volume | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=v16.2.0) | >= v1.15.0 | +| | Creating and deleting snapshot | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=v16.2.0) | >= v1.17.0 | +| | Provision volume from snapshot | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=v16.2.0) | >= v1.17.0 | +| | Provision volume from another volume | Alpha | >= v3.7.0 | >= v1.1.0 | Pacific (>=v16.2.0) | >= v1.16.0 | `NOTE`: The `Alpha` status reflects possible non-backward compatible changes in the future, and is thus not recommended diff --git a/internal/cephfs/core/metadata.go b/internal/cephfs/core/metadata.go index 9e2b90d5f468..e834b4f13350 100644 --- a/internal/cephfs/core/metadata.go +++ b/internal/cephfs/core/metadata.go @@ -17,11 +17,8 @@ limitations under the License. package core import ( - "errors" "fmt" "strings" - - fsAdmin "github.com/ceph/go-ceph/cephfs/admin" ) const ( @@ -29,43 +26,15 @@ const ( clusterNameKey = "csi.ceph.com/cluster/name" ) -// ErrSubVolMetadataNotSupported is returned when set/get/list/remove subvolume metadata options are not supported. -var ErrSubVolMetadataNotSupported = errors.New("subvolume metadata operations are not supported") - -func (s *subVolumeClient) supportsSubVolMetadata() bool { - newLocalClusterState(s.clusterID) - - return clusterAdditionalInfo[s.clusterID].subVolMetadataState != unsupported -} - -func (s *subVolumeClient) isUnsupportedSubVolMetadata(err error) bool { - var invalid fsAdmin.NotImplementedError - if err != nil && errors.As(err, &invalid) { - // In case the error is other than invalid command return error to the caller. - clusterAdditionalInfo[s.clusterID].subVolMetadataState = unsupported - - return false - } - clusterAdditionalInfo[s.clusterID].subVolMetadataState = supported - - return true -} - // setMetadata sets custom metadata on the subvolume in a volume as a // key-value pair. func (s *subVolumeClient) setMetadata(key, value string) error { var err error - if !s.supportsSubVolMetadata() { - return ErrSubVolMetadataNotSupported - } fsa, err := s.conn.GetFSAdmin() if err != nil { return err } err = fsa.SetMetadata(s.FsName, s.SubvolumeGroup, s.VolID, key, value) - if !s.isUnsupportedSubVolMetadata(err) { - return ErrSubVolMetadataNotSupported - } return err } @@ -74,17 +43,11 @@ func (s *subVolumeClient) setMetadata(key, value string) error { // using the metadata key. func (s *subVolumeClient) removeMetadata(key string) error { var err error - if !s.supportsSubVolMetadata() { - return ErrSubVolMetadataNotSupported - } fsa, err := s.conn.GetFSAdmin() if err != nil { return err } err = fsa.RemoveMetadata(s.FsName, s.SubvolumeGroup, s.VolID, key) - if !s.isUnsupportedSubVolMetadata(err) { - return ErrSubVolMetadataNotSupported - } return err } @@ -97,10 +60,6 @@ func (s *subVolumeClient) SetAllMetadata(parameters map[string]string) error { for k, v := range parameters { err := s.setMetadata(k, v) - // If setMetadata is not supported return nil - if errors.Is(err, ErrSubVolMetadataNotSupported) { - return nil - } if err != nil { return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w", k, v, s, err) } @@ -108,10 +67,6 @@ func (s *subVolumeClient) SetAllMetadata(parameters map[string]string) error { if s.clusterName != "" { err := s.setMetadata(clusterNameKey, s.clusterName) - // If setMetadata is not supported return nil - if errors.Is(err, ErrSubVolMetadataNotSupported) { - return nil - } if err != nil { return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w", clusterNameKey, s.clusterName, s, err) @@ -129,10 +84,6 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error { for _, key := range keys { err := s.removeMetadata(key) - // If setMetadata is not supported return nil - if errors.Is(err, ErrSubVolMetadataNotSupported) { - return nil - } // TODO: replace string comparison with errno. if err != nil && !strings.Contains(err.Error(), "No such file or directory") { return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", key, s, err) @@ -140,10 +91,6 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error { } err := s.removeMetadata(clusterNameKey) - // If setMetadata is not supported return nil - if errors.Is(err, ErrSubVolMetadataNotSupported) { - return nil - } // TODO: replace string comparison with errno. if err != nil && !strings.Contains(err.Error(), "No such file or directory") { return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", clusterNameKey, s, err) diff --git a/internal/cephfs/core/volume.go b/internal/cephfs/core/volume.go index a92025ec93d9..52e836764fcb 100644 --- a/internal/cephfs/core/volume.go +++ b/internal/cephfs/core/volume.go @@ -199,16 +199,13 @@ func (s *subVolumeClient) GetSubVolumeInfo(ctx context.Context) (*Subvolume, err type operationState int64 const ( - unknown operationState = iota - supported + supported operationState = iota unsupported ) type localClusterState struct { // set the enum value i.e., unknown, supported, // unsupported as per the state of the cluster. - resizeState operationState - subVolMetadataState operationState subVolSnapshotMetadataState operationState } @@ -268,39 +265,22 @@ func (s *subVolumeClient) ExpandVolume(ctx context.Context, bytesQuota int64) er return err } -// ResizeVolume will try to use ceph fs subvolume resize command to resize the -// subvolume. If the command is not available as a fallback it will use -// CreateVolume to resize the subvolume. +// ResizeVolume will use ceph fs subvolume resize command to resize the subvolume. func (s *subVolumeClient) ResizeVolume(ctx context.Context, bytesQuota int64) error { newLocalClusterState(s.clusterID) - // resize subvolume when either it's supported, or when corresponding - // clusterID key was not present. - if clusterAdditionalInfo[s.clusterID].resizeState == unknown || - clusterAdditionalInfo[s.clusterID].resizeState == supported { - fsa, err := s.conn.GetFSAdmin() - if err != nil { - log.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", s.FsName, err) - - return err - } - _, err = fsa.ResizeSubVolume(s.FsName, s.SubvolumeGroup, s.VolID, fsAdmin.ByteCount(bytesQuota), true) - if err == nil { - clusterAdditionalInfo[s.clusterID].resizeState = supported + fsa, err := s.conn.GetFSAdmin() + if err != nil { + log.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", s.FsName, err) - return nil - } - var invalid fsAdmin.NotImplementedError - // In case the error is other than invalid command return error to the caller. - if !errors.As(err, &invalid) { - log.ErrorLog(ctx, "failed to resize subvolume %s in fs %s: %s", s.VolID, s.FsName, err) + return err + } - return err - } + _, err = fsa.ResizeSubVolume(s.FsName, s.SubvolumeGroup, s.VolID, fsAdmin.ByteCount(bytesQuota), true) + if err != nil { + log.ErrorLog(ctx, "failed to resize subvolume %s in fs %s: %s", s.VolID, s.FsName, err) } - clusterAdditionalInfo[s.clusterID].resizeState = unsupported - s.Size = bytesQuota - return s.CreateVolume(ctx) + return err } // PurgSubVolume removes the subvolume.