Skip to content

Commit

Permalink
director: Log info line whenever a director is added/removed from ring
Browse files Browse the repository at this point in the history
This can help with debugging problems.
  • Loading branch information
sirainen committed Oct 5, 2017
1 parent f16eeeb commit 2ff3217
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/director/director-connection.c
Expand Up @@ -744,6 +744,7 @@ static bool director_cmd_director(struct director_connection *conn,
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;
Expand All @@ -767,6 +768,7 @@ static bool director_cmd_director(struct director_connection *conn,
} 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
Expand All @@ -782,7 +784,7 @@ static bool director_cmd_director(struct director_connection *conn,
"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;
}
Expand Down
10 changes: 9 additions & 1 deletion src/director/director.c
Expand Up @@ -479,10 +479,15 @@ void director_sync_thaw(struct director *dir)
}

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);
Expand Down Expand Up @@ -516,6 +521,9 @@ void director_ring_remove(struct director_host *removed_host,
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;
Expand Down
2 changes: 1 addition & 1 deletion src/director/director.h
Expand Up @@ -181,7 +181,7 @@ void director_sync_send(struct director *dir, struct director_host *host,
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);

Expand Down
2 changes: 1 addition & 1 deletion src/director/doveadm-connection.c
Expand Up @@ -261,7 +261,7 @@ doveadm_cmd_director_add(struct doveadm_connection *conn,

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;
Expand Down

0 comments on commit 2ff3217

Please sign in to comment.