mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/redis-connection-failure'
* origin/topic/timw/redis-connection-failure:
Redis: bump version of hiredis required
Redis: return proper error if connection fails
(cherry picked from commit f996f661b6
)
This commit is contained in:
parent
e1e5e404c3
commit
5b09f8cb47
7 changed files with 51 additions and 6 deletions
10
CHANGES
10
CHANGES
|
@ -1,3 +1,13 @@
|
|||
7.2.1-1 | 2025-07-14 14:18:30 -0700
|
||||
|
||||
* Redis: bump version of hiredis required (Tim Wojtulewicz, Corelight)
|
||||
|
||||
(cherry picked from commit f996f661b66ac5c0236203a54a79ce898531ac67)
|
||||
|
||||
* Redis: return proper error if connection fails (Tim Wojtulewicz, Corelight)
|
||||
|
||||
(cherry picked from commit f996f661b66ac5c0236203a54a79ce898531ac67)
|
||||
|
||||
7.2.1 | 2025-05-20 09:12:46 -0700
|
||||
|
||||
* Update CHANGES, VERSION, and NEWS for 7.2.1 release (Tim Wojtulewicz, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
7.2.1
|
||||
7.2.1-1
|
||||
|
|
|
@ -628,7 +628,7 @@ void Redis::HandleInfoResult(redisReply* reply) {
|
|||
}
|
||||
|
||||
void Redis::OnConnect(int status) {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection event");
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection event, status=%d", status);
|
||||
--active_ops;
|
||||
|
||||
connected = false;
|
||||
|
@ -638,7 +638,7 @@ void Redis::OnConnect(int status) {
|
|||
|
||||
if ( status == REDIS_ERR ) {
|
||||
// TODO: do something with the error?
|
||||
DBG_LOG(DBG_STORAGE, "INFO command failed: %s", async_ctx->errstr);
|
||||
DBG_LOG(DBG_STORAGE, "INFO command failed: %s err=%d", async_ctx->errstr, async_ctx->err);
|
||||
CompleteCallback(open_cb,
|
||||
{ReturnCode::OPERATION_FAILED,
|
||||
util::fmt("INFO command failed to retrieve server info: %s", async_ctx->errstr)});
|
||||
|
@ -647,12 +647,17 @@ void Redis::OnConnect(int status) {
|
|||
|
||||
++active_ops;
|
||||
}
|
||||
else {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection failed: %s err=%d", async_ctx->errstr, async_ctx->err);
|
||||
CompleteCallback(open_cb,
|
||||
{ReturnCode::CONNECTION_FAILED, util::fmt("Connection failed: %s", async_ctx->errstr)});
|
||||
}
|
||||
|
||||
// TODO: we could attempt to reconnect here
|
||||
}
|
||||
|
||||
void Redis::OnDisconnect(int status) {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: disconnection event");
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: disconnection event, status=%d", status);
|
||||
|
||||
connected = false;
|
||||
if ( status == REDIS_ERR ) {
|
||||
|
|
|
@ -29,9 +29,9 @@ if (HIREDIS_FOUND)
|
|||
set(HIREDIS_VERSION
|
||||
"${HIREDIS_MAJOR_VERSION}.${HIREDIS_MINOR_VERSION}.${HIREDIS_PATCH_VERSION}")
|
||||
|
||||
if (HIREDIS_VERSION VERSION_LESS "1.0.0")
|
||||
if (HIREDIS_VERSION VERSION_LESS "1.1.0")
|
||||
message(
|
||||
STATUS "Hiredis library version ${HIREDIS_VERSION} is too old, need v1.0.0 or later.")
|
||||
STATUS "Hiredis library version ${HIREDIS_VERSION} is too old, need v1.1.0 or later.")
|
||||
unset(HIREDIS_FOUND)
|
||||
|
||||
else ()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
Failed to connect
|
|
@ -0,0 +1,27 @@
|
|||
# @TEST-DOC: Tests various error handling scenarios for the storage framework
|
||||
|
||||
# @TEST-REQUIRES: have-redis
|
||||
# @TEST-PORT: REDIS_PORT
|
||||
|
||||
# @TEST-EXEC: zeek -b %INPUT > out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||
|
||||
@load base/frameworks/storage/sync
|
||||
@load base/frameworks/reporter
|
||||
@load policy/frameworks/storage/backend/redis
|
||||
|
||||
event zeek_init() {
|
||||
# Test failing to connect to a server
|
||||
local opts : Storage::BackendOptions;
|
||||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
local res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
|
||||
# macOS says this is a timeout, but linux says it's a connection refused. The
|
||||
# error string in the record contains the full reason, so don't print out the full
|
||||
# record in the interest of test determinism.
|
||||
if ( res$code == Storage::CONNECTION_FAILED )
|
||||
print "Failed to connect";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue