Commit 645bba3a authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

If possible, replace symbolic links in place



Naive 'ln -s -f a b' will put the link inside 'b', if
'b' is (a symlink to) a directory; so, during upgrades,
the links in $(sysconfdir) cannot be updated this way.
Removing and readding works, however leaves the risk
of the upgrade process dying in that very moment, thus
leaving 'gnt-cluster' a dangling link, so that the --resume
option is of no help. On GNU systems, avoid this problem
by using the -T option of GNU ln.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent d250bc5d
......@@ -1723,16 +1723,26 @@ def _SetGanetiVersion(versionstring):
"""
failed = []
failed.extend(_VerifyCommand(
["rm", "-f", os.path.join(pathutils.SYSCONFDIR, "ganeti/lib")]))
failed.extend(_VerifyCommand(
["ln", "-s", "-f", os.path.join(pathutils.PKGLIBDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/lib")]))
failed.extend(_VerifyCommand(
["rm", "-f", os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]))
failed.extend(_VerifyCommand(
["ln", "-s", "-f", os.path.join(pathutils.SHAREDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]))
if constants.HAS_GNU_LN:
failed.extend(_VerifyCommand(
["ln", "-s", "-f", "-T",
os.path.join(pathutils.PKGLIBDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/lib")]))
failed.extend(_VerifyCommand(
["ln", "-s", "-f", "-T",
os.path.join(pathutils.SHAREDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]))
else:
failed.extend(_VerifyCommand(
["rm", "-f", os.path.join(pathutils.SYSCONFDIR, "ganeti/lib")]))
failed.extend(_VerifyCommand(
["ln", "-s", "-f", os.path.join(pathutils.PKGLIBDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/lib")]))
failed.extend(_VerifyCommand(
["rm", "-f", os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]))
failed.extend(_VerifyCommand(
["ln", "-s", "-f", os.path.join(pathutils.SHAREDIR, versionstring),
os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]))
return list(set(failed))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment