Commit 35989d9c authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-28281: Hashicorp: Key ID is not indicated in the log record

This commit adds an indication of the ID of the not found key
(and, when appropriate, also an indication of the version number
of the key) in the log file, making it easier to find errors.
parent 0c5d8b87
......@@ -595,7 +595,9 @@ static int hex2buf (unsigned int max_length, unsigned char *dstbuf,
}
static int get_data (const std::string &response_str,
const char **js, int *js_len)
const char **js, int *js_len,
unsigned int key_id,
unsigned int key_version)
{
const char *response = response_str.c_str();
size_t response_len = response_str.size();
......@@ -605,9 +607,18 @@ static int get_data (const std::string &response_str,
*/
if (response_len == 0)
{
my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER
"Key not found",
ME_ERROR_LOG_ONLY | ME_NOTE);
if (key_version == ENCRYPTION_KEY_VERSION_INVALID)
{
my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER
"Key not found (key id: %u)",
ME_ERROR_LOG_ONLY | ME_NOTE, key_id);
}
else
{
my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER
"Key not found (key id: %u, key version: %u)",
ME_ERROR_LOG_ONLY | ME_NOTE, key_id, key_version);
}
return 1;
}
if (json_get_object_key(response, response + response_len, "data",
......@@ -728,7 +739,8 @@ static unsigned int get_latest_version (unsigned int key_id)
}
const char *js;
int js_len;
if (get_data(response_str, &js, &js_len))
if (get_data(response_str, &js, &js_len, key_id,
ENCRYPTION_KEY_VERSION_INVALID))
{
return ENCRYPTION_KEY_VERSION_INVALID;
}
......@@ -809,7 +821,7 @@ static unsigned int get_key_from_vault (unsigned int key_id,
}
const char *js;
int js_len;
if (get_data(response_str, &js, &js_len))
if (get_data(response_str, &js, &js_len, key_id, key_version))
{
return ENCRYPTION_KEY_VERSION_INVALID;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment