URL: https://github.com/SSSD/sssd/pull/404 Author: fidencio Title: #404: Log to syslog whether the DP is online or offline Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/404/head:pr404 git checkout pr404
From a5ab364af1f74f7b1d2c3b738507a39cd293b5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fiden...@redhat.com> Date: Thu, 12 Oct 2017 10:08:21 +0200 Subject: [PATCH 1/3] DP: Fix the output type used in dp_req_recv_ptr() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related: https://pagure.io/SSSD/sssd/issue/3307 Signed-off-by: Fabiano FidĂȘncio <fiden...@redhat.com> --- src/providers/data_provider_be.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index a1509cfd2..e564bc11d 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -249,7 +249,7 @@ static errno_t be_check_online_request(struct be_ctx *be_ctx) static void be_check_online_done(struct tevent_req *req) { struct be_ctx *be_ctx; - struct dp_reply_std reply; + struct dp_reply_std *reply; errno_t ret; be_ctx = tevent_req_callback_data(req, struct be_ctx); @@ -260,7 +260,7 @@ static void be_check_online_done(struct tevent_req *req) goto done; } - switch (reply.dp_error) { + switch (reply->dp_error) { case DP_ERR_OK: DEBUG(SSSDBG_TRACE_FUNC, "Backend is online\n"); break; @@ -275,7 +275,7 @@ static void be_check_online_done(struct tevent_req *req) be_ctx->check_online_ref_count--; - if (reply.dp_error != DP_ERR_OK && be_ctx->check_online_ref_count > 0) { + if (reply->dp_error != DP_ERR_OK && be_ctx->check_online_ref_count > 0) { ret = be_check_online_request(be_ctx); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create check online req.\n"); @@ -286,8 +286,8 @@ static void be_check_online_done(struct tevent_req *req) done: be_ctx->check_online_ref_count = 0; - if (reply.dp_error != DP_ERR_OFFLINE) { - if (reply.dp_error != DP_ERR_OK) { + if (reply->dp_error != DP_ERR_OFFLINE) { + if (reply->dp_error != DP_ERR_OK) { reset_fo(be_ctx); } be_reset_offline(be_ctx); From c53662774fa799dcde94e554f384d0045e8d5cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fiden...@redhat.com> Date: Thu, 12 Oct 2017 10:15:22 +0200 Subject: [PATCH 2/3] DP: Log to syslog whether it's online or offline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of requiring that admins enable and look at our logs, let's log to syslog what's the DP status. Resolves: https://pagure.io/SSSD/sssd/issue/3307 Signed-off-by: Fabiano FidĂȘncio <fiden...@redhat.com> --- src/providers/backend.h | 5 +++++ src/providers/data_provider_be.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/providers/backend.h b/src/providers/backend.h index f6c74f856..191427403 100644 --- a/src/providers/backend.h +++ b/src/providers/backend.h @@ -113,6 +113,11 @@ struct be_ctx { size_t check_online_ref_count; struct data_provider *provider; + + /* Indicates whether the last state of the DP that has been logged is + * DP_ERR_OK or DP_ERR_OFFLINE. The only usage of this var, so far, is + * to log the DP status without spamming the syslog/journal. */ + int last_dp_state; }; bool be_is_offline(struct be_ctx *ctx); diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index e564bc11d..2e55dc4e3 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -262,9 +262,17 @@ static void be_check_online_done(struct tevent_req *req) switch (reply->dp_error) { case DP_ERR_OK: + if (be_ctx->last_dp_state != DP_ERR_OK) { + be_ctx->last_dp_state = DP_ERR_OK; + sss_log(SSS_LOG_INFO, "Backend is online\n"); + } DEBUG(SSSDBG_TRACE_FUNC, "Backend is online\n"); break; case DP_ERR_OFFLINE: + if (be_ctx->last_dp_state != DP_ERR_OFFLINE) { + be_ctx->last_dp_state = DP_ERR_OFFLINE; + sss_log(SSS_LOG_INFO, "Backend is offline\n"); + } DEBUG(SSSDBG_TRACE_FUNC, "Backend is offline\n"); break; default: @@ -397,6 +405,7 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx, ret = ENOMEM; goto done; } + be_ctx->last_dp_state = -1; ret = be_init_failover(be_ctx); if (ret != EOK) { From 5645e1e7935fa5cf465b7b6c1777eb99ffbef00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fiden...@redhat.com> Date: Mon, 16 Oct 2017 14:36:21 +0200 Subject: [PATCH 3/3] DP: Only print its status in case of change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabiano FidĂȘncio <fiden...@redhat.com> --- src/providers/data_provider_be.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 2e55dc4e3..d99c43560 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -265,15 +265,15 @@ static void be_check_online_done(struct tevent_req *req) if (be_ctx->last_dp_state != DP_ERR_OK) { be_ctx->last_dp_state = DP_ERR_OK; sss_log(SSS_LOG_INFO, "Backend is online\n"); + DEBUG(SSSDBG_TRACE_FUNC, "Backend is online\n"); } - DEBUG(SSSDBG_TRACE_FUNC, "Backend is online\n"); break; case DP_ERR_OFFLINE: if (be_ctx->last_dp_state != DP_ERR_OFFLINE) { be_ctx->last_dp_state = DP_ERR_OFFLINE; sss_log(SSS_LOG_INFO, "Backend is offline\n"); + DEBUG(SSSDBG_TRACE_FUNC, "Backend is offline\n"); } - DEBUG(SSSDBG_TRACE_FUNC, "Backend is offline\n"); break; default: DEBUG(SSSDBG_TRACE_FUNC, "Error during online check [%d]: %s\n",
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org