diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 84f85524cb4..cf041a30f55 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -377,6 +377,7 @@ indentless ine Infof Infoln +inotifywait installable INSTALLMESSAGE INSTALLPROPERTY diff --git a/bats/tests/containers/volumes.bats b/bats/tests/containers/volumes.bats index 6ddc9732514..a7a14fead84 100644 --- a/bats/tests/containers/volumes.bats +++ b/bats/tests/containers/volumes.bats @@ -311,3 +311,28 @@ known_failure_on_mount_type() { assert_success "${assert}_output" -rwxr-xr-x # spellcheck-ignore-line } + +@test 'filesystem monitoring' { + skip_on_windows + # wait for API + RD_TIMEOUT=10s try --max 30 --delay 5 rdctl api /settings + rdctl set --experimental.virtual-machine.mount.inotify + wait_for_container_engine + # Build an image that will monitor for changes. + ctrctl build --file - --tag rd_bats_volume_inotify "$HOST_WORK_PATH" <<<" + FROM $IMAGE_REGISTRY_2_8_1 + RUN apk add --update-cache --no-interactive inotify-tools + ENTRYPOINT /usr/bin/inotifywait --recursive --quiet --timeout 30 /mount + " + # Schedule a change to be triggered. + { + sleep 10 + date >"$HOST_WORK_PATH/foo" + } & + # Run the container, which should pick up the change and report it. + run ctrctl run \ + --volume "$HOST_WORK_PATH:/mount:rw" --pull never \ + rd_bats_volume_inotify + assert_output --regexp "/mount.*foo" + assert_success +} diff --git a/pkg/rancher-desktop/assets/specs/command-api.yaml b/pkg/rancher-desktop/assets/specs/command-api.yaml index bd232018e47..bd541e8d878 100644 --- a/pkg/rancher-desktop/assets/specs/command-api.yaml +++ b/pkg/rancher-desktop/assets/specs/command-api.yaml @@ -699,6 +699,10 @@ components: cacheMode: type: string enum: [none, loose, fscache, mmap] + inotify: + type: boolean + x-rd-platforms: [darwin, linux] + x-rd-usage: file modification notification support, only for writable mounts proxy: type: object x-rd-platforms: [win32] diff --git a/pkg/rancher-desktop/assets/translations/en-us.yaml b/pkg/rancher-desktop/assets/translations/en-us.yaml index 4a7d81cabab..9574c2f6663 100644 --- a/pkg/rancher-desktop/assets/translations/en-us.yaml +++ b/pkg/rancher-desktop/assets/translations/en-us.yaml @@ -372,6 +372,11 @@ virtualMachine: virtiofs: label: virtiofs description: Exposes the filesystem by using an Apple Virtualization framework shared directory device. + inotify: + label: Filesystem event monitoring + enabled: Enabled + description: >- + Only a limited set of events are triggered; file deletions are ignored. proxy: legend: WSL Proxy label: Enable the proxy used by rancher-desktop diff --git a/pkg/rancher-desktop/backend/lima.ts b/pkg/rancher-desktop/backend/lima.ts index 3e65a6df13d..c6210812b84 100644 --- a/pkg/rancher-desktop/backend/lima.ts +++ b/pkg/rancher-desktop/backend/lima.ts @@ -114,6 +114,7 @@ export type LimaConfiguration = { disk?: number; mounts?: LimaMount[]; mountType: 'reverse-sshfs' | '9p' | 'virtiofs'; + mountInotify?: boolean; ssh: { localPort: number; loadDotSSHPubKeys?: boolean; @@ -635,6 +636,7 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken memory: (this.cfg?.virtualMachine.memoryInGB || 4) * 1024 * 1024 * 1024, mounts: this.getMounts(), mountType: this.cfg?.virtualMachine.mount.type, + mountInotify: this.cfg?.experimental.virtualMachine.mount.inotify, ssh: { localPort: await this.sshPort }, hostResolver: { hosts: { @@ -2154,8 +2156,9 @@ CREDFWD_URL='http://${ SLIRP.HOST_GATEWAY }:${ stateInfo.port }' 'experimental.virtualMachine.mount.9p.msizeInKib': undefined, 'experimental.virtualMachine.mount.9p.protocolVersion': undefined, 'experimental.virtualMachine.mount.9p.securityModel': undefined, - 'virtualMachine.mount.type': undefined, + 'experimental.virtualMachine.mount.inotify': undefined, 'experimental.virtualMachine.sshPortForwarder': undefined, + 'virtualMachine.mount.type': undefined, 'virtualMachine.type': undefined, 'virtualMachine.useRosetta': undefined, })); diff --git a/pkg/rancher-desktop/components/Preferences/VirtualMachineVolumes.vue b/pkg/rancher-desktop/components/Preferences/VirtualMachineVolumes.vue index ee145d25d90..d87eb9546b2 100644 --- a/pkg/rancher-desktop/components/Preferences/VirtualMachineVolumes.vue +++ b/pkg/rancher-desktop/components/Preferences/VirtualMachineVolumes.vue @@ -1,8 +1,11 @@