Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-7489

Change From NFS to Bind Mount is Partially Unsuccessful

    XMLWordPrintable

    Details

    • Template:
    • Team:
      Platform OS

      Description

      When using the mount provider to apply a bind mount for a given mount point, it seems that in the precise scenario where the existing mount at the same location is an NFS volume (and perhaps the issue is less specific, but this is at least what we conclude without changing variables involved in the situation), Puppet will successfully modify the respective /etc/fstab entry, and even the desired mount options appear get applied, but the NFS volume remains mounted to the given location rather than the desired bind mount.

      I have concluded that when the change is triggered, a "mount -o remount /target/dir" is issued, which we've verified with manual execution that this will not effectively put the bind mount in place of the NFS mount. As such, it seems the following pseudo-logic/code would need to be injected into the mount provider :

      "if (old fstype is nfs) and (new fstype is none && includes option of bind); then 
      /bin/unmount /target/dir
      /bin/mount /target/dir
      fi".
      

      Below are all the additional pertinent details that I can think to include, but feel free to let me know if any additional information and/or action is needed on my behalf! Thanks!

      (Note : Entity-specific details have been replaced with generic placeholder references)

      ==== Puppet Manifest ====

      mount {
            '/some/target/dir':
      	      ensure  => 'mounted',
      	      device  => "$::mounts::some_vol",
      	      fstype  => "$::mounts::some_vol_type",
      	      options => "$::mounts::some_vol_opts",
      	      target  => '/etc/fstab',
              require => [Class['mounts::app::dependent_nfs_mount'],File['/some/target/dir']];
      

      Hieradata:

      mounts::some_vol: '/some/source_nfs_dir’
      mounts::some_vol_type: 'none'
      mounts::some_vol_opts: "%{hiera('bind_default_opts')}"
      bind_default_opts: '_netdev,bind,rw,nosuid,nodev'
      

      ==== "Pre-Puppet" State ====

      # mount | grep ‘/some/target/dir’
      1.2.3.4:/some_nfs_vol on /some/target/dir type nfs (rw,nosuid,nodev,bg,hard,vers=4,proto=tcp,timeo=600,rsize=65536,wsize=65536,nointr,addr=1.2.3.4,clientaddr=1.2.3.40)
       
      # grep ‘/some/target/dir’ /etc/fstab
      1.2.3.4:/some_nfs_vol	/some/target/dir	nfs	rw,bg,hard,vers=4,proto=tcp,timeo=600,rsize=65536,wsize=65536,nointr,nodev,nosuid	0	0
       
      # puppet agent --debug --trace --verbose --test 2>&1 | tee /tmp/puppet_run.out
      …trim…
      Notice: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]/device: device changed 1.2.3.4:/some_nfs_vol to /some/source_nfs_dir
      Notice: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]/fstype: fstype changed nfs to none
      Notice: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]/options: options changed rw,bg,hard,vers=4,proto=tcp,timeo=600,rsize=65536,wsize=65536,nointr,nodev,nosuid to _netdev,bind,rw,nosuid,nodev
      Debug: Flushing mount provider target /etc/fstab
      Info: Computing checksum on file /etc/fstab
      Debug: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: The container Class[Mounts::Some_target_dir] will propagate my refresh event
      Info: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: Scheduling refresh of Mount[/some/target/dir]
      Debug: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: The container Class [Mounts::Some_target_dir] will propagate my refresh event
      Info: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: Scheduling refresh of Mount[/some/target/dir]
      Debug: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: The container Class[Mounts::Some_target_dir] will propagate my refresh event
      Info: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: Scheduling refresh of Mount[/some/target/dir]
      Info: Mount[/some/target/dir](provider=parsed): Remounting
      Debug: Executing /bin/mount -o remount /some/target/dir
      Notice: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: Triggered refresh from 3 events
      Debug: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: The container Class[Mounts::Some_target_dir] will propagate my refresh event
      Info: /Stage[main]Mounts::Some_target_dir/Mount[/some/target/dir]: Scheduling refresh of Mount[/some/target/dir]
      …trim…
      

      ==== “Post-Puppet State” ====

      # mount | grep ‘/some/target/dir’
      1.2.3.4:/some_nfs_vol on /some/target/dir type nfs (rw,nosuid,nodev,bind,_netdev)
       
      # grep ‘some/target/dir’ /etc/fstab
      /some/source_nfs_dir	/some/target/dir	none	_netdev,bind,rw,nosuid,nodev	0	0
       
      # ls -al /some/target/dir
      < contents of location are verifiably those of the NFS volume 1.2.3.4:/some_nfs_vol >
      

      ==== Manual Reproduction of Issue and Fix ====

      # mount -o remount /some/target/dir
      # mount | grep /some/target/dir
      1.2.3.4:/some_nfs_vol on /some/target/dir type fs (rw,nosuid,nodev,bind,_netdev)
      # umount /some/target/dir
      # mount /some/target/dir
      # mount | grep /some/target/dir
      /some/source_nfs_dir on /some/target/dir type none (rw,nosuid,nodev,bind,_netdev)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              Buddha1115 Barry Gestwicki
              QA Contact:
              Eric Thompson
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:

                  Zendesk Support