Merged in DCD-1467-optional-config-updates (pull request #116)

DCD-1467: Add flag to force overwrite of existing config files where appropriate

Approved-by: Jun Jeong
Approved-by: Adam Brokes
Approved-by: Dylan Rathbone
This commit is contained in:
Steve Smith 2022-04-22 00:59:15 +00:00
commit c69af410fa
4 changed files with 72 additions and 3 deletions

View File

@ -297,6 +297,21 @@ management technology, and is beyond the scope of this documentation.
## Container Configuration
* `ATL_FORCE_CFG_UPDATE` (default: false)
The Docker [entrypoint](entrypoint.py) generates application configuration on
first start; not all of these files are regenerated on subsequent
starts. This is deliberate, to avoid race conditions or overwriting manual
changes during restarts and upgrades. However in deployments where
configuration is purely specified through the environment (e.g. Kubernetes)
this behaviour may be undesirable; this flag forces an update of all
generated files.
In Confluence the affected files are: `confluence.cfg.xml`
See [the entrypoint code](entrypoint.py) for the details of how configuration
files are generated.
* `SET_PERMISSIONS` (default: true)
Define whether to set home directory permissions on startup. Set to `false` to disable

View File

@ -1,12 +1,13 @@
#!/usr/bin/python3 -B
from entrypoint_helpers import env, gen_cfg, str2bool, exec_app
from entrypoint_helpers import env, gen_cfg, str2bool_or, exec_app
RUN_USER = env['run_user']
RUN_GROUP = env['run_group']
CONFLUENCE_INSTALL_DIR = env['confluence_install_dir']
CONFLUENCE_HOME = env['confluence_home']
UPDATE_CFG = str2bool_or(env.get('atl_force_cfg_update'), False)
gen_cfg('server.xml.j2', f'{CONFLUENCE_INSTALL_DIR}/conf/server.xml')
gen_cfg('seraph-config.xml.j2',
@ -14,7 +15,7 @@ gen_cfg('seraph-config.xml.j2',
gen_cfg('confluence-init.properties.j2',
f'{CONFLUENCE_INSTALL_DIR}/confluence/WEB-INF/classes/confluence-init.properties')
gen_cfg('confluence.cfg.xml.j2', f'{CONFLUENCE_HOME}/confluence.cfg.xml',
user=RUN_USER, group=RUN_GROUP, overwrite=False)
user=RUN_USER, group=RUN_GROUP, overwrite=UPDATE_CFG)
exec_app([f'{CONFLUENCE_INSTALL_DIR}/bin/start-confluence.sh', '-fg'], CONFLUENCE_HOME,
name='Confluence', env_cleanup=True)

@ -1 +1 @@
Subproject commit 8447826407728bd5fd85e0fc3521cb5fcdf8cd41
Subproject commit 52cd98f0136e31e69b2e75a35f81e315d646cf82

View File

@ -443,3 +443,56 @@ def test_confluence_xml_snapshot_properties(docker_cli, image, run_user):
assert xml.findall('.//setupType')[0].text == "clustersetup"
assert xml.findall('.//buildNumber')[0].text == "8703"
assert xml.findall('.//property[@name="hibernate.setup"]')[0].text == "true"
def test_confluence_xml_no_overwrite(docker_cli, image, run_user):
environment = {
'ATL_TOMCAT_CONTEXTPATH': 'myconf',
}
container = docker_cli.containers.run(image, detach=True, user=run_user, environment=environment)
tihost = testinfra.get_host("docker://"+container.id)
cfg = f'{get_app_home(tihost)}/confluence.cfg.xml'
_jvm = wait_for_proc(tihost, get_bootstrap_proc(tihost))
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/myconf"
container.exec_run(f"sed -i 's/myconf/otherval/' {cfg}")
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/otherval"
container.restart(timeout=60)
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/otherval"
def test_confluence_xml_force_overwrite(docker_cli, image, run_user):
environment = {
'ATL_TOMCAT_CONTEXTPATH': 'myconf',
'ATL_FORCE_CFG_UPDATE': 'y',
}
container = docker_cli.containers.run(image, detach=True, user=run_user, environment=environment)
tihost = testinfra.get_host("docker://"+container.id)
cfg = f'{get_app_home(tihost)}/confluence.cfg.xml'
_jvm = wait_for_proc(tihost, get_bootstrap_proc(tihost))
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/myconf"
container.exec_run(f"sed -i 's/myconf/otherval/' {cfg}")
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/otherval"
container.stop(timeout=60)
container.start()
_jvm = wait_for_proc(tihost, get_bootstrap_proc(tihost))
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/myconf"