Make openshift-dns deployment Python 3 compatible
The code used to configure openshift-dns was not compatible with Python
3 in terms of file operations. This commit fixes it by making sure files
are not opened in binary mode.
@@ -1068,6 +1068,7 @@ EOF
import os
import sys
import tempfile
+import traceback
import yaml
if len(sys.argv) < 3:
@@ -1086,7 +1087,7 @@ def dns_configure_copy(conf):
old_config = {}
while True:
- tp = tempfile.NamedTemporaryFile(dir=conf_dir, delete=False)
+ tp = tempfile.NamedTemporaryFile(dir=conf_dir, delete=False, mode='w')
try:
with open(node_conf_path) as node_conf:
current_conf = yaml.load(node_conf.read())
@@ -1102,7 +1103,8 @@ while True:
old_config = current_conf
tp.close()
os.unlink(tp.name)
- except Exception:
+ except Exception as e:
+ traceback.print_exc(file=sys.stdout)
tp.close()
os.unlink(tp.name)
EOF
@@ -1245,7 +1247,7 @@ def service_configure_registry_clusterIP(conf):
old_conf = {}
while True:
- tp = tempfile.NamedTemporaryFile(dir=conf_dir, delete=False)
+ tp = tempfile.NamedTemporaryFile(dir=conf_dir, delete=False, mode='w')
try:
with open(registry_conf_path) as registry_conf:
current_conf = yaml.load(registry_conf.read())
