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

Trigger for an --action=add is not working #23

Open
nmaludy opened this issue Jan 22, 2017 · 1 comment · May be fixed by #29
Open

Trigger for an --action=add is not working #23

nmaludy opened this issue Jan 22, 2017 · 1 comment · May be fixed by #29

Comments

@nmaludy
Copy link

nmaludy commented Jan 22, 2017

I have a udev rule that increases block timeouts for virtual machine block devices:

# cat /etc/udev/rules.d/99-blk-timeout.rules 
ACTION=="add", SUBSYSTEMS=="scsi", ATTRS{vendor}=="VMware*", ATTRS{model}=="Virtual disk*", RUN+="/bin/sh -c 'echo 119 >/sys$DEVPATH/timeout'"

Executing a simple udevadm trigger does not invoke the "add" event needed to apply this rule.

To get this to work from the command like i have to run the following:

udevadm trigger --action="add" --subsystem-match="scsi" --attr-match=vendor="VMware*" --attr-match=model="Virtual disk*"

Or, in the case of puppet i've created an exec {} resources to perform this.

  # Set timeout to 120 seconds for all VMware block devices
  # to test: udevadm info -q all -a /dev/sda | grep timeout
  udev::rule { '99-blk-timeout.rules':
    ensure  => present,
    content => "ACTION==\"add\", SUBSYSTEMS==\"scsi\", ATTRS{vendor}==\"VMware*\", ATTRS{model}==\"Virtual disk*\", RUN+=\"/bin/sh -c 'echo 119 >/sys\$DEVPATH/timeout\'\"\n",
    notify  => Exec['udevadm trigger 99-blk-timeout.rules'],
  }
  # end udev rule
  exec { 'udevadm trigger 99-blk-timeout.rules':
    command     => '/usr/sbin/udevadm trigger --action="add" --subsystem-match="scsi" --attr-match=vendor="VMware*" --attr-match=model="Virtual disk*"',
    refreshonly => true,
    subscribe   => Udev::Rule['99-blk-timeout.rules'],
  }
  # end execute udevadm trigger

This is an OK solution, however udevadm trigger is being called twice. Once by udevadm::trigger and once by my exec call.

It would be awesome if we could pass in additional options into the udevadm trigger command so i didn't need my extra exec resource.

Maybe something like:

  udev::rule { '99-blk-timeout.rules':
    ensure  => present,
    content => "ACTION==\"add\", SUBSYSTEMS==\"scsi\", ATTRS{vendor}==\"VMware*\", ATTRS{model}==\"Virtual disk*\", RUN+=\"/bin/sh -c 'echo 119 >/sys\$DEVPATH/timeout\'\"\n",
    trigger_options => '--action="add" --subsystem-match="scsi" --attr-match=vendor="VMware*" --attr-match=model="Virtual disk*"',
  }
@jhoblitt
Copy link
Owner

jhoblitt commented Feb 2, 2017

Currently, the exec is only invoked once for all rules. Things would need to be re-plumbed so that a per rule exec resource is used if custom options are specified.

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 a pull request may close this issue.

2 participants