From 34b50f211fe863984159781f90cdc09d442e5d0f Mon Sep 17 00:00:00 2001 From: Sanjeev Rohila Date: Mon, 2 Jun 2025 15:05:21 +0530 Subject: [PATCH 1/3] Adding logic to take case the /export/home mount before delting /export/home Adding the mount point logic back to delphix-platform.sh script Changing as per Seb-s comment to alter the softlink logic. Changing the code to previous version to validate the comments. Changing the delphix-legacy-link.service to perform the same steps next reboot like deferred upgrade. Creating a different service for taking care of soft /export/home -> /home DLPX-89763 DLPX-86523 delphix-platform changes Moved the code to create symlink to different script Removing the autofs handling as per the concerns raised by Seb and our validation Removing the softlink loginc from main.yml PR URL: https://www.github.com/delphix/delphix-platform/pull/477 --- debian/postinst | 4 ++ debian/preinst | 42 +++++++++++++++++++ .../systemd/system/delphix-platform.service | 1 + .../roles/delphix-platform/tasks/main.yml | 8 ++-- .../var/lib/delphix-platform/export-home | 24 +++++++++++ 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 debian/preinst create mode 100644 files/common/var/lib/delphix-platform/export-home diff --git a/debian/postinst b/debian/postinst index 9c5a1d918..53a623ee3 100644 --- a/debian/postinst +++ b/debian/postinst @@ -124,6 +124,10 @@ configure) update-initramfs -u -t -k "$(uname -r)" fi + if [[ -f "/var/lib/delphix-platform/export-home" ]]; then + chmod 755 "/var/lib/delphix-platform/export-home" + fi + ;; esac diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 000000000..a22ccb233 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,42 @@ +#!/bin/bash -eux +# +# Copyright 2025 Delphix +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +case $1 in +upgrade) + # Home directories were previously mounted under /export/home, + # and this was changed to /home. This is the upgrade logic that + # updates the /etc/fstab file to reflect that change. + # Home directories will be mounted in both /export/home and /home + # until the system is rebooted to ensure that running processes + # referencing the old /export/home paths continue to function + # while also enabling new logins under /home to work. + fs_tab=/etc/fstab + + if grep -q "\/export\/home" "$fs_tab"; then + sed -i 's|/export/home|/home|g' "$fs_tab" + mount /home + fi + + passwd_file=/etc/passwd + if grep -q "\/export\/home" "$passwd_file"; then + sed -i 's/\/export\/home/\/home/g' /etc/passwd + fi + + ;; +esac + +exit 0 diff --git a/files/common/lib/systemd/system/delphix-platform.service b/files/common/lib/systemd/system/delphix-platform.service index 89a809d67..70514fdbe 100644 --- a/files/common/lib/systemd/system/delphix-platform.service +++ b/files/common/lib/systemd/system/delphix-platform.service @@ -24,6 +24,7 @@ Before=rsync.service docker.service Type=oneshot ExecStart=/var/lib/delphix-platform/ansible/apply ExecStart=/var/lib/delphix-platform/dynamic-debug +ExecStart=/var/lib/delphix-platform/export-home RemainAfterExit=yes # diff --git a/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml b/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml index 67abf0d98..18cff1522 100644 --- a/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml +++ b/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml @@ -1,5 +1,5 @@ # -# Copyright 2018, 2023 Delphix +# Copyright 2018, 2025 Delphix # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ # it below; otherwise that task will fail. # - file: - path: /export/home + path: /home state: directory mode: 0755 @@ -35,7 +35,7 @@ shell: /bin/bash create_home: yes comment: Delphix User - home: /export/home/delphix + home: /home/delphix # # In order for this locale to be used (e.g. by virtualization) we need @@ -635,7 +635,7 @@ - name: Source bash completion blockinfile: - dest: "/export/home/delphix/.bashrc" + dest: "/home/delphix/.bashrc" block: | . /etc/bash_completion.d/systemctl . /etc/bash_completion.d/zfs diff --git a/files/common/var/lib/delphix-platform/export-home b/files/common/var/lib/delphix-platform/export-home new file mode 100644 index 000000000..404f5ecb0 --- /dev/null +++ b/files/common/var/lib/delphix-platform/export-home @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright (c) 2025 by Delphix. All rights reserved. +# + +# +# This script ensures that the /export/home is a symlink +# to /home. +# + +if ! mountpoint -q /export/home; then + if [ ! -L /export/home ]; then + echo 'Ensuring /export/home is a symlink to /home...' + if [ -e /export/home ]; then + echo 'Removing existing /export/home directory...' + rm -rf /export/home + fi + if [ ! -d /export ]; then + mkdir /export + fi + echo 'Creating symlink: /export/home -> /home' + ln -s /home /export/home + fi +fi From b36fe933a33f24cc9fec8957724610a1110652be Mon Sep 17 00:00:00 2001 From: Sanjeev Rohila Date: Wed, 16 Jul 2025 10:30:21 +0530 Subject: [PATCH 2/3] Taking care the comments from Seb on 16 July 2025. --- debian/postinst | 4 -- .../var/lib/delphix-platform/export-home | 45 ++++++++++++++----- 2 files changed, 33 insertions(+), 16 deletions(-) mode change 100644 => 100755 files/common/var/lib/delphix-platform/export-home diff --git a/debian/postinst b/debian/postinst index 53a623ee3..9c5a1d918 100644 --- a/debian/postinst +++ b/debian/postinst @@ -124,10 +124,6 @@ configure) update-initramfs -u -t -k "$(uname -r)" fi - if [[ -f "/var/lib/delphix-platform/export-home" ]]; then - chmod 755 "/var/lib/delphix-platform/export-home" - fi - ;; esac diff --git a/files/common/var/lib/delphix-platform/export-home b/files/common/var/lib/delphix-platform/export-home old mode 100644 new mode 100755 index 404f5ecb0..b805ba226 --- a/files/common/var/lib/delphix-platform/export-home +++ b/files/common/var/lib/delphix-platform/export-home @@ -8,17 +8,38 @@ # to /home. # -if ! mountpoint -q /export/home; then - if [ ! -L /export/home ]; then - echo 'Ensuring /export/home is a symlink to /home...' - if [ -e /export/home ]; then - echo 'Removing existing /export/home directory...' - rm -rf /export/home - fi - if [ ! -d /export ]; then - mkdir /export - fi - echo 'Creating symlink: /export/home -> /home' - ln -s /home /export/home +# If /export/home is already a symlink to /home, do nothing +if [ -L /export/home ]; then + echo '/export/home is already exists. Nothing to do.' + exit 0 +fi + +# If it's still a mount point, abort to avoid potential data loss +if mountpoint -q /export/home; then + echo '/export/home is still mounted. Aborting to avoid risk of data loss.' + exit 1 +fi + +# If /export/home exists as a directory, check if it is safe to remove +if [ -e /export/home ]; then + echo 'Found existing /export/home. Checking if it is safe to remove.' + if rmdir /export/home 2>/dev/null; then + echo '/export/home was empty and removed successfully.' + else + echo 'Error: /export/home is not empty. Aborting to avoid accidental deletion.' + exit 1 fi fi + +# Ensure /export directory exists +mkdir -p /export + +# Create symlink +echo 'Creating symlink: /export/home -> /home' +ln -s /home /export/home +if [ $? -eq 0 ]; then + echo 'Symlink created successfully.' +else + echo 'Failed to create symlink. Please check permissions and try again.' + exit 1 +fi From 562800b6b863a6d69125801f048bf953f876517d Mon Sep 17 00:00:00 2001 From: Sanjeev Rohila Date: Wed, 23 Jul 2025 12:21:21 +0530 Subject: [PATCH 3/3] Since /export/home has empty delphix directory, taking care --- files/common/var/lib/delphix-platform/export-home | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/files/common/var/lib/delphix-platform/export-home b/files/common/var/lib/delphix-platform/export-home index b805ba226..789dd0ee7 100755 --- a/files/common/var/lib/delphix-platform/export-home +++ b/files/common/var/lib/delphix-platform/export-home @@ -23,6 +23,14 @@ fi # If /export/home exists as a directory, check if it is safe to remove if [ -e /export/home ]; then echo 'Found existing /export/home. Checking if it is safe to remove.' + if [ -d /export/home/delphix ]; then + if rmdir /export/home/delphix 2>/dev/null; then + echo '/export/home/delphix was empty and removed successfully.' + else + echo 'Error: /export/home/delphix is not empty. Aborting to avoid accidental deletion.' + exit 1 + fi + fi if rmdir /export/home 2>/dev/null; then echo '/export/home was empty and removed successfully.' else