From 6d31a2f6ba091a06d711391ee1e79fbd75bdd5c4 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 21 Mar 2024 18:16:43 +0000 Subject: [PATCH 1/2] Add current user to adm group to access logs Signed-off-by: Peter Zhu --- ...est.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile | 1 + ...est.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile | 1 + .../test.rockylinux8.systemd-base.x64.arm64.dockerfile | 2 +- jenkins/opensearch-dashboards/integ-test.jenkinsfile | 6 +++--- src/test_workflow/integ_test/distribution_deb.py | 4 +++- src/test_workflow/integ_test/distribution_rpm.py | 4 +++- .../test_integ_workflow/integ_test/test_distribution_deb.py | 3 ++- .../test_integ_workflow/integ_test/test_distribution_rpm.py | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docker/ci/dockerfiles/current/test.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile b/docker/ci/dockerfiles/current/test.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile index 72d31cc128..601f2b66c5 100644 --- a/docker/ci/dockerfiles/current/test.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile +++ b/docker/ci/dockerfiles/current/test.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile @@ -110,6 +110,7 @@ RUN dnf install -y sudo && \ useradd -u 1002 -g 1002 opensearch-dashboards && \ usermod -a -G opensearch $CONTAINER_USER && \ usermod -a -G opensearch-dashboards $CONTAINER_USER && \ + usermod -a -G adm $CONTAINER_USER && \ id && \ echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER diff --git a/docker/ci/dockerfiles/current/test.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile b/docker/ci/dockerfiles/current/test.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile index b87925ef71..c1f2f9c2fe 100644 --- a/docker/ci/dockerfiles/current/test.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile +++ b/docker/ci/dockerfiles/current/test.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile @@ -128,6 +128,7 @@ RUN apt-get install -y sudo && \ useradd -u 1002 -g 1002 -s /bin/bash -d /home/opensearch-dashboards -m opensearch-dashboards && \ usermod -a -G opensearch $CONTAINER_USER && \ usermod -a -G opensearch-dashboards $CONTAINER_USER && \ + usermod -a -G adm $CONTAINER_USER && \ id && \ echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER diff --git a/docker/ci/dockerfiles/legacy/test.rockylinux8.systemd-base.x64.arm64.dockerfile b/docker/ci/dockerfiles/legacy/test.rockylinux8.systemd-base.x64.arm64.dockerfile index 31c3d6aae9..c3d88391d8 100644 --- a/docker/ci/dockerfiles/legacy/test.rockylinux8.systemd-base.x64.arm64.dockerfile +++ b/docker/ci/dockerfiles/legacy/test.rockylinux8.systemd-base.x64.arm64.dockerfile @@ -109,7 +109,7 @@ RUN dnf install -y sudo && \ groupadd -g 1002 opensearch-dashboards && \ useradd -u 1002 -g 1002 opensearch-dashboards && \ usermod -a -G opensearch $CONTAINER_USER && \ - usermod -a -G opensearch-dashboards $CONTAINER_USER && \ + usermod -a -G adm $CONTAINER_USER && \ id && \ echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER diff --git a/jenkins/opensearch-dashboards/integ-test.jenkinsfile b/jenkins/opensearch-dashboards/integ-test.jenkinsfile index fc8c1ff126..a53799f8f7 100644 --- a/jenkins/opensearch-dashboards/integ-test.jenkinsfile +++ b/jenkins/opensearch-dashboards/integ-test.jenkinsfile @@ -21,9 +21,9 @@ def docker_images = [ ] def docker_args = [ - "tar": "-u 1000 -e BROWSER_PATH=electron", - "rpm": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host -e BROWSER_PATH=electron", - "deb": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host -e BROWSER_PATH=electron", + "tar": "-u 1000", + "rpm": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host", + "deb": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host", "zip": "-u ContainerAdministrator", ] diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 0068eb8bbe..43b434e72c 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -50,7 +50,9 @@ def install(self, bundle_name: str) -> None: '&&', f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}', '&&', - f'sudo usermod -a -G {self.filename} `whoami`' + f'sudo usermod -a -G {self.filename} `whoami`', + '&&', + f'sudo usermod -a -G adm `whoami`' ] ) subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True) diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index 49123451c7..10f3da3be3 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -52,7 +52,9 @@ def install(self, bundle_name: str) -> None: '&&', f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}', '&&', - f'sudo usermod -a -G {self.filename} `whoami`' + f'sudo usermod -a -G {self.filename} `whoami`', + '&&', + f'sudo usermod -a -G adm `whoami`' ] ) subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index ad59c10cda..41e528cc3f 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -49,7 +49,8 @@ def test_install(self, check_call_mock: Mock) -> None: "dpkg --install opensearch.deb && " f"sudo chmod 0666 {self.distribution_deb.config_path} && " f"sudo chmod 0755 {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir} && " - f"sudo usermod -a -G opensearch `whoami`" + f"sudo usermod -a -G opensearch `whoami` && " + f"sudo usermod -a -G adm `whoami`" ), args_list[0][0][0], ) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index d851b3773b..56a213bab6 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -49,7 +49,8 @@ def test_install(self, check_call_mock: Mock) -> None: "yum install -y opensearch.rpm && " f"sudo chmod 0666 {self.distribution_rpm.config_path} && " f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir} && " - f"sudo usermod -a -G opensearch `whoami`" + f"sudo usermod -a -G opensearch `whoami` && " + f"sudo usermod -a -G adm `whoami`" ), args_list[0][0][0], ) From 6e469c3375baf18b1958675ef5ad509d412e5267 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 21 Mar 2024 18:20:54 +0000 Subject: [PATCH 2/2] Remove unused substitute Signed-off-by: Peter Zhu --- src/test_workflow/integ_test/distribution_deb.py | 2 +- src/test_workflow/integ_test/distribution_rpm.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 43b434e72c..b26f91adbe 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -52,7 +52,7 @@ def install(self, bundle_name: str) -> None: '&&', f'sudo usermod -a -G {self.filename} `whoami`', '&&', - f'sudo usermod -a -G adm `whoami`' + 'sudo usermod -a -G adm `whoami`' ] ) subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True) diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index 10f3da3be3..e7e2de6608 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -54,7 +54,7 @@ def install(self, bundle_name: str) -> None: '&&', f'sudo usermod -a -G {self.filename} `whoami`', '&&', - f'sudo usermod -a -G adm `whoami`' + 'sudo usermod -a -G adm `whoami`' ] ) subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True)