diff options
Diffstat (limited to 'gemfeed')
| -rw-r--r-- | gemfeed/2025-07-14-f3s-kubernetes-with-freebsd-part-6.html | 72 | ||||
| -rw-r--r-- | gemfeed/atom.xml | 74 |
2 files changed, 83 insertions, 63 deletions
diff --git a/gemfeed/2025-07-14-f3s-kubernetes-with-freebsd-part-6.html b/gemfeed/2025-07-14-f3s-kubernetes-with-freebsd-part-6.html index 85d007e8..b58eb813 100644 --- a/gemfeed/2025-07-14-f3s-kubernetes-with-freebsd-part-6.html +++ b/gemfeed/2025-07-14-f3s-kubernetes-with-freebsd-part-6.html @@ -1602,7 +1602,6 @@ http://www.gnu.org/software/src-highlite --> MOUNT_POINT=<font color="#808080">"/data/nfs/k3svolumes"</font> LOCK_FILE=<font color="#808080">"/var/run/nfs-mount-check.lock"</font> -STATE_FILE=<font color="#808080">"/var/run/nfs-mount.state"</font> <i><font color="silver"># Use a lock file to prevent concurrent runs</font></i> <b><u><font color="#000000">if</font></u></b> [ -f <font color="#808080">"$LOCK_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> @@ -1611,46 +1610,57 @@ STATE_FILE=<font color="#808080">"/var/run/nfs-mount.state"</font> touch <font color="#808080">"$LOCK_FILE"</font> <b><u><font color="#000000">trap</font></u></b> <font color="#808080">"rm -f $LOCK_FILE"</font> EXIT -remount_it () { - <i><font color="silver"># Try to fix</font></i> - echo <font color="#808080">"Attempting to fix/remount NFS mount at $(date)"</font> | systemd-cat -t nfs-monitor -p notice - umount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null - sleep <font color="#000000">1</font> +fix_mount () { + echo <font color="#808080">"Attempting to remount NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> mount -o remount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Remount command issued for $MOUNT_POINT"</font> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to remount NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">fi</font></u></b> - <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> - echo <font color="#808080">"NFS mount fixed at $(date)"</font> | systemd-cat -t nfs-monitor -p info - rm -f <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Checking if $MOUNT_POINT is a mountpoint"</font> + <b><u><font color="#000000">if</font></u></b> mountpoint <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"$MOUNT_POINT is a valid mountpoint"</font> <b><u><font color="#000000">else</font></u></b> - echo <font color="#808080">"Failed to fix NFS mount at $(date)"</font> | systemd-cat -t nfs-monitor -p err + echo <font color="#808080">"$MOUNT_POINT is not a valid mountpoint, attempting mount"</font> + <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Successfully mounted $MOUNT_POINT"</font> + <b><u><font color="#000000">return</font></u></b> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to mount $MOUNT_POINT"</font> + <b><u><font color="#000000">fi</font></u></b> <b><u><font color="#000000">fi</font></u></b> -} -<i><font color="silver"># Quick check - ensure it's actually mounted</font></i> -<b><u><font color="#000000">if</font></u></b> ! mountpoint -q <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> - echo <font color="#808080">"NFS mount not found at $(date)"</font> | systemd-cat -t nfs-monitor -p err - remount_it -<b><u><font color="#000000">fi</font></u></b> + echo <font color="#808080">"Attempting to unmount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> umount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Successfully unmounted $MOUNT_POINT"</font> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to unmount $MOUNT_POINT (it might not be mounted)"</font> + <b><u><font color="#000000">fi</font></u></b> -<i><font color="silver"># Quick check - try to stat a directory with a very short timeout</font></i> -<b><u><font color="#000000">if</font></u></b> timeout 2s stat <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># Mount appears healthy</font></i> - <b><u><font color="#000000">if</font></u></b> [ -f <font color="#808080">"$STATE_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># Was previously unhealthy, log recovery</font></i> - echo <font color="#808080">"NFS mount recovered at $(date)"</font> | systemd-cat -t nfs-monitor -p info - rm -f <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Attempting to mount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT mounted successfully"</font> + <b><u><font color="#000000">return</font></u></b> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to mount NFS mount $MOUNT_POINT"</font> <b><u><font color="#000000">fi</font></u></b> - <b><u><font color="#000000">exit</font></u></b> <font color="#000000">0</font> -<b><u><font color="#000000">fi</font></u></b> -<i><font color="silver"># Mount is unhealthy</font></i> -<b><u><font color="#000000">if</font></u></b> [ ! -f <font color="#808080">"$STATE_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># First detection of unhealthy state</font></i> - echo <font color="#808080">"NFS mount unhealthy detected at $(date)"</font> | systemd-cat -t nfs-monitor -p warning - touch <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Failed to fix NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">exit</font></u></b> <font color="#000000">1</font> +} + +<b><u><font color="#000000">if</font></u></b> ! mountpoint <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT not found"</font> + fix_mount <b><u><font color="#000000">fi</font></u></b> -remount_it +<b><u><font color="#000000">if</font></u></b> ! timeout 2s stat <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT appears to be unresponsive"</font> + fix_mount +<b><u><font color="#000000">fi</font></u></b> EOF + [root@r0 ~]<i><font color="silver"># chmod +x /usr/local/bin/check-nfs-mount.sh</font></i> </pre> <br /> diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index dc1c83bb..86fbc6ea 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2025-07-28T14:27:18+03:00</updated> + <updated>2025-07-28T15:09:21+03:00</updated> <title>foo.zone feed</title> <subtitle>To be in the .zone!</subtitle> <link href="https://foo.zone/gemfeed/atom.xml" rel="self" /> @@ -1609,7 +1609,6 @@ http://www.gnu.org/software/src-highlite --> MOUNT_POINT=<font color="#808080">"/data/nfs/k3svolumes"</font> LOCK_FILE=<font color="#808080">"/var/run/nfs-mount-check.lock"</font> -STATE_FILE=<font color="#808080">"/var/run/nfs-mount.state"</font> <i><font color="silver"># Use a lock file to prevent concurrent runs</font></i> <b><u><font color="#000000">if</font></u></b> [ -f <font color="#808080">"$LOCK_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> @@ -1618,46 +1617,57 @@ STATE_FILE=<font color="#808080">"/var/run/nfs-mount.state"</font> touch <font color="#808080">"$LOCK_FILE"</font> <b><u><font color="#000000">trap</font></u></b> <font color="#808080">"rm -f $LOCK_FILE"</font> EXIT -remount_it () { - <i><font color="silver"># Try to fix</font></i> - echo <font color="#808080">"Attempting to fix/remount NFS mount at $(date)"</font> | systemd-cat -t nfs-monitor -p notice - umount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null - sleep <font color="#000000">1</font> +fix_mount () { + echo <font color="#808080">"Attempting to remount NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> mount -o remount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Remount command issued for $MOUNT_POINT"</font> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to remount NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">fi</font></u></b> - <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> - echo <font color="#808080">"NFS mount fixed at $(date)"</font> | systemd-cat -t nfs-monitor -p info - rm -f <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Checking if $MOUNT_POINT is a mountpoint"</font> + <b><u><font color="#000000">if</font></u></b> mountpoint <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"$MOUNT_POINT is a valid mountpoint"</font> <b><u><font color="#000000">else</font></u></b> - echo <font color="#808080">"Failed to fix NFS mount at $(date)"</font> | systemd-cat -t nfs-monitor -p err + echo <font color="#808080">"$MOUNT_POINT is not a valid mountpoint, attempting mount"</font> + <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Successfully mounted $MOUNT_POINT"</font> + <b><u><font color="#000000">return</font></u></b> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to mount $MOUNT_POINT"</font> + <b><u><font color="#000000">fi</font></u></b> <b><u><font color="#000000">fi</font></u></b> -} -<i><font color="silver"># Quick check - ensure it's actually mounted</font></i> -<b><u><font color="#000000">if</font></u></b> ! mountpoint -q <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> - echo <font color="#808080">"NFS mount not found at $(date)"</font> | systemd-cat -t nfs-monitor -p err - remount_it -<b><u><font color="#000000">fi</font></u></b> + echo <font color="#808080">"Attempting to unmount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> umount -f <font color="#808080">"$MOUNT_POINT"</font> <font color="#000000">2</font>>/dev/null; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"Successfully unmounted $MOUNT_POINT"</font> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to unmount $MOUNT_POINT (it might not be mounted)"</font> + <b><u><font color="#000000">fi</font></u></b> -<i><font color="silver"># Quick check - try to stat a directory with a very short timeout</font></i> -<b><u><font color="#000000">if</font></u></b> timeout 2s stat <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># Mount appears healthy</font></i> - <b><u><font color="#000000">if</font></u></b> [ -f <font color="#808080">"$STATE_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># Was previously unhealthy, log recovery</font></i> - echo <font color="#808080">"NFS mount recovered at $(date)"</font> | systemd-cat -t nfs-monitor -p info - rm -f <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Attempting to mount $MOUNT_POINT"</font> + <b><u><font color="#000000">if</font></u></b> mount <font color="#808080">"$MOUNT_POINT"</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT mounted successfully"</font> + <b><u><font color="#000000">return</font></u></b> + <b><u><font color="#000000">else</font></u></b> + echo <font color="#808080">"Failed to mount NFS mount $MOUNT_POINT"</font> <b><u><font color="#000000">fi</font></u></b> - <b><u><font color="#000000">exit</font></u></b> <font color="#000000">0</font> -<b><u><font color="#000000">fi</font></u></b> -<i><font color="silver"># Mount is unhealthy</font></i> -<b><u><font color="#000000">if</font></u></b> [ ! -f <font color="#808080">"$STATE_FILE"</font> ]; <b><u><font color="#000000">then</font></u></b> - <i><font color="silver"># First detection of unhealthy state</font></i> - echo <font color="#808080">"NFS mount unhealthy detected at $(date)"</font> | systemd-cat -t nfs-monitor -p warning - touch <font color="#808080">"$STATE_FILE"</font> + echo <font color="#808080">"Failed to fix NFS mount $MOUNT_POINT"</font> + <b><u><font color="#000000">exit</font></u></b> <font color="#000000">1</font> +} + +<b><u><font color="#000000">if</font></u></b> ! mountpoint <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT not found"</font> + fix_mount <b><u><font color="#000000">fi</font></u></b> -remount_it +<b><u><font color="#000000">if</font></u></b> ! timeout 2s stat <font color="#808080">"$MOUNT_POINT"</font> >/dev/null <font color="#000000">2</font>>&<font color="#000000">1</font>; <b><u><font color="#000000">then</font></u></b> + echo <font color="#808080">"NFS mount $MOUNT_POINT appears to be unresponsive"</font> + fix_mount +<b><u><font color="#000000">fi</font></u></b> EOF + [root@r0 ~]<i><font color="silver"># chmod +x /usr/local/bin/check-nfs-mount.sh</font></i> </pre> <br /> |
