From 6dadcddc80458a833b15bd42e4d367988082f330 Mon Sep 17 00:00:00 2001 From: Karolis Eigelis Date: Thu, 20 Feb 2020 23:28:11 +0200 Subject: [PATCH 2/8] adding confluence access log --- config/server.xml.j2 | 2 ++ tests/test_image.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/server.xml.j2 b/config/server.xml.j2 index ecd5c90..b05651d 100644 --- a/config/server.xml.j2 +++ b/config/server.xml.j2 @@ -50,6 +50,8 @@ + + Date: Fri, 21 Feb 2020 14:24:46 +0200 Subject: [PATCH 3/8] adding ATL_ACCESS_LOG flag --- config/server.xml.j2 | 2 ++ tests/test_image.py | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/config/server.xml.j2 b/config/server.xml.j2 index b05651d..6dcb2cf 100644 --- a/config/server.xml.j2 +++ b/config/server.xml.j2 @@ -50,8 +50,10 @@ + {% if atl_access_log == 'true' %} + {% endif %} Date: Wed, 26 Feb 2020 10:12:18 +0200 Subject: [PATCH 4/8] align with the other tomcat configuration environment variables --- config/server.xml.j2 | 4 ++-- tests/test_image.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/server.xml.j2 b/config/server.xml.j2 index 6dcb2cf..6835b9a 100644 --- a/config/server.xml.j2 +++ b/config/server.xml.j2 @@ -50,9 +50,9 @@ - {% if atl_access_log == 'true' %} + {% if atl_tomcat_access_log == 'true' %} - + {% endif %} diff --git a/tests/test_image.py b/tests/test_image.py index f109b13..a9bd212 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -283,8 +283,8 @@ def test_confluence_xml_cluster_tcp(docker_cli, image, run_user): def test_confluence_xml_access_log(docker_cli, image, run_user): environment = { - 'ATL_ACCESS_LOG': 'true', - 'ATL_PROXY_INTERNAL_IPS': '192.168.1.1', + 'ATL_TOMCAT_ACCESS_LOG': 'true', + 'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1', } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) @@ -292,7 +292,7 @@ def test_confluence_xml_access_log(docker_cli, image, run_user): xml = parse_xml(container, f'{get_app_home(container)}/server.cfg.xml') valve = xml.find(".//Context/Valve[@className='org.apache.catalina.valves.RemoteIpValve']") - assert valve.get('internalProxies') == environment.get('ATL_PROXY_INTERNAL_IPS') + assert valve.get('internalProxies') == environment.get('ATL_TOMCAT_PROXY_INTERNAL_IPS') def test_java_in_run_user_path(docker_cli, image): RUN_USER = 'confluence' From ec4b4bcc4548d46d3639b3e66c120556ad90254b Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Fri, 28 Feb 2020 14:30:20 +1100 Subject: [PATCH 5/8] Add README entry about new setting and misc. formatting cleanups. --- README.md | 9 +++++++++ config/server.xml.j2 | 16 ++++++++++++++-- tests/test_image.py | 26 +++++++++++++------------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a22272e..79ac662 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,15 @@ 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) + + Whether to enable Tomcat access logging; set to `true` to enable. *NOTE*: + These logs are written to the Container internal volume by default (under + `/opt/atlassian/confluence/logs/`); these are rotated but not removed, and + will grow indefinitely. If you enable this functionality it is recommended + that you map the directory to a volume and perform log ingestion/cleanup with + external tools. + The following Tomcat/Catalina options are also supported. For more information, see https://tomcat.apache.org/tomcat-7.0-doc/config/index.html. diff --git a/config/server.xml.j2 b/config/server.xml.j2 index 6835b9a..941a7f2 100644 --- a/config/server.xml.j2 +++ b/config/server.xml.j2 @@ -51,8 +51,20 @@ {% if atl_tomcat_access_log == 'true' %} - - + + {% endif %} diff --git a/tests/test_image.py b/tests/test_image.py index a9bd212..77d0d73 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -14,10 +14,10 @@ def test_jvm_args(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + procs_list = get_procs(container) jvm = [proc for proc in procs_list if get_bootstrap_proc(container) in proc][0] - + assert f'-Xms{environment.get("JVM_MINIMUM_MEMORY")}' in jvm assert f'-Xmx{environment.get("JVM_MAXIMUM_MEMORY")}' in jvm assert f'-XX:ReservedCodeCacheSize={environment.get("JVM_RESERVED_CODE_CACHE_SIZE")}' in jvm @@ -37,9 +37,9 @@ def test_install_permissions(docker_cli, image): def test_first_run_state(docker_cli, image, run_user): PORT = 8090 URL = f'http://localhost:{PORT}/status' - + container = run_image(docker_cli, image, user=run_user, ports={PORT: PORT}) - + wait_for_http_response(URL, expected_status=200, expected_state=('STARTING', 'FIRST_RUN')) @@ -50,7 +50,7 @@ def test_server_xml_defaults(docker_cli, image): xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml') connector = xml.find('.//Connector') context = xml.find('.//Context') - + assert connector.get('port') == '8090' assert connector.get('maxThreads') == '100' assert connector.get('minSpareThreads') == '10' @@ -62,7 +62,7 @@ def test_server_xml_defaults(docker_cli, image): assert connector.get('scheme') == 'http' assert connector.get('proxyName') == '' assert connector.get('proxyPort') == '' - + def test_server_xml_catalina_fallback(docker_cli, image): environment = { 'CATALINA_CONNECTOR_PROXYNAME': 'PROXYNAME', @@ -107,7 +107,7 @@ def test_server_xml_params(docker_cli, image): xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml') connector = xml.find('.//Connector') context = xml.find('.//Context') - + assert xml.get('port') == environment.get('ATL_TOMCAT_MGMT_PORT') assert connector.get('port') == environment.get('ATL_TOMCAT_PORT') @@ -168,7 +168,7 @@ def test_confluence_xml_postgres(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml') assert xml.findall('.//property[@name="hibernate.connection.url"]')[0].text == "atl_jdbc_url" assert xml.findall('.//property[@name="hibernate.connection.username"]')[0].text == "atl_jdbc_user" @@ -231,7 +231,7 @@ def test_confluence_xml_cluster_aws(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml') assert xml.findall('.//property[@name="confluence.cluster"]')[0].text == "true" @@ -255,7 +255,7 @@ def test_confluence_xml_cluster_multicast(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml') assert xml.findall('.//property[@name="confluence.cluster"]')[0].text == "true" @@ -273,7 +273,7 @@ def test_confluence_xml_cluster_tcp(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml') assert xml.findall('.//property[@name="confluence.cluster"]')[0].text == "true" @@ -288,7 +288,7 @@ def test_confluence_xml_access_log(docker_cli, image, run_user): } container = run_image(docker_cli, image, user=run_user, environment=environment) _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - + xml = parse_xml(container, f'{get_app_home(container)}/server.cfg.xml') valve = xml.find(".//Context/Valve[@className='org.apache.catalina.valves.RemoteIpValve']") @@ -305,4 +305,4 @@ def test_non_root_user(docker_cli, image): RUN_UID = 2002 RUN_GID = 2002 container = run_image(docker_cli, image, user=f'{RUN_UID}:{RUN_GID}') - jvm = wait_for_proc(container, "org.apache.catalina.startup.Bootstrap") \ No newline at end of file + jvm = wait_for_proc(container, "org.apache.catalina.startup.Bootstrap") From 1247e1abdb5bb809a9d4a6e7f6ce2f5f006574f2 Mon Sep 17 00:00:00 2001 From: Ben Partridge Date: Tue, 3 Mar 2020 16:29:09 +1100 Subject: [PATCH 6/8] Fix xml access log test using incorrect path to server.xml and running as confluence user --- tests/test_image.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/test_image.py b/tests/test_image.py index 77d0d73..16575b0 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -124,6 +124,18 @@ 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): + environment = { + 'ATL_TOMCAT_ACCESS_LOG': 'true', + 'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1', + } + + 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') def test_seraph_defaults(docker_cli, image): container = run_image(docker_cli, image) @@ -281,19 +293,6 @@ def test_confluence_xml_cluster_tcp(docker_cli, image, run_user): assert xml.findall('.//property[@name="confluence.cluster.name"]')[0].text == "atl_cluster_name" assert xml.findall('.//property[@name="confluence.cluster.peers"]')[0].text == "1.1.1.1,99.99.99.99" -def test_confluence_xml_access_log(docker_cli, image, run_user): - environment = { - 'ATL_TOMCAT_ACCESS_LOG': 'true', - 'ATL_TOMCAT_PROXY_INTERNAL_IPS': '192.168.1.1', - } - container = run_image(docker_cli, image, user=run_user, environment=environment) - _jvm = wait_for_proc(container, get_bootstrap_proc(container)) - - xml = parse_xml(container, f'{get_app_home(container)}/server.cfg.xml') - valve = xml.find(".//Context/Valve[@className='org.apache.catalina.valves.RemoteIpValve']") - - assert valve.get('internalProxies') == environment.get('ATL_TOMCAT_PROXY_INTERNAL_IPS') - def test_java_in_run_user_path(docker_cli, image): RUN_USER = 'confluence' container = run_image(docker_cli, image) From f9817df3950a732a0d37ecbc252df9e2a7144be4 Mon Sep 17 00:00:00 2001 From: Ben Partridge Date: Tue, 3 Mar 2020 16:34:39 +1100 Subject: [PATCH 7/8] Add contributing guidelines to README --- CONTRIBUTING.md | 7 +++++++ README.md | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..34d4ff5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +If you are contributing from outside Atlassian, make sure you have signed the [Atlassian CLA](https://developer.atlassian.com/platform/open-source/contributor-license-agreement/) + +If you are contributing from an external fork, please target your pull request at the `forked-contributions-target` branch. We will perform a preliminary code review +in this pull request, then merge to this branch. Once the code has been merged into `forked-contributions-target` our pipeline will run our tests against it. Once +the tests pass, your contribution will be merged into `master`. diff --git a/README.md b/README.md index 79ac662..255cd21 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,10 @@ Note that these images are built on the [AdoptOpenJDK](https://adoptopenjdk.net/ Confluence 6.13 OpenJDK was not a supported platform. See [the 6.13 release-notes][12] for more information. +# Contribution + +See the [contributing guideline](CONTRIBUTING.md) if you are contributing from outside Atlassian. + # License Copyright © 2020 Atlassian Corporation Pty Ltd. From 4bebf05a1e0dba29052e68fab9215e15b2539ad3 Mon Sep 17 00:00:00 2001 From: Dave Chevell Date: Wed, 4 Mar 2020 09:37:04 +1100 Subject: [PATCH 8/8] Tidying up --- tests/test_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_image.py b/tests/test_image.py index 16575b0..3cfdb59 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -304,4 +304,4 @@ def test_non_root_user(docker_cli, image): RUN_UID = 2002 RUN_GID = 2002 container = run_image(docker_cli, image, user=f'{RUN_UID}:{RUN_GID}') - jvm = wait_for_proc(container, "org.apache.catalina.startup.Bootstrap") + _jvm = wait_for_proc(container, get_bootstrap_proc(container))