-
Notifications
You must be signed in to change notification settings - Fork 115
Openzfs smhp #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Openzfs smhp #622
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f29528d
OpenZFS branch
amanshanbhag 0b28d42
Updating openzfs mount path to /home
amanshanbhag e8f67e4
Adding /home/user as home directory (openzfs)
amanshanbhag 98d9f5d
Adding in the Automate Script + CF Stack Template for OpenZFS deployment
amanshanbhag fd77d0c
Revert "Adding in the Automate Script + CF Stack Template for OpenZFS…
amanshanbhag c3b0664
small changes to adjust provisioning_parameters.json syntax
amanshanbhag feb876a
Pushing correct tp value (only had it on local)
amanshanbhag 019b2fd
Add user provisioned IOPS option
amanshanbhag 711f8d5
Removed redundant code, switched to Ansible for openzfs mount. Tested…
amanshanbhag 031da2a
Pinning Ansible version 6.7.0, using pip install ansible
amanshanbhag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
1.architectures/5.sagemaker-hyperpod/LifecycleScripts/base-config/mount_fsx_openzfs.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
# must be run as sudo | ||
|
||
set -x | ||
set -e | ||
|
||
# FSx OpenZFS Endpoints and versions | ||
FSX_OPENZFS_DNS_NAME="$1" | ||
OPENZFS_MOUNT_POINT="$2" | ||
NFS_VERSION=4.2 | ||
|
||
# Ansible Version | ||
ANSIBLE_VERSION="6.7.0" | ||
|
||
# Function for error handling | ||
handle_error() | ||
{ | ||
local exit_code=$? | ||
echo "Error occured in command: $BASH_COMMAND" | ||
echo "Exit code: $exit_code" | ||
exit $exit_code | ||
} | ||
|
||
trap handle_error ERR | ||
|
||
# DEBUG: Verify parameters are set | ||
verify_parameters() | ||
{ | ||
if [ -z "$FSX_OPENZFS_DNS_NAME" ] || [ -z "$OPENZFS_MOUNT_POINT" ]; then | ||
echo "Usage: $0 <fsx_dns_name> <mount_point>" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Install Ansible and collections: Move to higher LCS once others start using Ansible too. | ||
install_ansible() | ||
{ | ||
apt-get update | ||
# apt-get install -y ansible=$ANSIBLE_VERSION | ||
apt-get install -y python3-pip | ||
python3 -m pip install "ansible==${ANSIBLE_VERSION}" | ||
ansible-galaxy collection install ansible.posix | ||
} | ||
|
||
# Install NFS Client based on OS | ||
install_nfs_client() | ||
{ | ||
if [ -f /etc/lsb-release ]; then | ||
# Ubuntu | ||
ansible localhost -b -m ansible.builtin.apt -a "name=nfs-common state=present update_cache=yes" | ||
elif [ -f /etc/redhat-release ]; then | ||
# CentOS/RHEL | ||
ansible localhost -b -m ansible.builtin.yum -a "name=nfs-utils state=present" | ||
fi | ||
} | ||
|
||
# Mount the FSx OpenZFS file system | ||
mount_fs() | ||
{ | ||
ansible localhost -b -m ansible.posix.mount -a "path=$OPENZFS_MOUNT_POINT src=$FSX_OPENZFS_DNS_NAME:/fsx fstype=nfs opts=nfsvers=$NFS_VERSION,_netdev,nconnect=16,x-systemd.automount,x-systemd.requires=network-online.target dump=0 passno=0 state=mounted" | ||
} | ||
|
||
main() | ||
{ | ||
echo "Mount_fsx_openzfs called with fsx_openzfs_dns_name: $FSX_OPENZFS_DNS_NAME" | ||
echo "Using openzfs_mount_point: $OPENZFS_MOUNT_POINT" | ||
verify_parameters | ||
install_ansible | ||
install_nfs_client | ||
mount_fs | ||
echo "FSx OpenZFS mounted successfully to $OPENZFS_MOUNT_POINT" | ||
} | ||
|
||
main "$@" |
74 changes: 58 additions & 16 deletions
74
1.architectures/5.sagemaker-hyperpod/LifecycleScripts/base-config/utils/fsx_ubuntu.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,65 @@ | ||
#!/bin/bash | ||
|
||
# Wait for FSx to be properly mounted (timeout after 60 seconds) | ||
# RETRY CONFIG | ||
ATTEMPTS=6 | ||
WAIT=10 | ||
for ((i=1; i<=ATTEMPTS; i++)); do | ||
if mountpoint -q "/fsx" && touch /fsx/.test_write 2>/dev/null; then | ||
rm -f /fsx/.test_write | ||
break | ||
FSX_OPENZFS_DNS_NAME="/home" | ||
FSX_L_DNS_NAME="/fsx" | ||
|
||
# Function to check mount | ||
check_mount() | ||
{ | ||
local mount_point="$1" | ||
if mountpoint -q "$mount_point" && touch "$mount_point/.test_write" 2>/dev/null; then | ||
rm -f "$mount_point/.test_write" | ||
return 0 | ||
fi | ||
if [ $i -eq $ATTEMPTS ]; then | ||
echo "FSx mount not ready after $((ATTEMPTS * WAIT)) seconds" | ||
return 1 | ||
} | ||
|
||
# Wait for mount (both OpenZFS and FSxL) | ||
wait_for_mount() | ||
{ | ||
local mount_point="$1" | ||
for ((i=1; i<=$ATTEMPTS; i++)); do | ||
if check_mount "$mount_point"; then | ||
echo "Successfully verified mount at $mount_point" | ||
return 0 | ||
fi | ||
if [ $i -eq $ATTEMPTS ]; then | ||
echo "Mount not ready after $((ATTEMPTS * WAIT)) seconds" | ||
return 1 | ||
fi | ||
echo "Waiting for FSx mount: $mount_point to be ready... (attempt $i/$ATTEMPTS)" | ||
sleep $WAIT | ||
done | ||
} | ||
|
||
# Check if OpenZFS is mounted | ||
if wait_for_mount "$FSX_OPENZFS_DNS_NAME"; then | ||
echo "OpenZFS is mounted at $FSX_OPENZFS_DNS_NAME" | ||
if [ -d "$FSX_OPENZFS_DNS_NAME" ]; then | ||
# Set home directory to /home/ubuntu | ||
sudo usermod -m -d "$FSX_OPENZFS_DNS_NAME/ubuntu" ubuntu | ||
echo "Home directory set to $FSX_OPENZFS_DNS_NAME/ubuntu" | ||
|
||
# Maintain access to /fsx/ubuntu | ||
if wait_for_mount "$FSX_L_DNS_NAME"; then | ||
sudo mkdir -p "$FSX_L_DNS_NAME/ubuntu" | ||
sudo chown ubuntu:ubuntu "$FSX_L_DNS_NAME/ubuntu" | ||
else | ||
echo "Warning: FSx mount not available, skipping $FSX_L_DNS_NAME/ubuntu setup" | ||
fi | ||
fi | ||
else | ||
echo "OpenZFS is not mounted. Using FSxL file system as home" | ||
if ! wait_for_mount "$FSX_L_DNS_NAME"; then | ||
echo "Warning: FSx mount not available. Exiting." | ||
exit 1 | ||
fi | ||
sleep $WAIT | ||
done | ||
|
||
# move the ubuntu user to the shared /fsx filesystem | ||
if [ -d "/fsx/ubuntu" ]; then | ||
sudo usermod -d /fsx/ubuntu ubuntu | ||
elif [ -d "/fsx" ]; then | ||
sudo usermod -m -d /fsx/ubuntu ubuntu | ||
fi | ||
if [ -d "$FSX_L_DNS_NAME/ubuntu" ]; then | ||
sudo usermod -d "$FSX_L_DNS_NAME/ubuntu" ubuntu | ||
elif [ -d "$FSX_L_DNS_NAME" ]; then | ||
sudo usermod -m -d "$FSX_L_DNS_NAME/ubuntu" ubuntu | ||
fi | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be more distriptive? fsxl vs fsxz?