Commit Graph

106 Commits

Author SHA1 Message Date
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 46ed646e03 rados: support fetching the cluster from the Conn
The cephfs function ceph_create_from_rados requires the cluster_t
value, which is current private to the Conn type. Alias the cluster_t
type and allow other pkgs to get it if needed.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-27 18:30:10 +01:00
John Mulligan 5cf2b02a6c rados: clean up var lines in rados.go and add doc comments
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05: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 f6d77333b7 rados: fix and update doc comments for PGCommand funcs
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan 0dfa7bcfac rados: add missing doc comment for OpenIOContext function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan 65f2417c4c rados: add doc comment for not connected error
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan bc9b7c58ed rados: add doc comments for RadosError type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 08:09:36 -05:00
John Mulligan de60dcb33b rados: add a test case for the >4086 buffer code path in ListPools
The code path where the pools result buffer was increased in size
then re-fetched was not being tested. Test it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 07:45:35 +01:00
John Mulligan 15dfd6fc09 rados: reduce boilerplate in TestGetPoolByName using testify
Testfiy's assert and require libs have helpful functions for
checking values. Use them to reduce a bunch of boilerplate code in the
TestGetPoolByName function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 07:45:35 +01:00
John Mulligan b5a0045d70 rados: add test coverage for failure to get config option
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 07:45:35 +01:00
John Mulligan b8f04da105 rados: add test coverage for failure to open io context
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 07:45:35 +01:00
John Mulligan dd1e25e5a4 rados: test error condition in PingMonitor
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-23 07:45:35 +01: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 18dcd69eb6 rados: drop extra else + return indent blocks
Clean up if-return-else-return pattern ocurrances in rados package's
conn.go file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-22 10:35:02 +01:00
John Mulligan bb375f68ac rados: convert less-than-zero error checks to getRadosError
A number of the error handling checks do not seem to need to check
for specific non-zero error returns so we should be able to
convert to getRadosError rather than a lot of boiler-plate.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-22 10:35:02 +01:00
John Mulligan d7bcba78dd rados: use getRadosError where obviously applicable
A number of the functions in rados do not use the simple error
conversion function where is obviously applies. Convert them to use it.

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
John Mulligan d51628ca59 rados: update test setup code to avoid blocking forever
When working on the previous rbd change it was determined that the
connection setup code would block forever if the ceph config was missing
or bad when running the tests. Adjust the connection setup in the rados
pkg such that the tests will not block forever.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-20 16:52:45 +01:00
John Mulligan d4b6798928 rados: add test function for error type and functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
John Mulligan bd99f64517 rados: convert to common errno handling
Use the errno handling function originally created for rbd and
then made common in rados package.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
John Mulligan 8a2d18be87 rados: include rados_test.go in rados package
Keeping the _test.go code in the same package allows for the testing
of private functions. AFAIK it is more conventional as well.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 09:49:47 +01:00
Yue Zhu 750fe1830e rados: add support for sending PG commands 2019-12-13 16:30:00 +01:00
John Mulligan e07f6a6050 rados: replace Println calls with a proper error
Replace the odd calls to Println with a comparable error value.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-13 15:17:27 +01:00
John Mulligan 5d0b9b17a0 rados: use correct style for package doc comment
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-12 11:34:51 -05:00
John Mulligan 5ea85a9419
Merge pull request #89 from CodeLingoBot/rewrite
Fix function comments based on best practices from Effective Go
2019-12-11 19:56:20 -05:00
Niels de Vos 09b6977dc9 rados: free cluster runtime resources automatically
Release resources that are allocated while configuring the connection to
the cluster. rados_shutdown() should only be needed after a successful
call to rados_connect(), however if the connection has been configured
with non-default parameters, some of the parameters may be allocated
before connecting. rados_shutdown() will free the allocated resources,
even if there has not been a connection yet.

Note that the finalizers get executed during garbage collection, which
can be forced by calling runtime.GC() for testing.

Fixes: #109
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2019-11-26 09:59:19 -05:00
Niels de Vos 43a863d1cb Add GetPoolByID() for calling rados_pool_reverse_lookup()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2019-11-01 14:40:47 -04:00
Niels de Vos bcf44fc782 Add GetPoolByName() for calling rados_pool_lookup()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2019-11-01 14:40:47 -04: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
Noah Watkins 21c4240aa3
Merge pull request #69 from MalloZup/Nitpick
Use Guardclause for function
2018-10-09 10:24:23 -07:00
Dario Maiocchi caf0f7ed68 Use Guardclause for function 2018-10-09 10:22:02 +02: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 fe9a93bb73 rados: migrate remaining tests to suite interface
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-09-14 14:35:45 -07:00
Noah Watkins 818e026b20 rados: grab all namespace prefix from C header
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-09-14 14:34:51 -07: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 a1c3394414 test: convert more tests to use suite
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-08-22 10:58:45 -07:00
Noah Watkins fad63ff1f9 test: convert more tests to use suite
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-08-17 11:51:36 -07:00
Noah Watkins 7b5a27ca9a rados: refactor tests to use testing suite
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-08-09 07:34:43 -07:00
Noah Watkins 6363bf77ae rados: use test suite to share code
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-08-07 18:48:17 -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 c14a3857fa rados: add a connected flag to the conn obj
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-07-28 14:23:18 -07:00