--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, comment added at end, new deleted node"
+
+setup_nodes <<EOF
+192.168.20.41
+192.168.20.42
+192.168.20.43
+# Adding a comment!
+EOF
+
+setup_ctdbd <<EOF
+NODEMAP
+0 192.168.20.41 0x0 CURRENT RECMASTER
+1 192.168.20.42 0x0
+2 192.168.20.43 0x0
+EOF
+
+ok <<EOF
+Node 3 is NEW
+EOF
+simple_test
+
+ok <<EOF
+Number of nodes:4 (including 1 deleted nodes)
+pnn:0 192.168.20.41 OK (THIS NODE)
+pnn:1 192.168.20.42 OK
+pnn:2 192.168.20.43 OK
+EOF
+simple_test_other nodestatus all
}
for (i=0; i<nodemap->num; i++) {
- struct node *node;
+ struct node *node = NULL;
+ ctdb_sock_addr zero = {};
+ int ret;
+
+ ret = ctdb_sock_addr_from_string("0.0.0.0", &zero, false);
+ if (ret != 0) {
+ /* Can't happen, but Coverity... */
+ goto fail;
+ }
if (i < node_map->num_nodes &&
ctdb_sock_addr_same(&nodemap->node[i].addr,
continue;
}
- if (nodemap->node[i].flags & NODE_FLAGS_DELETED) {
- int ret;
-
+ if (i < node_map->num_nodes &&
+ nodemap->node[i].flags & NODE_FLAGS_DELETED) {
node = &node_map->node[i];
node->flags |= NODE_FLAGS_DELETED;
- ret = ctdb_sock_addr_from_string("0.0.0.0", &node->addr,
- false);
- if (ret != 0) {
- /* Can't happen, but Coverity... */
- goto fail;
- }
+ node->addr = zero;
continue;
}
node->addr = nodemap->node[i].addr;
node->pnn = nodemap->node[i].pnn;
- node->flags = 0;
+ if (ctdb_sock_addr_same_ip(&node->addr, &zero)) {
+ node->flags = NODE_FLAGS_DELETED;
+ } else {
+ node->flags = 0;
+ }
node->capabilities = CTDB_CAP_DEFAULT;
node->recovery_disabled = false;
node->recovery_substate = NULL;