hooks error while pushing to gerrit

990 views
Skip to first unread message

Ashwini T R

unread,
Feb 24, 2017, 5:49:19 AM2/24/17
to Repo and Gerrit Discussion
Hi,

We are getting below error while pushing to Gerrit even though the hooks are not enabled for the project.

remote: error: internal error while processing changes
To ssh://<user_account>@<host_name>:8282<repo>i
 ! [remote rejected] <branch> -> <branch> (Error running hook /opt/gerrit/hooks/ref-update)
error: failed to push some refs to ssh://<user_account>@<host_name>:8282<repo>i


Please provide solution for the error.

Regards
Ashwini

David Pursehouse

unread,
Feb 24, 2017, 7:05:08 AM2/24/17
to Ashwini T R, Repo and Gerrit Discussion
On Fri, Feb 24, 2017 at 7:49 PM Ashwini T R <ashu.r...@gmail.com> wrote:
Hi,

We are getting below error while pushing to Gerrit even though the hooks are not enabled for the project.


What do you mean "not enabled for the project"?  Hooks are global; they are executed for all projects.

If there is a hook file with the appropriate name in $site_path/hooks/ it will be executed.  To disable the hook, remove that file.

Alternatively if you're using 2.13, you can disable hooks completely by uninstalling the hooks plugin.
 
remote: error: internal error while processing changes
To ssh://<user_account>@<host_name>:8282<repo>i
 ! [remote rejected] <branch> -> <branch> (Error running hook /opt/gerrit/hooks/ref-update)
error: failed to push some refs to ssh://<user_account>@<host_name>:8282<repo>i


Push will be rejected if the ref-update hook returns a non-zero exit status or fails for some other reason.
 

Please provide solution for the error.

See above.  If the hook has failed unexpectedly there should be something in the error log on the server.
 

Regards
Ashwini

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sheik Farzand

unread,
Feb 28, 2017, 9:24:57 AM2/28/17
to Repo and Gerrit Discussion, ashu.r...@gmail.com
Hi David,

Me and Ashwini are working in same team.

Let me explain the issue.
We are using 2.13.2 and we have hooks plugin in place. We all know hooks are global and get executed for all project. Logs will get captured here "$site_path/hooks/hook.log".
This log will get generated for both $site_path/hooks/ref-update and $site_path/hooks/ref-updated. Each time when we push a ref, ref-update and ref-updated will get executed and they generate logs. And "$site_path/hooks/subhooks" script will also get invoked by ref-update and ref-updated.

Everything works fine, nothing to complain. But the problem comes when we try to migrate a big project from, let us say github or any other git tool, to gerrit. This big project contains huge number of refs. When we do a mirror push or push --all something like that, it is causing the trouble and throw us the error(which ashwini posted here initially).

We found out that, when we push huge number of refs in single push, the hooks are getting executed continuously for each and every refs which is being pushed to server. The hooks script is unable to process that much times of execution in short period of time.

Now we want to exclude one or few projects from running the hooks. Is there any way to remove the hooks execution particularly one or few projects?

Please reply, if you need more clarification on this. We would be very grateful to you if you can shed some light on us.

Thanks
Sheik Farzand

Martin Fick

unread,
Feb 28, 2017, 11:21:02 AM2/28/17
to repo-d...@googlegroups.com, Sheik Farzand, ashu.r...@gmail.com
On Tuesday, February 28, 2017 06:24:57 AM Sheik Farzand
wrote:
> Now we want to exclude one or few projects from running
> the hooks. Is there any way to remove the hooks execution
> particularly one or few projects?

We code the hook itself to not execute its task for certain
projects, maybe that will work for you?

-Martin

David Pursehouse

unread,
Feb 28, 2017, 8:52:20 PM2/28/17
to Sheik Farzand, Repo and Gerrit Discussion, ashu.r...@gmail.com
On Tue, Feb 28, 2017 at 11:24 PM Sheik Farzand <sheikf...@gmail.com> wrote:
Hi David,

Me and Ashwini are working in same team.

Let me explain the issue.
We are using 2.13.2 and we have hooks plugin in place. We all know hooks are global and get executed for all project. Logs will get captured here "$site_path/hooks/hook.log".
This log will get generated for both $site_path/hooks/ref-update and $site_path/hooks/ref-updated. Each time when we push a ref, ref-update and ref-updated will get executed and they generate logs. And "$site_path/hooks/subhooks" script will also get invoked by ref-update and ref-updated.

Everything works fine, nothing to complain. But the problem comes when we try to migrate a big project from, let us say github or any other git tool, to gerrit. This big project contains huge number of refs. When we do a mirror push or push --all something like that, it is causing the trouble and throw us the error(which ashwini posted here initially).

We found out that, when we push huge number of refs in single push, the hooks are getting executed continuously for each and every refs which is being pushed to server. The hooks script is unable to process that much times of execution in short period of time.

Thanks for providing more context.  This seems to be the same problem as discussed in a separate topic on the mailing list yesterday [1].  Namely, the ref-update hook is executed for each commit being pushed rather than only for the last commit in a series.  Note that this should not be the case for ref-updated, which should behave correctly according to the integration tests.


 

Now we want to exclude one or few projects from running the hooks. Is there any way to remove the hooks execution particularly one or few projects?

