Commit Graph

265 Commits

Author SHA1 Message Date
Madhu Rajanna
e8267de3c9 cephfs: fix logic to call ceph fs resize
clusterAdditionalInfo map is holding a localClusterState
for checking ceph cluster supports resize and subvolumegroup
is created or not, currently we are checking if the key is present
in a map and localClusterStatelocalClusterState.resizeSupported
is set to false to call ceph fs subvolume resize to check command is
supported or not, if a structure is  initialized all its members
are set to default value. so we will never going to check the
ceph fs subvolume  resize command is supported in backend or not, we are
always using ceph fs subvolume create to resize subvolume. in some
ceph version ceph fs subvolume create wont work to resize a subvolume.
This commit changes the resizeSupported from bool to *bool for
proper handling of this scenario.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit a35a835e9c)
2020-12-03 09:57:17 +00:00
Madhu Rajanna
4be9c0159f rbd: add minsnapshotsonimage flag
An rbd image can have a maximum number of
snapshots defined by maxsnapshotsonimage
On the limit is reached the cephcsi will
start flattening the older snapshots and
returns the ABORT error message, The Request
comes after this as to wait till all the
images are flattened (this will increase the
PVC creation time.  Instead of waiting till
the maximum snapshots on an RBD image, we can
have a soft limit, once the limit reached
cephcsi will start flattening the task to
break the chain. With this PVC  creation time
will only be affected when the hard limit
(minsnapshotsonimage) reached.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 8d3a44d0c4)
2020-11-18 20:11:43 +05:30
Madhu Rajanna
83fbbd6d93 cephfs: check only the stderror message for umount
if the cephfs mountpoint is not mounted the umount
call will fail with both stderr and err,
an error (exit status 32) and stdError (umount: /var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-e622cd2b-0b87-4f49-a709-b89664ca6ec4/globalmount: not mounted.

checking stderr is sufficient to find out the mountpoint
is not mounted.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-11-18 09:37:57 +05:30
Madhu Rajanna
09c303c2cb cephfs: check clone pending state
sometimes, cephfs returns pending as clone
status if we request for the subvolume clone.
cephcsi need to consider the pending state
when checking the clone status and it should
return abort error message if the clone is in
pending state or in-progress state.

Co-authored-by: Yug <yuggupta27@gmail.com>
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-11-06 21:19:17 +05:30
Madhu Rajanna
75d190f430 cephfs: check stderror for CLI commands
currently in someplaces we are checking the stderror
for CLI errors and insome places we are checking for
just error. This commit fixes the issue by checking
the stderror for actual CLI errors.

Co-authored-by: Yug <yuggupta27@gmail.com>
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-11-06 21:19:17 +05:30
Madhu Rajanna
eaf0058c31 util: log stderror in ExecCommand
all the CLI commands we execute logs the actual
error in stdError. logging stderror is using for
debugging.

Co-authored-by: Yug <yuggupta27@gmail.com>
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-11-06 21:19:17 +05:30
John Mulligan
e99b996bea journal: fix reading omaps from objects with large key counts
The implementation of getOMapValues assumed that the number of key-value
pairs assigned to the object would be close to the number of keys
being requested. When the number of keys on the object exceeded the
"listExcess" value the function would fail to read additional keys
even if they existed in the omap.
This change sets a large fixed "chunk size" value and keeps reading
key-value pairs as long as the callback gets called and increments
the numKeys counter.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 8a41cd03a5)
2020-11-06 07:46:07 +00:00
Humble Chirammal
6e3d68ee7b cephfs: fix wrong error check in CreateVolume rollback action
Previously the purgeVolume error was ignored due to wrong error variable
check in the createVolume. With this change it checks on the proper error.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
(cherry picked from commit 9dee064b77)
2020-10-20 05:57:38 +00:00
Marton Natko
8dc3f51350 rbd: fix problem with deletion of a namespaced image
fix problem with deletion of a namespaced image

Signed-off-by: Marton Natko <mnatko@transip.nl>
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 91c49c14b3)
2020-09-25 17:05:19 +00:00
Marton Natko
d999d9db0c rbd: fix typo in createVolume validation
Signed-off-by: Marton Natko <mnatko@transip.nl>
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 2fbca0d1e2)
2020-09-25 17:05:19 +00:00
Madhu Rajanna
764e33f249 cephfs: check ENOTEMPTY when removing subvolume
return a proper error message to the user when
the subvolume has the snapshots and it cannot
be removed until the snapshots on the subvolume
have to be deleted.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 89b326c896)
2020-09-25 09:26:48 +00:00
Niels de Vos
b810ca57a0 cephfs: trim spaces around fuseMountOptions
When passing

    fuseMountOptions: debug

in the StorageClass, the mount options passed on the ceph-fuse
commandline result in "-o nonempty ,debug". The additional space before
the ",debug" causes the mount command to fail.

Fixes: 1485
Signed-off-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit 6f2f972f5b)
2020-09-23 14:39:43 +00:00
Yug
8170e12114 cephfs: Fetch subvolume features in newSnapshotOptionsFromID
Get subvolume features using subvolume info and update the
volume options with Features parameter.

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 0682f0e500)
2020-09-17 09:04:41 +00:00
Yug
6a64958876 cephfs: No-Op Unprotect call if "snapshot-autoprotect" feature present
The subvolume features consists the list of features, which if includes
"snapshot-autoprotect", result in query based approach to
detecting the need for protect/unprotect.
If "snapshot-autoprotect" feature is present, The UnprotectSnapshot
call should be treated as a no-op

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 9e959c45a3)
2020-09-17 09:04:41 +00:00
Yug
15463d8f52 cephfs: No-Op Protect call if "snapshot-autoprotect" feature present
The subvolume features consists the list of features, which if includes
"snapshot-autoprotect", result in query based approach to
detecting the need for protect/unprotect.
If "snapshot-autoprotect" feature is present, The ProtectSnapshot
call should be treated as a no-op

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 43a4c100ec)
2020-09-17 09:04:41 +00:00
Yug
b32569bc47 cephfs: use subvolume info if available
Use subvolume info to fetch the subvolume path.
If `subvolume info` command is not available,
use `getpath` command instead.

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 365eb58ff7)
2020-09-11 12:23:19 +00:00
Yug
0f51df99e8 cephfs: validate if subvolume has snapshot-retention feature
Add validateSnapshotRetention() to verify if subvolume has
`snapshot-retention` feature.

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 59fc4aa00f)
2020-09-11 12:23:19 +00:00
Yug
5daf21831e cephfs: Add --retain-snapshots flag to purge volume operations
Snapshots can be retained even after subvolume deletion in
Ceph 14.2.12. Adding support for the same in ceph-csi.

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 6351358752)
2020-09-11 12:23:19 +00:00
Madhu Rajanna
d7e3f06384 cephfs: allow readonly only for volume with contentsource
It doesnot make sense to allow the creation of empty
volumes with readonly access, this commit allows the
creation of volume which is having readonly capabilities
only if the content source is set for the volume.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 860b65c446)
2020-09-10 15:05:38 +00:00
Madhu Rajanna
5a7e188bb4 rbd: allow readonly only for volume with contentsource
It doesnot make sense to allow the creation of empty
volumes which is going to be accessed with readonly mode,
this commit allows the creation of volume which is having
readonly capabilities only if the content source is set
for the volume.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 2deabcd284)
2020-09-10 15:05:38 +00:00
Madhu Rajanna
c9601189ef util: add helper to validate ROX request
added a helper function to validate is create
request for ROX is for volume from source.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit d816df4f42)
2020-09-10 15:05:38 +00:00
Mudit Agarwal
6105a4f428 rbd: NodeExpandVolume() should use StagingTargetPath
Form kubernetes v1.19 onwards NodeRequest is getting volume path
in StagingTargetPath instead of VolumePath, cephcsi should also
use the same.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
(cherry picked from commit 4de1abad5e)
2020-08-25 17:20:08 +00:00
Mudit Agarwal
1792cff878 rbd: implement rbd.updateVolWithImageInfo() with go-ceph
updateVolWithImageInfo() is currently executing an rbd command
to get details about an RBD image. Replaced it with the
required go-ceph functions.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
(cherry picked from commit 8c2bdbc001)
2020-08-25 08:13:52 +00:00
Madhu Rajanna
8e267b3806 rbd: rearrange the cleanup order incase clone fails
in case of clone failure, we need to first delete
the clone and the snapshot from which we created
the clone, then as part of cleanup we need to remove
the temporary cloned image and the temporary snapshot
created on the parent image.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 38892c3068)
2020-08-24 09:24:09 +00:00
Madhu Rajanna
45c8d178b2 rbd: fix return error message
incase of flattening error return the
flatten error.
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit a7b65087af)
2020-08-24 09:24:09 +00:00
Madhu Rajanna
a8e6bdee8e cephfs: use string const for cli error comparison
we should not return the CLI errors in GRPC errors
we need to return proper readable error messages
to the user for better understanding and better
debugging.

updates #1242

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 0bd45a5eb1)
2020-08-19 18:15:10 +00:00
Madhu Rajanna
b2a9ecf5e5 util: replace klog with util logger in liveness.go
replace klog with util logger in liveness.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 27d2cc644d)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
2fe86bbc4b journal: replace klog with util logger in voljournal.go
journal: replace klog with util logger in voljournal.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit ed289fea5e)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
c75f89628c journal: replace klog with util logger in omap.go
replace klog with util logger in omap.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 1a9cd23f64)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
86aca6c631 rbd: replace klog with util logger in snapshot.go
rbd: replace klog with util logger in snapshot.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 7c9fee17af)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
c61fd94596 rbd: replace klog with util logger in rbd_util.go
rbd: replace klog with util logger in rbd_util.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 9305e27797)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
9938c654e1 rbd: replace klog with util logger in rbd_journal.go
replace klog with util logger in rbd_journal.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 90cc5a4fd0)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
f9bb13a373 rbd: replace klog with util logger in rbd_attach.go
replace klog with util logger in rbd_attach.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 9512aa6206)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
727666dedc rbd: replace klog with util logger in nodeserver.go
replace klog with util logger in nodeserver.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit e768c0dfc0)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
4b5952d15a rbd: replace klog with util logger in driver.go
replace klog with util logger in driver.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 883485b082)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
ab53834757 rbd: replace klog with util logger in clone.go
replace klog with util logger in clone.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit c4f30c23c1)
2020-08-19 15:35:13 +00:00
Madhu Rajanna
98088ec50a rbd: replace klog with util in controllerserver.go
replace klog with util in controllerserver.go

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit d8ca56fbe9)
2020-08-19 15:35:13 +00:00
Humble Chirammal
d04dbd0811 rbd: Bail out from nodeexpansion if its block mode pvc
At CSI spec < 1.2.0, there was no volumecapability in the
expand request. However its available from v1.2+ which allows
us to declare the node operations based on the volume mode.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
(cherry picked from commit 1f5b84745f)
2020-08-19 13:43:52 +00:00
Madhu Rajanna
165b8d13d1 cephfs: fix lock release in volumeDelete
currently the lock is not released which is
taken on the request name. this is causing issues
when the subvolume is requested for delete.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 787ba69089)
2020-08-18 10:07:25 +00:00
Madhu Rajanna
f9faf4822f cephfs: check error output contains Error: ENOENT
execCommandErr returns both error and stderror
message. checking strings.HasPrefix is not helpful
as the stderr will be the first string. its good
to do string comparison and find out that error
is volume not found error.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 31c7c95fdb)
2020-08-18 10:07:25 +00:00
Madhu Rajanna
f566b0fc2d cephfs: replace Warningf with WarningLog in unmountVolume
replace Errorf with ErrorLog in unmountVolume
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
3fe3d25dda cephfs: replace Errorf with ErrorLogMsg in loadAvailableMounters
replace Errorf with ErrorLog in loadAvailableMounters
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
fbe090065d cephfs: replace Errorf with ErrorLog in purgeVolume
replace Errorf with ErrorLog in purgeVolume
for context based logging

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
5a1652e5e8 cephfs: replace Errorf with ErrorLog in resizeVolume
replace Errorf with ErrorLog in resizeVolume
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
a882c1194b cephfs: replace Errorf with ErrorLog in createVolume
replace Errorf with ErrorLog in createVolume
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
f3d9b8933b cephfs: replace Errorf with ErrorLog in getSubVolumeInfo
replace Errorf with ErrorLog in getSubVolumeInfo
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
2b7aade289 cephfs: replace Errorf with ErrorLog in getVolumeRootPathCeph
replace Errorf with ErrorLog in getVolumeRootPathCeph
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
d1ac832266 cephfs: replace Errorf with ErrorLog in genSnapFromOptions
replace Errorf with ErrorLog in genSnapFromOptions
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
e83a51c1e1 cephfs: replace Errorf with ErrorLog in parseTime
replace Errorf with ErrorLog in parseTime
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00
Madhu Rajanna
e7a043271d cephfs: replace Errorf with ErrorLog in cloneSnapshot
replace Errorf with ErrorLog in cloneSnapshot
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2020-08-13 09:44:12 +00:00