Commit Graph

57 Commits

Author SHA1 Message Date
Sven Anderson e8da761769 update various parts of the code to use the retry lib.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-04-20 15:08:36 -04:00
John Mulligan be7a90a2be rados: use getError helper in general error conversion cases
For more consisistency use getError where possible.
Changes produced using `gofmt -r 'RadosError(int(x)) -> getError(x)`,
followed by a few manual fixups.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 17:10:09 -04:00
John Mulligan 5394d1c99f rados: update error conversion func to be consistent with rbd & cephfs
Rename the getRadosError to getError and update it to match the other
packages behavior.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 17:10:09 -04:00
John Mulligan 754d744ac8 rados: return an unsafe.Pointer from ioctx Pointer call
This improves the code in two ways: first, it makes the function name and the
return type match. Second, it avoids issues found by go vet converting
from uintptr to unsafe.Pointer without any obvious pointer math.
(See: https://pkg.go.dev/unsafe)

Technically, this is an API breaking change but this function is only
public to exchange the internal ceph structure between the rados and
rbd modules. This had the smallest delta and doesn't feel any more
hacky than what already existed in the code. If someone was using this
function externally then too bad.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 09:02:53 +01:00
John Mulligan 9efbfd8518 rados: move object iter(ation) related functions into their own file
Create an object_iter.go from the Iter related functions that were
formerly in ioctx.go. This makes ioctx a little less of a giant wall of
code as well as making things easier to work on in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 08:51:07 +01:00
John Mulligan f29d760894 rados: move omap related functions into their own file
Create an omap.go from the omap functions that were formerly in
ioctx.go. This makes ioctx a little less of a giant wall of code
as well as making things easier to work on in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 08:51:07 +01:00
Niels de Vos 5adb04909d rados: standardize error naming
RadosError-prefixes are not recommended, instead just Err as prefix is
used.

Also, errors are constants, not variables.

For existing users, backwards compatible constants are available. These
will need to be removed in a future go-ceph release.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-01-29 16:51:49 +01:00
Niels de Vos c6b65af9ec rados: add Create() function to create new objects
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-01-29 16:51:49 +01:00
John Mulligan 1585362d3a rados: fix incorrect doc comment on SetOmap func
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan 90cd306e99 rados: fix incorrect doc comment for ListXattrs function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan bcec1ab9c1 rados: fix incorrect doc comment on SetXattr
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan f16013ebce rados: fix incorrect doc comment on ListLockers function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan b1740e9680 rados: fix incorrect doc comments on Unlock & BreakLock
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan f6a143f24f rados: add 'implements' subsection to GetPoolStats doc comment
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan 8cdeebc38f rados: fix incorrect doc comment for GetPoolStats
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan 224217212d rados: drop extra else + return indent blocks
Clean up if-return-else-return pattern ocurrances in rados package's
ioctx file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-22 10:35:02 +01:00
John Mulligan df46476e21 rados: make get rados error a private function
There is no good reason why the internal error handling support should
be exposed outside the rados package. Make the function lower-cased and
thus private.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-22 10:35:02 +01:00
CodeLingo Bot 9e2fbe369f Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-03-06 03:14:57 +00:00
zhangyue 7884e8a8af bugfix: fix function deprecated rados_read_op_omap_get_vals
Signed-off-by: zhangyue <zy675793960@yeah.net>
2018-12-02 11:04:21 +08:00
Daniel Swarbrick 3023eb281d
Go style cleanups
- Use C errno constants in place of hardcoded ints
- Use type inference where possible (especially C.CString
- Don't explicitly specify zero values where value would be default anway
- Rewrap some unnecessarily wrapped short lines
- Use if/else one-liners where value is not needed afterwards

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
2018-09-18 11:03:41 +02:00
Noah Watkins 5074481957 fmt: fix formatting
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-09-14 14:34:33 -07:00
Noah Watkins 0a30725b59 ioctx: do not short-circuit read for empty slice
ioctx.read should contact the cluster even when its slice is empty so
that errors like ENOENT can be reported.

Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-08-07 18:48:17 -07:00
Noah Watkins 8b9635ff29
Merge pull request #51 from nanjekyejoannah/add_go_vet
Add go vet to Travis
2018-07-07 11:12:38 -07:00
Noah Watkins 3b3b73fc99
Merge pull request #52 from immesys/improve-namespaces
Improve namespace support
2018-07-07 10:41:28 -07:00
Joshua C. Randall 3c08133264 fix panic when writing empty objects
fixes #58
2018-06-29 14:49:12 +00:00
Michael Andersen 59cdfdc5a4 rados: improve support for namespaces 2018-02-03 10:59:54 -08:00
Joannah Nanjekye 35ee127486 Add go vet to Travis 2018-01-30 21:12:42 +03:00
Noah Watkins bd5bc6d4cb
Merge pull request #48 from immesys/master
Get luminous working
2018-01-04 14:54:52 -06:00
Michael Andersen a97ce4a032 ioctx: replace functions unimplemented on luminous 2017-12-30 09:35:26 -08:00
Kefu Chai 9db9a99b59 ioctx: compiles on osx
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2017-10-17 19:44:47 +08:00
Damien Tournoud 03facd6d90 Fix bogus duration handling in IOContext.Lock*
Signed-off-by: Damien Tournoud <damien@platform.sh>
2017-07-28 16:32:25 +02:00
Noah Watkins 022d69c468 ioctx: check high-level error first
the problem was that the C-API was returning an error, but the error
pointer (from the op) was getting -EIO. That makes sense as the outer
error was resulting in junk being decode somewhere.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2017-01-20 09:36:07 -08:00
Emmet Cassidy 628bae93d1 rados: add support for object locking + test 2016-08-03 15:50:34 -07:00
Noah Watkins 29d1ad9394 ioctx: fix integer cast
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2016-03-26 11:54:51 -07:00
Noah Watkins 8c0703f5e2 Merge remote-tracking branch 'origin/pr/15' 2016-03-26 11:52:02 -07:00
Noah Watkins b6a7e80009 Merge remote-tracking branch 'origin/pr/14' 2016-03-26 11:49:28 -07:00
Livio Soares f74dc6c3c6 rados: Use GetRadosError() in lieu of RadosError() so as to guarantee the translation of error codes into rados errors where applicable.
This commit fixes the TestObjectStat() case where a non existing object name is
tested for existance.
2016-03-25 00:59:18 -04:00
Livio Soares 46f5d61aba Namespace support for Pools.
This commit simply adds a SetNamespace() method to IOContext, allowing users to
perform pool operations in the context of a specific namespace.
2016-03-25 00:42:49 -04:00
Livio Soares 2d33c55c6b rados: Fix iterator memory allocation; allocating a c_entry is not necessary and performed directly by the library. 2016-03-25 00:08:28 -04:00
Livio Soares 373a3043d7 rados: Implement Iter() interface to allow incremental listing of Pools.
The current IOContext struct has a ListObjects() method that works well for
pools with a reasonable number of objects. However, for very large pools, having
finer control over the iteration may be desirable.

This commit adds a new Iter() interface for pools. It allows callers to stop
iterating at any time by issuing a iter.Close(). It also allows callers to
"Seek" into the pool list using a token object.
2016-03-24 23:18:07 -04:00
Livio Soares 74d77ff49b Fix rados.GetRadosError() interface to allow package-external use.
In Go, the "C" package is a special type of package that creates local symbols
names (non exportable) to the importing package. The result, in the case of
rados.GetRadosError() is that trying to use results in:

cannot use cerr (type C.int) as type rados.C.int in argument to rados.GetRadosError

It seems that "C.int" within 'rados' namespace produces a symbol of the type
`_Ctype_int`, which given it's first character `_` is not exported. As such, we
have the type being defined as `rados._Ctype_int`, which is not accessible
outside of the rados package.

This commit changes the interface to use the native Go `int` type.
2016-03-24 22:37:52 -04:00
Emmet Cassidy f251b539c3 added append function and a test 2015-10-28 09:25:11 -07:00
Ye Yin 5c2d42ef5a Change return new error for rados and rbd
Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-24 11:34:18 +08:00
Ye Yin 193dbacdb0 Convert some C error code to Go code, for convenient Golang code to handle error.
Define some Rbd constant variables, to pass to librbd API.
Add test unit for RbdErrorNotFound

Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-23 15:33:34 +08:00
Ye Yin f39179553f Add rados_write_full function
Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-20 20:37:32 +08:00
Abhishek Lekshmanan d63c6698c2 gofmt all the source files
Running gofmt ./... on the repository

Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
2015-07-08 14:04:54 +05:30
Vincent Giersch b15639c44c ioctx: ListOmapValues & GetAllOmapValues added
* `ListOmapValues` allows to iterate on all the key feteched during
a read operation of an omap (the goal is to easily get the last
read key from the C iterator. This one can then be used in another
call as `startAfter` parameter).
* `GetAllOmapValues` returns all the keys / values of the whole omap
* `GetOmapValues` now uses `ListOmapValues`

Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
2015-05-04 14:50:59 +00:00
Noah Watkins c7a0450712 Merge pull request #15 from gierschv/feat-stat
ioctx: Stat added
2015-04-27 11:32:58 -07:00
Vincent Giersch 476dc4001d ioctx: omap set / get / delete / clear added
Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
2015-04-27 15:21:54 +00:00
Vincent Giersch 1779dc795a ioctx: Stat added
Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
2015-04-24 12:01:50 +00:00