There is no way to configure it such that the hook is not executed for specific projects.  One way is to code the hook to ignore certain projects, as Martin suggested.  Another way would be to disable the hook on the server (move it to another location, or rename it to something like "ref-update-disabled") temporarily while you do the push of many commits.

Sheik Farzand

unread,
Mar 1, 2017, 12:00:04 AM3/1/17
to Repo and Gerrit Discussion, sheikf...@gmail.com, ashu.r...@gmail.com
Hi David and Martin,

Thank you for replying.

>>"One way is to code the hook to ignore certain projects, as Martin suggested."
>>"We code the hook itself to not execute its task for certain
projects, maybe that will work for you? "

We can code the hook in such a way to ignore certain projects. But what if i need to enable hook for those projects in future?
Currently  i am using the below work around for this issue. My ref-update and ref-updated script looks like below
==============================
[root@localhost hooks]# cat ref-update
#!/bin/bash

if grep -Fxq "$2" /$site_path/hooks/exld_repos; then exit 0; else

me=$0
hookname=`basename $me`
wkdir=`dirname $me`
#echo "$hookname : $*" >> $wkdir/hook.log
$wkdir/subhooks $hookname $*

fi
[root@localhost hooks]#
=================================

I created a file named "exld_repos" and put all the project names which i need to ignore in that. In future if i need to enable a project, i will just remove the project name from the list. This looks simple than coding the hook. Please tell me if this workaround is also a good one when compared to what you have suggested(coding the hook).

Now i need a better workaround. Something which an end user can do without server admin's intervention. For example, If an end user is trying to push a big project. He should able to disable/enable the hooks for his project from client end without the help of server admin. I guess this is not possible, but i would really like to hear your opinion about this since you have much better knowledge about Gerrit hooks.

Thanks
Sheik Farzand

David Pursehouse

unread,
Mar 1, 2017, 12:45:29 AM3/1/17
to Sheik Farzand, Repo and Gerrit Discussion, ashu.r...@gmail.com
On Wed, Mar 1, 2017 at 2:00 PM Sheik Farzand <sheikf...@gmail.com> wrote:
Hi David and Martin,

Thank you for replying.

>>"One way is to code the hook to ignore certain projects, as Martin suggested."
>>"We code the hook itself to not execute its task for certain
projects, maybe that will work for you? "

We can code the hook in such a way to ignore certain projects. But what if i need to enable hook for those projects in future?
Currently  i am using the below work around for this issue. My ref-update and ref-updated script looks like below
==============================
[root@localhost hooks]# cat ref-update
#!/bin/bash

if grep -Fxq "$2" /$site_path/hooks/exld_repos; then exit 0; else

me=$0
hookname=`basename $me`
wkdir=`dirname $me`
#echo "$hookname : $*" >> $wkdir/hook.log
$wkdir/subhooks $hookname $*

fi
[root@localhost hooks]#
=================================

I created a file named "exld_repos" and put all the project names which i need to ignore in that. In future if i need to enable a project, i will just remove the project name from the list. This looks simple than coding the hook. Please tell me if this workaround is also a good one when compared to what you have suggested(coding the hook).

Now i need a better workaround. Something which an end user can do without server admin's intervention. For example, If an end user is trying to push a big project. He should able to disable/enable the hooks for his project from client end without the help of server admin. I guess this is not possible, but i would really like to hear your opinion about this since you have much better knowledge about Gerrit hooks.

It's probably feasible to implement project-specific configuration for hooks, but since it's a niche feature that not many people need I don't think it's likely to get done very soon.   I would rather spend effort on fixing the root cause of the issue, which is that the hook is called for all commits of a bulk push.

BTW can you confirm that this problem is also occurring for the ref-updated hook?  This should not be the case.

Sheik Farzand

unread,
Mar 1, 2017, 10:02:42 AM3/1/17
to Repo and Gerrit Discussion, sheikf...@gmail.com, ashu.r...@gmail.com
Hi David,


<<<BTW can you confirm that this problem is also occurring for the ref-updated hook?  This should not be the case.>>>>
This problem is not occurring for ref-updated hook, it is occurring only for ref-update. I can confirm that.

Thanks
Sheik Farzand

Saša Živkov

unread,
Mar 1, 2017, 10:57:41 AM3/1/17
to Sheik Farzand, Repo and Gerrit Discussion, Ashwini T R
On Tue, Feb 28, 2017 at 3:24 PM, Sheik Farzand <sheikf...@gmail.com> wrote:
Hi David,

Me and Ashwini are working in same team.

Let me explain the issue.
We are using 2.13.2 and we have hooks plugin in place. We all know hooks are global and get executed for all project. Logs will get captured here "$site_path/hooks/hook.log".
This log will get generated for both $site_path/hooks/ref-update and $site_path/hooks/ref-updated. Each time when we push a ref, ref-update and ref-updated will get executed and they generate logs. And "$site_path/hooks/subhooks" script will also get invoked by ref-update and ref-updated.

Everything works fine, nothing to complain. But the problem comes when we try to migrate a big project from, let us say github or any other git tool, to gerrit. This big project contains

If it is about a one-time import only, then one simple option is to login into the machine running Gerrit,
go to the (bare) repository and fetch directly from the remote (github) repo.
 

--
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages