-
Notifications
You must be signed in to change notification settings - Fork 151
aravneel update lcs - openzfs mount and user add permissions #899
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
Changes from all commits
6d7b7da
7b679c7
952886b
d7d5aac
57b6885
b743ec2
cdcb63b
e2da595
78a3936
36e0191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,21 +76,65 @@ install_nfs_client() | |
| # Mount the FSx OpenZFS file system | ||
| mount_fs() | ||
| { | ||
| # Create mount point directory if it doesn't exist | ||
| if [ ! -d "$OPENZFS_MOUNT_POINT" ]; then | ||
| mkdir -p "$OPENZFS_MOUNT_POINT" | ||
| fi | ||
| local max_attempts=5 | ||
| local attempt=1 | ||
| local delay=5 | ||
| local test_file="$OPENZFS_MOUNT_POINT/test_file_$(hostname)" | ||
|
|
||
| echo "[INFO] Ensuring $OPENZFS_MOUNT_POINT directory exists..." | ||
| ansible localhost -b -m ansible.builtin.file -a "path=$OPENZFS_MOUNT_POINT state=directory" || true | ||
|
|
||
| echo "[INFO] Mounting FSx OpenZFS on $OPENZFS_MOUNT_POINT..." | ||
| echo "[INFO] Using test file: $test_file" | ||
|
|
||
| while (( attempt <= max_attempts )); do | ||
| echo "============================" | ||
| echo "[INFO] Attempt $attempt of $max_attempts" | ||
| echo "============================" | ||
|
|
||
| echo "[STEP] Mounting FSx OpenZFS..." | ||
| if ! 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"; then | ||
| echo "[WARN] Mount command failed — retrying in $delay seconds" | ||
| sleep "$delay"; ((attempt++)); continue | ||
| fi | ||
|
|
||
| echo "[STEP] Verifying mountpoint..." | ||
| if ! ansible localhost -b -m ansible.builtin.command -a "mountpoint $OPENZFS_MOUNT_POINT"; then | ||
| echo "[WARN] Mountpoint verification failed — retrying in $delay seconds" | ||
| sleep "$delay"; ((attempt++)); continue | ||
| fi | ||
|
|
||
| retry_with_backoff $MAX_ATTEMPTS $INITIAL_BACKOFF "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\"" | ||
| echo "[STEP] Triggering automount..." | ||
| ls -la "$OPENZFS_MOUNT_POINT" >/dev/null 2>&1 || true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a potential silent error due to (...|| true) Example
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PremiumSpider This does qualify as a silent error due to (..|| true). But we don't need to log anything here because this is just triggering the automount. The ls command is trying to access the space which will mount the FS. We have explicit verification in the next step with touch and delete. I would leave as it is in my opinion. |
||
|
|
||
| echo "[STEP] Testing file access (touch)..." | ||
| if ! ansible localhost -b -m ansible.builtin.file -a "path=$test_file state=touch"; then | ||
| echo "[WARN] Touch failed — retrying in $delay seconds" | ||
| sleep "$delay"; ((attempt++)); continue | ||
| fi | ||
|
|
||
| echo "[STEP] Testing file access (delete)..." | ||
| if ! ansible localhost -b -m ansible.builtin.file -a "path=$test_file state=absent"; then | ||
| echo "[WARN] Delete failed — retrying in $delay seconds" | ||
| sleep "$delay"; ((attempt++)); continue | ||
| fi | ||
|
|
||
| echo "[SUCCESS] FSx OpenZFS mount succeeded on attempt $attempt" | ||
| return 0 | ||
| done | ||
|
|
||
| echo "[ERROR] FSx OpenZFS mount failed after $max_attempts attempts" | ||
| return 1 | ||
| } | ||
|
|
||
| # Verify mount was successful | ||
| verify_mount() | ||
| # Restart systemd daemon to ensure mount units are properly loaded | ||
| restart_daemon() | ||
| { | ||
| if ! mountpoint -q "$OPENZFS_MOUNT_POINT"; then | ||
| echo "Failed to verify mount point $OPENZFS_MOUNT_POINT" | ||
| exit 1 | ||
| fi | ||
| ansible localhost -b -m ansible.builtin.systemd -a "daemon_reload=yes" | ||
| ansible localhost -b -m ansible.builtin.systemd -a "name=remote-fs.target state=restarted" | ||
| echo "Check status of OpenZFS automount..." | ||
| systemctl list-units | grep -i automount || true | ||
| } | ||
|
|
||
| main() | ||
|
|
@@ -99,8 +143,8 @@ main() | |
| echo "Using openzfs_mount_point: $OPENZFS_MOUNT_POINT" | ||
| verify_parameters | ||
| install_nfs_client | ||
| mount_fs | ||
| verify_mount | ||
| mount_fs || exit 1 | ||
| restart_daemon | ||
| echo "FSx OpenZFS mounted successfully to $OPENZFS_MOUNT_POINT" | ||
| } | ||
|
|
||
|
|
||
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.
Suppose we have 2 nodes, if they are all creating a global static test_file, do we need to worry about race conditions ?
Would something like below help ?
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.
That is a good catch. I can implement this here. Thanks for catching this.
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.
@PremiumSpider This has been implemented now.
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.
Tested this as well and looks good.
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.
Thank you for testing on your end as well.