changeset 22562:3af1ba6b5248

director: Log info line whenever a director is added/removed from ring This can help with debugging problems.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 14 Sep 2017 17:29:48 +0300
parents 06361c8455a7
children ef58e0487991
files src/director/director-connection.c src/director/director.c src/director/director.h src/director/doveadm-connection.c
diffstat 4 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director-connection.c	Thu Sep 14 18:13:33 2017 +0300
+++ b/src/director/director-connection.c	Thu Sep 14 17:29:48 2017 +0300
@@ -744,6 +744,7 @@
 	struct director_host *host;
 	struct ip_addr ip;
 	in_port_t port;
+	bool log_add = FALSE;
 
 	if (!director_args_parse_ip_port(conn, args, &ip, &port))
 		return FALSE;
@@ -767,6 +768,7 @@
 	} else {
 		/* save the director and forward it */
 		host = director_host_add(conn->dir, &ip, port);
+		log_add = TRUE;
 	}
 	/* just forward this to the entire ring until it reaches back to
 	   itself. some hosts may see this twice, but that's the only way to
@@ -782,7 +784,7 @@
 			  "Not forwarding it since it's probably crashed.");
 	} else {
 		director_notify_ring_added(host,
-			director_connection_get_host(conn));
+			director_connection_get_host(conn), log_add);
 	}
 	return TRUE;
 }
--- a/src/director/director.c	Thu Sep 14 18:13:33 2017 +0300
+++ b/src/director/director.c	Thu Sep 14 17:29:48 2017 +0300
@@ -479,10 +479,15 @@
 }
 
 void director_notify_ring_added(struct director_host *added_host,
-				struct director_host *src)
+				struct director_host *src, bool log)
 {
 	const char *cmd;
 
+	if (log) {
+		i_info("Adding director %s to ring (requested by %s)",
+		       added_host->name, src->name);
+	}
+
 	added_host->dir->ring_change_counter++;
 	cmd = t_strdup_printf("DIRECTOR\t%s\t%u\n",
 			      net_ip2addr(&added_host->ip), added_host->port);
@@ -516,6 +521,9 @@
 	unsigned int i, count;
 	const char *cmd;
 
+	i_info("Removing director %s from ring (requested by %s)",
+	       removed_host->name, src->name);
+
 	if (removed_host->self) {
 		/* others will just disconnect us */
 		return;
--- a/src/director/director.h	Thu Sep 14 18:13:33 2017 +0300
+++ b/src/director/director.h	Thu Sep 14 17:29:48 2017 +0300
@@ -181,7 +181,7 @@
 bool director_resend_sync(struct director *dir);
 
 void director_notify_ring_added(struct director_host *added_host,
-				struct director_host *src);
+				struct director_host *src, bool log);
 void director_ring_remove(struct director_host *removed_host,
 			  struct director_host *src);
 
--- a/src/director/doveadm-connection.c	Thu Sep 14 18:13:33 2017 +0300
+++ b/src/director/doveadm-connection.c	Thu Sep 14 17:29:48 2017 +0300
@@ -261,7 +261,7 @@
 
 	if (director_host_lookup(conn->dir, &ip, port) == NULL) {
 		host = director_host_add(conn->dir, &ip, port);
-		director_notify_ring_added(host, conn->dir->self_host);
+		director_notify_ring_added(host, conn->dir->self_host, TRUE);
 	}
 	o_stream_nsend(conn->output, "OK\n", 3);
 	return DOVEADM_DIRECTOR_CMD_RET_OK;