From 02afc19f661e31bb18fd83898deddac5e55b41e3 Mon Sep 17 00:00:00 2001 From: Rob Bavey Date: Tue, 23 Nov 2021 11:09:29 -0500 Subject: [PATCH 1/3] Update logstash docker to use ubuntu 20.04 base image --- docker/templates/Dockerfile.j2 | 33 ++++++++++----------------- qa/docker/spec/full/container_spec.rb | 15 ++++++++++++ qa/docker/spec/oss/container_spec.rb | 15 ++++++++++++ 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/docker/templates/Dockerfile.j2 b/docker/templates/Dockerfile.j2 index 7a3159ae0f1..12f2667436e 100644 --- a/docker/templates/Dockerfile.j2 +++ b/docker/templates/Dockerfile.j2 @@ -19,33 +19,24 @@ # Minimal distributions do not ship with en language packs. {% set locale = 'C.UTF-8' -%} {% else -%} - {% set base_image = 'centos:7' -%} - {% set package_manager = 'yum' -%} + {% set base_image = 'ubuntu:20.04' -%} + {% set package_manager = 'apt-get' -%} {% set locale = 'en_US.UTF-8' -%} {% endif -%} FROM {{ base_image }} -# Install Java and the "which" command, which is needed by Logstash's shell -# scripts. -# Minimal distributions also require findutils tar gzip (procps for integration tests) - -# on aarch64, yum does not pick the right `bind-license` package for some reason -# here we install a specific noarch RPM. -{% if arch == 'aarch64' -%} -RUN for iter in {1..10}; do {{ package_manager }} install -y http://mirror.centos.org/centos/7/updates/x86_64/Packages/bind-license-9.11.4-26.P2.el7_9.5.noarch.rpm && \ - {{ package_manager }} clean all && \ - {{ package_manager }} clean metadata && \ - exit_code=0 && break || exit_code=$? && \ - echo "packaging error: retry $iter in 10s" && \ - {{ package_manager }} clean all && \ - {{ package_manager }} clean metadata && sleep 10; done; \ - (exit $exit_code) - +RUN for iter in {1..10}; do \ +{% if image_flavor != 'ubi8' -%} + export DEBIAN_FRONTEND=noninteractive && \ {% endif -%} -RUN for iter in {1..10}; do {{ package_manager }} update -y && \ - {{ package_manager }} install -y procps findutils tar gzip which shadow-utils && \ + {{ package_manager }} update -y && \ + {{ package_manager }} upgrade -y && \ + {{ package_manager }} install -y procps findutils tar gzip curl && \ +{% if image_flavor == 'ubi8' -%} + {{ package_manager }} install -y which shadow-utils && \ +{% endif -%} {{ package_manager }} clean all && \ {% if image_flavor != 'ubi8' -%} {{ package_manager }} clean metadata && \ @@ -62,7 +53,7 @@ RUN for iter in {1..10}; do {{ package_manager }} update -y && \ # Provide a non-root user to run the process. RUN groupadd --gid 1000 logstash && \ adduser --uid 1000 --gid 1000 \ - --home-dir /usr/share/logstash --no-create-home \ + --home /usr/share/logstash --no-create-home \ logstash # Add Logstash itself. diff --git a/qa/docker/spec/full/container_spec.rb b/qa/docker/spec/full/container_spec.rb index 797f1c2ba3e..da30715b7b4 100644 --- a/qa/docker/spec/full/container_spec.rb +++ b/qa/docker/spec/full/container_spec.rb @@ -9,4 +9,19 @@ it_behaves_like 'it runs with different configurations', 'full' it_behaves_like 'it applies settings correctly', 'full' it_behaves_like 'a container with xpack features', 'full' + + context 'The running container' do + before do + @image = find_image('full') + @container = start_container(@image, {}) + end + + after do + cleanup_container(@container) + end + + it 'has an Ubunto 20.04 base image' do + expect(exec_in_container(@container, 'cat /etc/os-release').chomp).to match /Ubuntu 20.04/ + end + end end \ No newline at end of file diff --git a/qa/docker/spec/oss/container_spec.rb b/qa/docker/spec/oss/container_spec.rb index d3662f44bc5..cfa2da1b78f 100644 --- a/qa/docker/spec/oss/container_spec.rb +++ b/qa/docker/spec/oss/container_spec.rb @@ -7,4 +7,19 @@ it_behaves_like 'the container is configured correctly', 'oss' it_behaves_like 'it applies settings correctly', 'oss' it_behaves_like 'it runs with different configurations', 'oss' + + context 'The running container' do + before do + @image = find_image('oss') + @container = start_container(@image, {}) + end + + after do + cleanup_container(@container) + end + + it 'has an Ubunto 20.04 base image' do + expect(exec_in_container(@container, 'cat /etc/os-release').chomp).to match /Ubuntu 20.04/ + end + end end \ No newline at end of file From 1588dfc1eedc845f0e6b2095d4ecd3421c4fadb5 Mon Sep 17 00:00:00 2001 From: Rob Bavey Date: Wed, 8 Dec 2021 11:33:40 -0500 Subject: [PATCH 2/3] Correctly set locale for ubuntu docker image --- docker/templates/Dockerfile.j2 | 4 +++- qa/docker/shared_examples/container.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docker/templates/Dockerfile.j2 b/docker/templates/Dockerfile.j2 index 12f2667436e..1b38cc958ea 100644 --- a/docker/templates/Dockerfile.j2 +++ b/docker/templates/Dockerfile.j2 @@ -30,15 +30,17 @@ RUN for iter in {1..10}; do \ {% if image_flavor != 'ubi8' -%} export DEBIAN_FRONTEND=noninteractive && \ {% endif -%} - {{ package_manager }} update -y && \ {{ package_manager }} upgrade -y && \ {{ package_manager }} install -y procps findutils tar gzip curl && \ {% if image_flavor == 'ubi8' -%} {{ package_manager }} install -y which shadow-utils && \ +{% else -%} + {{ package_manager }} install -y locales && \ {% endif -%} {{ package_manager }} clean all && \ {% if image_flavor != 'ubi8' -%} + locale-gen 'en_US.UTF-8' && \ {{ package_manager }} clean metadata && \ {% endif -%} exit_code=0 && break || exit_code=$? && \ diff --git a/qa/docker/shared_examples/container.rb b/qa/docker/shared_examples/container.rb index 924625ae41d..fc85e6445dc 100644 --- a/qa/docker/shared_examples/container.rb +++ b/qa/docker/shared_examples/container.rb @@ -10,6 +10,10 @@ end context 'logstash' do + it 'does not warn cannot change locale' do + expect(@container.logs(stderr: true)).not_to match /cannot change locale/ + end + it 'should run with the correct version' do console_out = exec_in_container(@container, 'logstash --version') console_filtered = console_out.split("\n") From bbf19f323d70c8762f9ac5cd8683b219e3933b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Thu, 9 Dec 2021 10:32:52 +0000 Subject: [PATCH 3/3] tiny typo fix: ubunto -> ubuntu --- qa/docker/spec/full/container_spec.rb | 2 +- qa/docker/spec/oss/container_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qa/docker/spec/full/container_spec.rb b/qa/docker/spec/full/container_spec.rb index da30715b7b4..dfd35e7574a 100644 --- a/qa/docker/spec/full/container_spec.rb +++ b/qa/docker/spec/full/container_spec.rb @@ -20,7 +20,7 @@ cleanup_container(@container) end - it 'has an Ubunto 20.04 base image' do + it 'has an Ubuntu 20.04 base image' do expect(exec_in_container(@container, 'cat /etc/os-release').chomp).to match /Ubuntu 20.04/ end end diff --git a/qa/docker/spec/oss/container_spec.rb b/qa/docker/spec/oss/container_spec.rb index cfa2da1b78f..fd956c80d23 100644 --- a/qa/docker/spec/oss/container_spec.rb +++ b/qa/docker/spec/oss/container_spec.rb @@ -18,7 +18,7 @@ cleanup_container(@container) end - it 'has an Ubunto 20.04 base image' do + it 'has an Ubuntu 20.04 base image' do expect(exec_in_container(@container, 'cat /etc/os-release').chomp).to match /Ubuntu 20.04/ end end