|
|
b2bc38 |
From 88d6ceb18e17c5a18bafb5092ae0c22241b212df Mon Sep 17 00:00:00 2001
|
|
|
b2bc38 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
b2bc38 |
Date: Mon, 1 Nov 2021 14:01:11 -0400
|
|
|
b2bc38 |
Subject: [PATCH 08/12] Issue 4978 - make installer robust
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Description: When run in a container the server can fail to start
|
|
|
b2bc38 |
because the installer sets the db_home_dir to /dev/shm,
|
|
|
b2bc38 |
but in containers the default size of /dev/shm is too
|
|
|
b2bc38 |
small for libdb. We should detect if we are in a
|
|
|
b2bc38 |
container and not set db_home_dir to /dev/shm.
|
|
|
b2bc38 |
|
|
|
b2bc38 |
During instance removal, if an instance was not properly
|
|
|
b2bc38 |
created then it can not be removed either. Make the
|
|
|
b2bc38 |
uninstall more robust to accept some errors and continue
|
|
|
b2bc38 |
removing the instance.
|
|
|
b2bc38 |
|
|
|
b2bc38 |
relates: https://github.com/389ds/389-ds-base/issues/4978
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Reviewed by: firstyear & tbordaz(Thanks!)
|
|
|
b2bc38 |
---
|
|
|
b2bc38 |
src/lib389/lib389/instance/setup.py | 9 +++++++++
|
|
|
b2bc38 |
src/lib389/lib389/utils.py | 5 ++++-
|
|
|
b2bc38 |
2 files changed, 13 insertions(+), 1 deletion(-)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
index be6854af8..7b0147cf9 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
@@ -731,6 +731,15 @@ class SetupDs(object):
|
|
|
b2bc38 |
for line in template_dse.readlines():
|
|
|
b2bc38 |
dse += line.replace('%', '{', 1).replace('%', '}', 1)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
+ # Check if we are in a container, if so don't use /dev/shm for the db home dir
|
|
|
b2bc38 |
+ # as containers typically don't allocate enough space for dev/shm and we don't
|
|
|
b2bc38 |
+ # want to unexpectedly break the server after an upgrade
|
|
|
b2bc38 |
+ container_result = subprocess.run(["systemd-detect-virt", "-c"], capture_output=True)
|
|
|
b2bc38 |
+ if container_result.returncode == 0:
|
|
|
b2bc38 |
+ # In a container, set the db_home_dir to the db path
|
|
|
b2bc38 |
+ self.log.debug("Container detected setting db home directory to db directory.")
|
|
|
b2bc38 |
+ slapd['db_home_dir'] = slapd['db_dir']
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse:
|
|
|
b2bc38 |
dse_fmt = dse.format(
|
|
|
b2bc38 |
schema_dir=slapd['schema_dir'],
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
|
|
|
b2bc38 |
index 5ba0c6676..c63b4d0ee 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/utils.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/utils.py
|
|
|
b2bc38 |
@@ -266,6 +266,8 @@ def selinux_label_port(port, remove_label=False):
|
|
|
b2bc38 |
:type remove_label: boolean
|
|
|
b2bc38 |
:raises: ValueError: Error message
|
|
|
b2bc38 |
"""
|
|
|
b2bc38 |
+ if port is None:
|
|
|
b2bc38 |
+ return
|
|
|
b2bc38 |
try:
|
|
|
b2bc38 |
import selinux
|
|
|
b2bc38 |
except ImportError:
|
|
|
b2bc38 |
@@ -662,7 +664,8 @@ def isLocalHost(host_name):
|
|
|
b2bc38 |
Uses gethostbyname()
|
|
|
b2bc38 |
"""
|
|
|
b2bc38 |
# first see if this is a "well known" local hostname
|
|
|
b2bc38 |
- if host_name == 'localhost' or \
|
|
|
b2bc38 |
+ if host_name is None or \
|
|
|
b2bc38 |
+ host_name == 'localhost' or \
|
|
|
b2bc38 |
host_name == 'localhost.localdomain' or \
|
|
|
b2bc38 |
host_name == socket.gethostname():
|
|
|
b2bc38 |
return True
|
|
|
b2bc38 |
--
|
|
|
b2bc38 |
2.31.1
|
|
|
b2bc38 |
|