Skip to content

Add FreeBSD support - #339

Open
ocochard wants to merge 1 commit into
aws:masterfrom
ocochard:freebsd
Open

Add FreeBSD support#339
ocochard wants to merge 1 commit into
aws:masterfrom
ocochard:freebsd

Conversation

@ocochard

Copy link
Copy Markdown

Description of changes:

efs-utils builds and runs on FreeBSD/amd64 and FreeBSD/aarch64. A new mount_efs(8) helper mounts EFS filesystems through the same efs-proxy used on Linux, and the mount-watchdog daemon supervises the proxy just as it does on other platforms.

FreeBSD differs from Linux in a few places that required targeted adjustments:

  • src/efs_utils_common/mount_options.py: FreeBSD's mount_nfs(8) does not recognize nfsvers=4.1; on FreeBSD, pass nfsv4,minorversion=1 instead so mount_nfs negotiates NFSv4.1. Also add oneopenown and retrycnt=1 to match the AWS-recommended FreeBSD EFS mount options.

  • src/efs_utils_common/mount_utils.py: dispatch to /sbin/mount_nfs on FreeBSD

  • src/efs_utils_common/proxy.py: detect FreeBSD init system as "rc" and start the watchdog with service(8) onestart. FreeBSD is also added to the SO_BINDTODEVICE-skip list for stunnel config generation.

  • src/watchdog/init.py: /proc/mounts does not exist on FreeBSD, and neither mount(8) nor nfsstat(8) expose the NFS client's TCP port. Enumerate the watchdog's own state files in STATE_FILE_DIR and cross-check against mount -t nfs to track live mounts. Keying off state files (rather than live proxy sockets) preserves the watchdog's ability to restart a dead efs-proxy.

  • dist/amazon-efs-mount-watchdog.rc: new FreeBSD rc(8) script, companion to the existing systemd unit and launchd plist.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mike-adams1

Copy link
Copy Markdown
Contributor

Hi @ocochard thanks for the PR.

We're taking a look at this internally and will let you know when we have updates.

efs-utils builds and runs on FreeBSD/amd64 and FreeBSD/aarch64. A new
mount_efs(8) helper mounts EFS filesystems through the same efs-proxy used on
Linux, and the mount-watchdog daemon supervises the proxy as on other
platforms.

* src/efs_utils_common/mount_options.py: use `nfsv4,minorversion=1` instead of
  `nfsvers=4.1` (unrecognized by FreeBSD's mount_nfs(8)); add `oneopenown` and
  `retrycnt=1` per AWS-recommended FreeBSD mount options.

* src/efs_utils_common/mount_utils.py: dispatch to /sbin/mount_nfs on FreeBSD.

* src/efs_utils_common/proxy.py: detect FreeBSD init as "rc", start the
  watchdog via `service(8) onestart`; skip SO_BINDTODEVICE in stunnel config
  generation on FreeBSD.

* src/watchdog/__init__.py: /proc/mounts doesn't exist on FreeBSD and neither
  mount(8) nor nfsstat(8) expose the NFS client's TCP port, so live mounts are
  tracked by enumerating state files in STATE_FILE_DIR and cross-checking
  against `mount -t nfs`. To avoid the health-check `df` wedging permanently in
  unkillable D-state on a kernel vnode lock, track the in-flight `df`
  subprocess per state file and skip spawning a new one while the prior one is
  still stuck, capping the leak at one stuck process per mount. To avoid
  tracking an orphaned efs-proxy/state-file pair left behind by
  nflx_mount_efs's cold-boot retry as a second live mount, prefer the state
  file whose port has an ESTABLISHED loopback connection (via `sockstat -4`)
  so the orphan gets reaped by the existing stale-mount cleanup path instead.

* dist/amazon-efs-mount-watchdog.rc: new FreeBSD rc(8) script, companion to
  the existing systemd unit and launchd plist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants