Fix a bug concerning TCP port release
authorDimitris Aragiorgis <dimara@grnet.gr>
Fri, 30 Mar 2012 09:47:14 +0000 (11:47 +0200)
committerMichael Hanselmann <hansmi@google.com>
Wed, 11 Apr 2012 16:14:57 +0000 (18:14 +0200)
commit2522b7c40826fdfea19b70999ef00b778049df86
tree67c080a40fd0652ce7c32d8fc77f4c0d8aef8262
parentb39d17b13021e61581ad6da4f54cbbd2ce2c4fcb
Fix a bug concerning TCP port release

Commit f396ad8 returns the TCP port used by DRBD disk back to the
TCP/UDP port pool using AddTcpUdpPort().

However, AddTcpUdpPort() writes the config on every invocation,
using _WriteConfig(). This causes two problems:

 * it causes critical errors logged by VerifyConfig(), after the DRBD
   disk removal, and until the actual instance removal.
 * if the code following AddTcpUdpPort() fails, the port is already
   returned back the pool, which causes the port to have duplicates
   (inconsistent config).

AddTcpUdpPort() is invoked in three cases:

 * during InstanceRemove() through _RemoveDisks().
 * during InstanceSetParams() in case of disk removal.
 * during InstanceSetParams() through _ConvertDrbdToPlain().

This commit fixes the problem by removing the _WriteConfig() call from
AddTcpUdpPort(), delegate it to Update() via the
TemporaryReservationManager and ensure AddTcpUdpPort() precedes
Update().

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
[iustin@google.com: small comments adjustements]
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
(cherry picked from commit 3b3b1bca566a005acd622a5b6e49528e5e3dbe85)
lib/cmdlib.py
lib/config.py