Skip to content

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

@nmaludy

Description

@nmaludy

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*"',
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions