Module: check_mk
Branch: master
Commit: 8ae53624a16c240bba4017be07f8831a2beffd0c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8ae53624a16c24…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 13 09:58:24 2017 +0100
5435 FIX Fixed "omd update" problems when updating from 1.4.0p17 or older
When executing "omd update" as site user to update a site from 1.4.0p17
or older an error could occur blocking the update. The message looks like
this:
<pre>
Traceback (most recent call last):
File "/omd/versions/1.4.0p17.cee/bin/omd", line 52, in <module>
import tarfile, fnmatch
File "/omd/versions/1.4.0p17.cee/lib/python2.7/tarfile.py", line 52, in
<module>
import copy
File "/omd/versions/1.4.0p17.cee/lib/python2.7/copy.py", line 52, in
<module>
import weakref
File "/omd/versions/1.4.0p17.cee/lib/python2.7/weakref.py", line 14, in
<module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
</pre>
This issue was caused by a mixup of python versions during the update which has
been fixed now by using the correct libraries during the update.
To workaround this issue, you could run the "omd update" command as root user
instead
of the site user.
Change-Id: I09048fcc4151b4ba189db8c4890d5646f0b51f36
---
.werks/5435 | 31 +++++++++++++++++++++++++++++++
omd/packages/omd/omd | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/.werks/5435 b/.werks/5435
new file mode 100644
index 0000000..7f84903
--- /dev/null
+++ b/.werks/5435
@@ -0,0 +1,31 @@
+Title: Fixed "omd update" problems when updating from 1.4.0p17 or older
+Level: 2
+Component: omd
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1510563044
+Class: fix
+
+When executing "omd update" as site user to update a site from 1.4.0p17
+or older an error could occur blocking the update. The message looks like
+this:
+
+<pre>
+Traceback (most recent call last):
+ File "/omd/versions/1.4.0p17.cee/bin/omd", line 52, in <module>
+ import tarfile, fnmatch
+ File "/omd/versions/1.4.0p17.cee/lib/python2.7/tarfile.py", line 52, in
<module>
+ import copy
+ File "/omd/versions/1.4.0p17.cee/lib/python2.7/copy.py", line 52, in
<module>
+ import weakref
+ File "/omd/versions/1.4.0p17.cee/lib/python2.7/weakref.py", line 14, in
<module>
+ from _weakref import (
+ImportError: cannot import name _remove_dead_weakref
+</pre>
+
+This issue was caused by a mixup of python versions during the update which has
+been fixed now by using the correct libraries during the update.
+
+To workaround this issue, you could run the "omd update" command as root user
instead
+of the site user.
diff --git a/omd/packages/omd/omd b/omd/packages/omd/omd
index cca5b31..edd16cc 100644
--- a/omd/packages/omd/omd
+++ b/omd/packages/omd/omd
@@ -24,6 +24,31 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# This hack here is needed to prevent "omd update" problems when updating
+# as site user from 1.4 versions older than 1.4.0p17.
+# Previous versios did not unset PYTHONPATH/LD_LIBRARY_PATH before execv()
+# to the newer version "omd" command which made the newer OMD load the old
+# python libraries. Newer versions unset these variables before, so this
+# additional execv() is only needed when updating from older versions.
+import os, sys
+if sys.argv[1] == "update" and sys.version_info[2] != 14:
+ # Prevent inheriting environment variables from this versions/site environment
+ # into the execed omd call. The OMD call must import the python version related
+ # modules and libaries. This only works when PYTHONPATH and LD_LIBRARY_PATH are
+ # not already set when calling "omd update"
+ try:
+ del os.environ["PYTHONPATH"]
+ except KeyError:
+ pass
+
+ try:
+ del os.environ["LD_LIBRARY_PATH"]
+ except KeyError:
+ pass
+ os.execv(sys.argv[0], sys.argv)
+ bail_out("Cannot run execv() %s" % sys.argv[0])
+
+
import sys, os, shutil, pwd, grp, re, time, pprint, tty, termios, traceback
import string
import random
@@ -4021,6 +4046,21 @@ def exec_other_omd(version):
# Rerun with omd of other version
omd_path = "/omd/versions/%s/bin/omd" % version
if os.path.exists(omd_path):
+ if command == "update":
+ # Prevent inheriting environment variables from this versions/site
environment
+ # into the execed omd call. The OMD call must import the python version
related
+ # modules and libaries. This only works when PYTHONPATH and LD_LIBRARY_PATH
are
+ # not already set when calling "omd update"
+ try:
+ del os.environ["PYTHONPATH"]
+ except KeyError:
+ pass
+
+ try:
+ del os.environ["LD_LIBRARY_PATH"]
+ except KeyError:
+ pass
+
os.execv(omd_path, sys.argv)
bail_out("Cannot run bin/omd of version %s." % version)
else: