Only first state hook triggers with 5.10

Hi. I have upgraded to 5.10 and now trying to port my hooks to the new hooks manager system. Conversion was quite easy, but looks like only the first defined hook is triggered on events.

For example, I had 3 hooks which were triggered on VM DONE. 2 of them were local, 1 was remote. I’ve added them to the hooks manager. But now only the one which was added first is triggered on DONE. Ok, I kinda can combine 2 of them, but remote hook has to be run on the remote host. Do I miss something?

Hi @divanikus ,

I’ve developed a script(hookmux.sh) to mitigate this issue.

The Idea is to register only one script for a hook event which will call all scripts in a folder.
So to use the script:

  1. copy hookmux.sh to /var/lib/one/remotes/hooks
cp hookmux.sh /var/lib/one/remotes/hooks/
  1. Create a symlink with the name that will be registered in the hook manager for example active-hotplug_nic
cd /var/lib/one/remotes/hooks
ln -s hookmux.sh active-hotplug_nic
  1. Create a directory where to place the script with named ${symlinkname}.d/
mkdir /var/lib/one/remotes/hooks/active-hotplug_nic.d
  1. Copy the scripts that must be called on this event in ${symlinkname}.d/ folder. The scripts that should be called on the remote host must have .remote in the end.
cp localscript /var/lib/one/remotes/hooks/active-hotplug_nic.d/localscript
cp remotescript /var/lib/one/remotes/hooks/active-hotplug_nic.d/remotescript.remote
  1. Sync the hosts
su - oneadmin -c 'onehost sync --force --rsync'
  1. Define a hook in the hook manager that is executed locally and have the VM template passed to stdin
...
COMMAND="active-hotplug_nic"
ARGUMENTS="$TEMPLATE"
ARGUMENTS_STDIN="YES"
REMOTE="NO"
...

When the hook is triggered the alias the hookmux.sh is called. It will accept the template on the STDIN, look for a folder named {alias}.d/ and call each executable file or symlink passing the $TEMPLATE to the stdin. If the symlink is ending on *.remote it will execute the script on last know host where the VM was running.

Hope this helps.

Edit: Added hosts sync as point 5.

Best Regards,
Anton Todorov

I believe it’s a bug and regression within hooks manager. I’ve created an issue about it: https://github.com/OpenNebula/one/issues/4449

Also, I’ve fixed it myself for my installation (see the comment section of the bug). Waiting for devs’ response.

Great,

I have’nt time to look at the code so wrote the wrapper script instead untill the issue is fixed upstream :slight_smile:

Best Regards,
Anton Todorov