]> git.proxmox.com Git - pve-cluster.git/commit
pvecm: add/delete: local lock & avoid problems on first node addition
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 23 Nov 2017 11:12:05 +0000 (12:12 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Nov 2017 08:10:54 +0000 (09:10 +0100)
commit9db3f0c0c17e0145dc2696e7fee46fd1604a52e7
tree64101d8ce94c58ac69736ecf0ba135673ef0c95f
parent6bd852fa7298cbea0006610783ac0a9b1963d3d2
pvecm: add/delete: local lock & avoid problems on first node addition

cfs_lock is per node, thus we had a possibility for a node addition
race if the process was started on the same node (e.g. by a
script/ansible/...).

So always request a local lock first, if that is acquired check how
many members currently reside in the cluster and then decide if we
can directly execute the code (single node cluster = no contenders)
or must hold the lock.

One may think that there remains a race when adding a node to single
node cluster, i.e., once the node is added it may itself be a target
for another joining node. But this cannot happen as we only tell the
joining node that it could be added once we already *have* added it
locally.

Besides the defense against a race if two user execute a node
addition to the same node at the same time, this also addresses a
issue where the cluster lock could not be removed after writing the
corosync conf, as pmxcfs and corosync triggered an config reload and
added the new node, which itself did not yet know that it was
accepted in the cluster. Thus, the former single node cluster expects
two nodes but has only one for now, until the other node pulled the
config and authkey and started up its cluster stack.

That resulted in a failing removal of the corosync lock, thus adding
another node did not work until this lock timed out (~2 minutes).

While often node additions are separated by more than 2 minutes time
intervall, deployment helpers (or fast admins, for that matter) may
trigger this easily.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/CLI/pvecm.pm