python/sanlock.c
by David Teigland
python/sanlock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit b79bd2ac317427908ced4834cc08a1198ce327a1
Author: Nir Soffer <nsoffer(a)redhat.com>
Date: Wed Jan 4 22:56:10 2017 +0200
python: Use error description in SanlockException
When raising SanlockException, if the error code was a posix error, we
included the error description from strerror(3), but for sanlock error
codes we included a rather unhelpful "Sanlock exception".
Now that we have sanlock_strerror() we can use it to include the actual
error description:
sanlock.SanlockException: (-223, 'Sanlock resource read failure',
'Lease does not exist on storage')
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
diff --git a/python/sanlock.c b/python/sanlock.c
index f2ad672..0ef1174 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -54,7 +54,7 @@ __set_exception(int en, char *msg)
en = -en;
err_name = strerror(en);
} else {
- err_name = "Sanlock exception";
+ err_name = sanlock_strerror(en);
}
exc_tuple = Py_BuildValue("(iss)", en, msg, err_name);
6 years, 9 months
[PATCH] python: Use error description in SanlockException
by Nir Soffer
From: Nir Soffer <nsoffer(a)redhat.com>
When raising SanlockException, if the error code was a posix error, we
included the error description from strerror(3), but for sanlock error
codes we included a rather unhelpful "Sanlock exception".
Now that we have sanlock_strerror() we can use it to include the actual
error description:
sanlock.SanlockException: (-223, 'Sanlock resource read failure',
'Lease does not exist on storage')
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index f2ad672..0ef1174 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -54,7 +54,7 @@ __set_exception(int en, char *msg)
en = -en;
err_name = strerror(en);
} else {
- err_name = "Sanlock exception";
+ err_name = sanlock_strerror(en);
}
exc_tuple = Py_BuildValue("(iss)", en, msg, err_name);
--
2.9.3
6 years, 9 months
src/client.c src/sanlock.h
by David Teigland
src/client.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/sanlock.h | 2 +
2 files changed, 79 insertions(+)
New commits:
commit c8ce851b260d2a3dd00ebc3f3b0cc4909522b101
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jan 3 13:49:12 2017 -0600
sanlock: add strerror function
to get a short string description of error numbers.
diff --git a/src/client.c b/src/client.c
index 4e1c14c..45aa06a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -32,6 +32,7 @@
#include "sanlock_resource.h"
#include "sanlock_admin.h"
#include "sanlock_sock.h"
+#include "sanlock_rv.h"
#ifndef GNUC_UNUSED
#define GNUC_UNUSED __attribute__((__unused__))
@@ -1998,3 +1999,79 @@ int sanlock_str_to_lockspace(char *str, struct sanlk_lockspace *ls)
return 0;
}
+const char *sanlock_strerror(int rv)
+{
+ switch (rv) {
+ case SANLK_ERROR:
+ return "General error";
+ case SANLK_AIO_TIMEOUT:
+ return "IO timeout";
+ case SANLK_WD_ERROR:
+ return "Watchdog device error";
+ case SANLK_DBLOCK_READ:
+ return "Lease read error in dblock";
+ case SANLK_DBLOCK_WRITE:
+ return "Lease write error in dblock";
+ case SANLK_DBLOCK_MBAL:
+ return "Lease was acquired by another host in current ballot";
+ case SANLK_DBLOCK_CHECKSUM:
+ return "Lease checksum error in dblock";
+ case SANLK_LEADER_READ:
+ return "Lease read error in leader";
+ case SANLK_LEADER_WRITE:
+ return "Lease write error in leader";
+ case SANLK_LEADER_DIFF:
+ return "Lease read inconsistent";
+ case SANLK_LEADER_MAGIC:
+ return "Lease does not exist on storage";
+ case SANLK_LEADER_VERSION:
+ return "Lease format version on storage is not recognized";
+ case SANLK_LEADER_SECTORSIZE:
+ return "Lease sector size is inconsistent";
+ case SANLK_LEADER_LOCKSPACE:
+ return "Lease lockspace name is incorrect";
+ case SANLK_LEADER_RESOURCE:
+ return "Lease resource name is incorrect";
+ case SANLK_LEADER_NUMHOSTS:
+ return "Lease num_hosts is incorrect";
+ case SANLK_LEADER_CHECKSUM:
+ return "Lease checksum error in leader";
+ case SANLK_ACQUIRE_LVER:
+ return "Lease leader version is unmatching";
+ case SANLK_ACQUIRE_LOCKSPACE:
+ return "Lease lockspace is not found";
+ case SANLK_ACQUIRE_IDDISK:
+ return "Lease lockspace disk cannot be opened";
+ case SANLK_ACQUIRE_IDLIVE:
+ return "Lease is held by another host";
+ case SANLK_ACQUIRE_OWNED:
+ return "Lease was acquired by another host in other ballot";
+ case SANLK_ACQUIRE_OTHER:
+ return "Lease was acquired by another host in local commit";
+ case SANLK_ACQUIRE_SHRETRY:
+ return "Lease is held by another host for shared acquire";
+ case SANLK_ACQUIRE_OWNED_RETRY:
+ return "Lease is owned by another host";
+ case SANLK_RELEASE_LVER:
+ return "Lease release version is incorrect";
+ case SANLK_RELEASE_OWNER:
+ return "Lease release owner is incorrect";
+ case SANLK_RENEW_OWNER:
+ return "Lease renew owner is incorrect";
+ case SANLK_RENEW_DIFF:
+ return "Lease renew data has changed";
+ case SANLK_HOSTID_BUSY:
+ return "Lease host ID is being used by another host";
+ case SANLK_REQUEST_MAGIC:
+ return "Lease request block has invalid data";
+ case SANLK_REQUEST_VERSION:
+ return "Lease request block has invalid version";
+ case SANLK_REQUEST_OLD:
+ return "Lease request has newer lease version";
+ case SANLK_REQUEST_LVER:
+ return "Lease request block has newer version";
+ default:
+ return "Unknown error";
+ };
+}
+
diff --git a/src/sanlock.h b/src/sanlock.h
index 89af4e6..1ebe745 100644
--- a/src/sanlock.h
+++ b/src/sanlock.h
@@ -138,4 +138,6 @@ struct sanlk_host_event {
size_t sanlock_path_export(char *dst, const char *src, size_t dstlen);
size_t sanlock_path_import(char *dst, const char *src, size_t dstlen);
+const char *sanlock_strerror(int rv);
+
#endif
6 years, 9 months