From 885b7b6f8e894fa16187da3f43076942e947984d Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 2 May 2025 11:17:53 -0400 Subject: [PATCH] dashboard: ensure nodeenv downloaded content is owned by current user When testing ceph builds in a container we discovered that certain files could not be deleted by jenkins after a build. This was due to the way the container maps IDs - files owned by the root user in the container become owned by the "real" user/jenkins user on the "host". However, the node tarball that is fetched and unpacked by nodeenv has a different owner name/uid that is preserved in the tree and this id gets mapped to something that can be managed by the "fake root" of the container but not by the "regular" user outside the container. The simplest workaround I can think of is to chown the tree back to the current user and avoid leaving files on disk with uncleanly mapped uids. Signed-off-by: John Mulligan (cherry picked from commit 24dbfb5da4813c6588f9cd199b9f527bb67f1e88) --- src/pybind/mgr/dashboard/frontend/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pybind/mgr/dashboard/frontend/CMakeLists.txt b/src/pybind/mgr/dashboard/frontend/CMakeLists.txt index c0d16511e9668..901f10487755e 100644 --- a/src/pybind/mgr/dashboard/frontend/CMakeLists.txt +++ b/src/pybind/mgr/dashboard/frontend/CMakeLists.txt @@ -65,6 +65,11 @@ else(WITH_SYSTEM_NPM) COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${MGR_PYTHON_EXECUTABLE} ${mgr-dashboard-nodeenv-dir} COMMAND ${mgr-dashboard-nodeenv-dir}/bin/pip install nodeenv COMMAND ${mgr-dashboard-nodeenv-dir}/bin/nodeenv --verbose ${node_mirror_opt} -p --node=20.13.1 + # ensure that the files that nodeenv unpacks from tarballs are owned by + # the current user. This can be an issue due to the node tarball using + # uid 1000 and running the unpack in a id-mapped namespace (container) + # that lets tar set the uid to a "bad" uid outside the namespace + COMMAND bash -c "chown -R $$(id -u):$$(id -g) ${mgr-dashboard-nodeenv-dir}/src" COMMAND mkdir ${mgr-dashboard-nodeenv-dir}/.npm WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "dashboard nodeenv is being installed") -- 2.39.5