Merged in DCD-1369-log-access (pull request #110)

DCD-1369 log access

Approved-by: Jun Jeong
Approved-by: Dylan Rathbone
This commit is contained in:
Nasser Ghazali-Beiklar 2022-01-17 03:05:01 +00:00
commit 7de9c96941
4 changed files with 51 additions and 7 deletions

View File

@ -33,6 +33,8 @@ RUN apt-get update \
ARG CONFLUENCE_VERSION
ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-${CONFLUENCE_VERSION}.tar.gz
ENV CONFLUENCE_VERSION ${CONFLUENCE_VERSION}
RUN groupadd --gid ${RUN_GID} ${RUN_GROUP} \
&& useradd --uid ${RUN_UID} --gid ${RUN_GID} --home-dir ${CONFLUENCE_HOME} --shell /bin/bash ${RUN_USER} \
&& echo PATH=$PATH > /etc/environment \

View File

@ -115,7 +115,7 @@ of the setup. They can be controlled via the below environment variables.
The context path the application is served over. `CATALINA_CONTEXT_PATH` is
also supported for backwards compatability.
* `ATL_TOMCAT_ACCESS_LOG` (default: false)
* `ATL_TOMCAT_ACCESS_LOG` (default: false [version < 7.11.0] and true [version >=7.11.0])
Whether to enable Tomcat access logging; set to `true` to enable. *NOTE*:
These logs are written to the Container internal volume by default (under

View File

@ -21,8 +21,6 @@
proxyPort="{{ atl_proxy_port | default(catalina_connector_proxyport) | default('') }}"
maxHttpHeaderSize="{{ atl_tomcat_maxhttpheadersize | default('8192') }}" />
<Engine name="Standalone"
defaultHost="localhost"
debug="0">
@ -41,7 +39,8 @@
<Manager pathname=""/>
<Valve className="org.apache.catalina.valves.StuckThreadDetectionValve"
threshold="60"/>
{% if atl_tomcat_access_log == 'true' %}
{% if ((atl_tomcat_access_log == 'true') or
(atl_tomcat_access_log is not defined and (confluence_version.split('.') | map('int') | list) >= ('7.11.0'.split('.') | map('int') | list)) ) %}
<Valve className="org.apache.catalina.valves.AccessLogValve"
requestAttributesEnabled="true"
directory="logs"

View File

@ -162,18 +162,61 @@ def test_server_xml_params(docker_cli, image):
assert context.get('path') == environment.get('ATL_TOMCAT_CONTEXTPATH')
def test_server_xml_access_log(docker_cli, image):
def test_server_xml_access_log_enabled(docker_cli, image):
environment = {
'ATL_TOMCAT_ACCESS_LOG': 'true',
'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1',
'CONFLUENCE_VERSION': '7.10.0',
}
container = run_image(docker_cli, image, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
valve = xml.find('.//Context/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]')
assert valve.get('internalProxies') == environment.get('ATL_TOMCAT_PROXY_INTERNAL_IPS')
value = xml.find('.//Context/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]')
assert value.get('internalProxies') == environment.get('ATL_TOMCAT_PROXY_INTERNAL_IPS')
def test_server_xml_access_log_disabled(docker_cli, image):
environment = {
'ATL_TOMCAT_ACCESS_LOG': 'false',
'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1',
'CONFLUENCE_VERSION': '7.12.0',
}
container = run_image(docker_cli, image, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
value = xml.find('.//Context/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]')
assert value is None
def test_server_xml_access_log_default_ver_lt_7_11(docker_cli, image):
environment = {
#'ATL_TOMCAT_ACCESS_LOG': Not defined,
'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1',
'CONFLUENCE_VERSION': "7.10.0",
}
container = run_image(docker_cli, image, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
value = xml.find('.//Context/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]')
assert value is None
def test_server_xml_access_log_default_ver_gt_7_11(docker_cli, image):
environment = {
#'ATL_TOMCAT_ACCESS_LOG': Not defined,
'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1',
'CONFLUENCE_VERSION': '7.12.0',
}
container = run_image(docker_cli, image, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
value = xml.find('.//Context/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]')
assert value.get('internalProxies') == environment.get('ATL_TOMCAT_PROXY_INTERNAL_IPS')
def test_seraph_defaults(docker_cli, image):
container = run_image(docker_cli, image)