Skip to content
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

mount resource is not idempotent with label #8260

Open
limitusus opened this Issue Mar 1, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@limitusus
Copy link

limitusus commented Mar 1, 2019

Description

mount resource infinitely tries to enable the resource with device_type :label.
After run, /etc/fstab file is unchanged.

I dumped out the current_resource and new_resource with some attributes:

enabled: true false
device: LABEL=/mnt/foo /mnt/foo
device_type: device label
mount_point: /mnt/foo /mnt/foo
fstype: ext4 ext4
options: ["defaults", "nofail"] ["defaults", "nofail"]
dump: 0 0
pass: 2 2

Chef-client tries to continue enabling this resource because, Chef::Provider::Mount#action_enabled judges whether to enable the resource when current_resource.enabled && mount_options_unchanged? && device_unchanged? is falsey (https://github.com/chef/chef/blob/master/lib/chef/provider/mount.rb#L123-L129)
And device_unchaged? implementation is @current_resource.device == @new_resource.device, so device of current_resource and new_resource differs, as current_resource's one is from the first column of /etc/fstab and new_resource's one is from mount resource definition.
To make this resource idempotent, I think the device_unchaged? implementation need to be fixed.

(I noticed this issue yesterday, just after upgrading chef-client from v13 to v14. With v13 this resource had been idempotent.)

Chef Version

14.10.9

Platform Version

AmazonLinux 1

Replication Case

On EC2, mount the EBS volume like the following

dir = "/mnt/foo
mount dir do
  device_type :label
  device '/mnt/foo'
  fstype 'ext4'
  options 'defaults,nofail'
  action [:mount, :enable]
end

Client Output

This log is whyrun log with -l trace option

[2019-03-02T00:26:42+09:00] INFO: Processing mount[/mnt/foo] action mount (foo_base::nfs-common line 23)
[2019-03-02T00:26:42+09:00] TRACE: Providers for generic mount resource enabled on node include: [Chef::Provider::Mount::Mount]
[2019-03-02T00:26:42+09:00] TRACE: Provider for action mount on resource mount[/mnt/foo] is Chef::Provider::Mount::Mount
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=2013548k,nr_inodes=503387,mode=755)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime)
/dev/xvda1 on / type ext4 (rw,noatime,data=ordered)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
none on /sys/kernel/debug type debugfs (rw,relatime)
/dev/xvdf on /mnt/foo type ext4 (rw,relatime,data=ordered)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
sunrpc on /proc/fs/nfsd type nfsd (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
/dev/xvdf
[2019-03-02T00:26:42+09:00] TRACE: Special device /dev/xvdf with label /mnt/foo mounted as /mnt/foo
[2019-03-02T00:26:42+09:00] TRACE: Found mount LABEL=/mnt/foo to /mnt/foo in /etc/fstab
[2019-03-02T00:26:42+09:00] TRACE: mount[/mnt/foo] is already mounted
.[2019-03-02T00:26:42+09:00] INFO: Processing mount[/mnt/foo] action enable (foo_base::nfs-common line 23)
[2019-03-02T00:26:42+09:00] TRACE: Providers for generic mount resource enabled on node include: [Chef::Provider::Mount::Mount]
[2019-03-02T00:26:42+09:00] TRACE: Provider for action enable on resource mount[/mnt/foo] is Chef::Provider::Mount::Mount
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=2013548k,nr_inodes=503387,mode=755)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime)
/dev/xvda1 on / type ext4 (rw,noatime,data=ordered)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
none on /sys/kernel/debug type debugfs (rw,relatime)
/dev/xvdf on /mnt/foo type ext4 (rw,relatime,data=ordered)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
sunrpc on /proc/fs/nfsd type nfsd (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
/dev/xvdf
[2019-03-02T00:26:42+09:00] TRACE: Special device /dev/xvdf with label /mnt/foo mounted as /mnt/foo
[2019-03-02T00:26:42+09:00] TRACE: Found mount LABEL=/mnt/foo to /mnt/foo in /etc/fstab

Stacktrace

N/A

@voroniys

This comment has been minimized.

Copy link

voroniys commented Mar 18, 2019

I have this issue too.
Chef client version 14.11.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.