Skip to content

Commit 688243f

Browse files
authored
Merge pull request #10 from innogames/ndco_1856
Send wanted state instead of real state to pfctl_worker
2 parents 1494bec + e328402 commit 688243f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/pfctl.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,12 @@ bool pf_sync_table(string table, SyncedLbNode *synced_lb_nodes) {
238238
for (int i = 0; i < MAX_NODES; i++) {
239239
for (int proto = 0; proto < 2; proto++) {
240240
if (strlen(synced_lb_nodes[i].ip_address[proto]) &&
241-
synced_lb_nodes[i].state == LbNodeState::STATE_UP &&
241+
synced_lb_nodes[i].wanted_state == LbNodeState::STATE_UP &&
242242
synced_lb_nodes[i].admin_state == LbNodeAdminState::STATE_ENABLED) {
243243
want_set.insert(string(synced_lb_nodes[i].ip_address[proto]));
244+
log(MessageType::MSG_INFO,
245+
fmt::sprintf("pfctl: Wanted node %s",
246+
synced_lb_nodes[i].ip_address[proto]));
244247
}
245248
}
246249
}

src/pfctl_worker.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,18 @@ bool send_message(message_queue *mq, string pool_name, string table_name,
175175
// as the later one includes calculation of min_ and max_nodes and
176176
// backup_pools.
177177
if (up_lb_nodes.count(lb_node)) {
178-
msg.synced_lb_nodes[lb_node_index].state = LbNodeState::STATE_UP;
178+
log(MessageType::MSG_INFO, lb_node,
179+
fmt::sprintf(
180+
"Syncing lb_node with wanted state up admin_state %s state %s",
181+
lb_node->get_admin_state_string(), lb_node->get_state_string()));
182+
msg.synced_lb_nodes[lb_node_index].wanted_state = LbNodeState::STATE_UP;
179183
} else {
180-
msg.synced_lb_nodes[lb_node_index].state = lb_node->state;
184+
log(MessageType::MSG_INFO, lb_node,
185+
fmt::sprintf("Syncing lb_node with wanted state down "
186+
"admin_state %s state %s",
187+
lb_node->get_admin_state_string(),
188+
lb_node->get_state_string()));
189+
msg.synced_lb_nodes[lb_node_index].wanted_state = LbNodeState::STATE_DOWN;
181190
}
182191

183192
// Pass information on if node is to be removed with or without killing

src/pfctl_worker.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool send_message(message_queue *mq, string pool_name, string table_name,
3131
set<LbNode *> all_lb_nodes, set<LbNode *> up_lb_nodes);
3232

3333
typedef struct {
34-
LbNodeState state; // To add or remove LB Node from table.
34+
LbNodeState wanted_state; // To add or remove LB Node from table.
3535
LbNodeAdminState admin_state; // How to remove LB Node from table.
3636
// IPv4 and IPv6 addresses.
3737
char ip_address[2][ADDR_LEN];

0 commit comments

Comments
 (0)