]> git.proxmox.com Git - mirror_corosync-qdevice.git/blame - qdevices/qnetd-log-debug.c
init: Fix init scripts to work with containers
[mirror_corosync-qdevice.git] / qdevices / qnetd-log-debug.c
CommitLineData
9a1955a7
JF
1/*
2 * Copyright (c) 2015-2017 Red Hat, Inc.
3 *
4 * All rights reserved.
5 *
6 * Author: Jan Friesse (jfriesse@redhat.com)
7 *
8 * This software licensed under BSD license, the text of which follows:
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the Red Hat, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include "qnetd-log.h"
36#include "qnetd-log-debug.h"
37#include "utils.h"
38
39void
40qnetd_log_debug_dump_cluster(struct qnetd_cluster *cluster)
41{
42 struct qnetd_client *client;
43
44 qnetd_log(LOG_DEBUG, " cluster dump:");
45 TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
46 qnetd_log(LOG_DEBUG, " client = %s, node_id = "UTILS_PRI_NODE_ID,
47 client->addr_str, client->node_id);
48 }
49}
50
51void
52qnetd_log_debug_new_client_connected(struct qnetd_client *client)
53{
54
55 qnetd_log(LOG_DEBUG, "New client connected");
56 qnetd_log(LOG_DEBUG, " cluster name = %s", client->cluster_name);
57 qnetd_log(LOG_DEBUG, " tls started = %u", client->tls_started);
58 qnetd_log(LOG_DEBUG, " tls peer certificate verified = %u",
59 client->tls_peer_certificate_verified);
60 qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID, client->node_id);
61 qnetd_log(LOG_DEBUG, " pointer = %p", client);
62 qnetd_log(LOG_DEBUG, " addr_str = %s", client->addr_str);
63 qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", client->last_ring_id.node_id,
64 client->last_ring_id.seq);
65
66 qnetd_log_debug_dump_cluster(client->cluster);
67}
68
69void
70qnetd_log_debug_dump_node_list(struct qnetd_client *client, const struct node_list *nodes)
71{
72 struct node_list_entry *node_info;
73
74 qnetd_log(LOG_DEBUG, " node list:");
75 TAILQ_FOREACH(node_info, nodes, entries) {
76 qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID", "
77 "data_center_id = "UTILS_PRI_DATACENTER_ID", "
78 "node_state = %s", node_info->node_id, node_info->data_center_id,
79 tlv_node_state_to_str(node_info->node_state));
80 }
81}
82
83void
84qnetd_log_debug_config_node_list_received(struct qnetd_client *client,
85 uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
86 const struct node_list *nodes, int initial)
87{
88
89 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
90 "sent %s node list.", client->addr_str, client->cluster_name, client->node_id,
91 (initial ? "initial" : "changed"));
92
93 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
94
95 if (config_version_set) {
96 qnetd_log(LOG_DEBUG, " config version = " UTILS_PRI_CONFIG_VERSION, config_version);
97 }
98
99 qnetd_log_debug_dump_node_list(client, nodes);
100}
101
102void
103qnetd_log_debug_membership_node_list_received(struct qnetd_client *client,
104 uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
105 enum tlv_heuristics heuristics, const struct node_list *nodes)
106{
107 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
108 "sent membership node list.", client->addr_str, client->cluster_name, client->node_id);
109
110 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
111
112 qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
113
114 qnetd_log(LOG_DEBUG, " heuristics = %s ", tlv_heuristics_to_str(heuristics));
115
116 qnetd_log_debug_dump_node_list(client, nodes);
117}
118
119void
120qnetd_log_debug_quorum_node_list_received(struct qnetd_client *client,
121 uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes)
122{
123
124 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
125 "sent quorum node list.", client->addr_str, client->cluster_name, client->node_id);
126
127 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
128 qnetd_log(LOG_DEBUG, " quorate = %u", quorate);
129
130 qnetd_log_debug_dump_node_list(client, nodes);
131}
132
133void
134qnetd_log_debug_client_disconnect(struct qnetd_client *client, int server_going_down)
135{
136
137 qnetd_log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
138 UTILS_PRI_NODE_ID") disconnect%s", client->addr_str, client->init_received,
139 client->cluster_name, client->node_id,
140 (server_going_down ? " (server is going down)" : ""));
141}
142
143void
144qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num)
145{
146
147 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
148 "asked for a vote", client->addr_str, client->cluster_name, client->node_id);
149 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
150}
151
152void
153qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
154{
155
156 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
157 "replied back to vote info message", client->addr_str, client->cluster_name,
158 client->node_id);
159 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
160}
161
162void
163qnetd_log_debug_send_vote_info(struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote vote)
164{
165
166 qnetd_log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
167 client->addr_str, client->cluster_name, client->node_id);
168 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
169 qnetd_log(LOG_DEBUG, " vote = %s", tlv_vote_to_str(vote));
170}
171
172void
173qnetd_log_debug_heuristics_change_received(struct qnetd_client *client, uint32_t msg_seq_num,
174 enum tlv_heuristics heuristics)
175{
176
177 qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
178 "sent heuristics change", client->addr_str, client->cluster_name, client->node_id);
179 qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
180 qnetd_log(LOG_DEBUG, " heuristics = %s", tlv_heuristics_to_str(heuristics));
181}