trivial rebase script problem

283 views
Skip to first unread message

Lazo Apostolovski

unread,
Jan 21, 2012, 8:49:06 AM1/21/12
to repo-d...@googlegroups.com
Hi

I try to integrate trivial_rebase.py script for patchset-created hook on gerrit, and I have a couple of problems with that.

I created separate new user on gerrit for this and I gives him admin rights (its in Administrators group).

At first when I upload new patch sets suexec command is executed withTraceback (most recent call last): 

(['ssh', '-l', 'Gerrit Code Review', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'myemail...@gmail.com', '--', u"gerrit approve --project testproject --message 'Automatically re-added by Gerrit trivial rebase detection script.' --code-review 1 526930264d146823f62be809dfa3c02a215b39cd"]

I see in gerrit sshd_log that user try to log with "Gerrit Code Review" username. I change this with appropriate username and try again. I do some comments on previous patch set and set code review on +1. I do some changes, rebase and push it again. New patch set was created but my commit messages has not been copied. I see in error.log and I see this message:

  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 226, in <module>
    Main()
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 222, in Main
    ' '.join(gerrit_approve_cmd))
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 127, in SuExec
    CheckCall(suexec_cmd)
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 63, in CheckCall
    raise CheckCallError(command, cwd, process.returncode, std_out, std_err)
__main__.CheckCallError: (['ssh', '-l', 'appropriateusername', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'mye...@gmail.com', '--', u"gerrit approve --project testproject --code-review 1 5ac66c3e58ad14e76afdae6b0be9afb2e69fad64 --message 'Automatically re-added by Gerrit trivial rebase detection script.'"], None, 1, '', None)

any suggestions?

Thank you.

Luciano Carvalho

unread,
Jan 21, 2012, 2:18:49 PM1/21/12
to repo-d...@googlegroups.com

The user must have Forge Identity +3 to run it, if I'm not wrong.

Try to add that permission to the Administrators group and you'll be good.

Luciano.

Lazo Apostolovski

unread,
Jan 23, 2012, 3:35:36 AM1/23/12
to repo-d...@googlegroups.com
Luciano thank you for your response.

I do not have +3 nowhere. I have +2 only on Label Code-Review.
I have Forge Author Identity Allowed administrator.
All other Forge Identity (Forge Committer Identity and Forge Server Identity) are not set. Do I need them for any reason? Cause they only have Allow and Deny.

Also I notice that some times scripts goes into patch id dont match and exit.

This lines of script code:
if cur_patch_id.split()[0] != prev_patch_id.split()[0]:
    # patch-ids don't match
    exit(0)

what is the reason for that? I know patch id don't match, but what patch id?

Thanks you.

Junfeng

unread,
Jan 23, 2012, 7:26:36 AM1/23/12
to repo-d...@googlegroups.com
“九悯

Lazo Apostolovski <lapost...@tricode.nl>编写:

Nasser Grainawi

unread,
Jan 23, 2012, 12:30:44 PM1/23/12
to repo-d...@googlegroups.com
We haven't upgraded to 2.2.2 internally yet, so I haven't updated the script. We'll (hopefully) be upgrading in the next few weeks and I'll post the updated script version with instructions then.

Nasser


-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

Philipp Altmann

unread,
Feb 14, 2012, 5:15:56 AM2/14/12
to Repo and Gerrit Discussion
Hi,

there are any news on this issue?

Cheers
Philipp

On Jan 23, 6:30 pm, Nasser Grainawi <nas...@codeaurora.org> wrote:
> We haven't upgraded to 2.2.2 internally yet, so I haven't updated the script. We'll (hopefully) be upgrading in the next few weeks and I'll post the updated script version with instructions then.
>
> Nasser
>
> On Jan 21, 2012, at 6:49 AM, Lazo Apostolovski wrote:
>
>
>
>
>
>
>
>
>
> > Hi
>
> > I try to integrate trivial_rebase.py script for patchset-created hook on gerrit, and I have a couple of problems with that.
>
> > I created separate new user on gerrit for this and I gives him admin rights (its in Administrators group).
>
> > At first when I upload new patch sets suexec command is executed withTraceback (most recent call last):
>
> > (['ssh', '-l', 'Gerrit Code Review', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'myemailaddr...@gmail.com', '--', u"gerrit approve --project testproject --message 'Automatically re-added by Gerrit trivial rebase detection script.' --code-review 1 526930264d146823f62be809dfa3c02a215b39cd"]
>
> > I see in gerrit sshd_log that user try to log with "Gerrit Code Review" username. I change this with appropriate username and try again. I do some comments on previous patch set and set code review on +1. I do some changes, rebase and push it again. New patch set was created but my commit messages has not been copied. I see in error.log and I see this message:
>
> >   File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 226, in <module>
> >     Main()
> >   File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 222, in Main
> >     ' '.join(gerrit_approve_cmd))
> >   File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 127, in SuExec
> >     CheckCall(suexec_cmd)
> >   File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 63, in CheckCall
> >     raise CheckCallError(command, cwd, process.returncode, std_out, std_err)
> > __main__.CheckCallError: (['ssh', '-l', 'appropriateusername', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'myem...@gmail.com', '--', u"gerrit approve --project testproject --code-review 1 5ac66c3e58ad14e76afdae6b0be9afb2e69fad64 --message 'Automatically re-added by Gerrit trivial rebase detection script.'"], None, 1, '', None)
>
> > any suggestions?
>
> > Thank you.
>
> > --
> > To unsubscribe, email repo-discuss...@googlegroups.com
> > More info athttp://groups.google.com/group/repo-discuss?hl=en

Lazo Apostolovski

unread,
Feb 14, 2012, 5:38:18 AM2/14/12
to repo-d...@googlegroups.com
Hi Philipp

Sorry I can't help you. I leave this for now. I spend to much time on this. If you have some idea I am glad to try assist you.

If I make it work somehow I will let you know. If you have some success please let me know.

Thank you.

JT Olds

unread,
Feb 17, 2012, 4:55:19 PM2/17/12
to Repo and Gerrit Discussion
Um, from your traceback I don't see enough detail to figure out what's
going on with your trivial rebase script configuration, but I got mine
configured just fine with 2.2.1

I made sure there was a "gerrit" user in Gerrit (henceforth referred
to as Gerrit-gerrit), with a new ssh key that the user running gerrit
(referred to as linux-gerrit) on the host box's ssh config knew about
(so, ~gerrit/.ssh/id_rsa). Then I made sure the Gerrit-gerrit user was
in the Administrators group.

Last, I needed to run the trivial rebase script with --private-key-
path $site/etc/ssh_host_dsa_key

All seems to be good to me. It might be helpful if you provided more
detail from your gerrit log, but I don't think compatibility with
2.2.x is the issue.

Philipp Altmann

unread,
Feb 18, 2012, 8:59:39 AM2/18/12
to Repo and Gerrit Discussion
Hi JT Olds,

but we are talking about 2.2.2.x not 2.2.1.

Cheers
Philipp

JT Olds

unread,
Feb 23, 2012, 10:09:19 PM2/23/12
to Philipp Altmann, Repo and Gerrit Discussion
D'oh, sorry. Totally missed that.

I've updated the script to work with 2.2.2.1

All that I found that needed to change was the SQL in the GetApprovals call to:

  sql_query = ("\"SELECT value,account_id,category_id FROM patch_set_approvals "
               "WHERE patch_set_id = %s AND change_id = (SELECT change_id FROM "
               "changes WHERE change_key = \'%s\') AND value <> 0\""
               % ((patchset - 1), changeId))

The full script updated for 2.2.2.1 can be found here: https://gist.github.com/1896929

-JT

Philipp Altmann

unread,
Feb 24, 2012, 7:11:35 AM2/24/12
to Repo and Gerrit Discussion
Hmm. That's crazy. I installed in the testing environment 2.2.2.1 with
trivial_rebase script and I had nothing to change only username, port
etc.

Phil

georgey

unread,
Apr 23, 2013, 3:08:28 PM4/23/13
to repo-d...@googlegroups.com
The tokens in the array starting at u'myemail... may provide goofiness (sp?) to an external shell. Not sure how those were constructed by the python.

Also, in newer Gerrit's there are new parameters passed to the patchset-created hook in the form of "--uploader MyDisplay Name '(mye...@address.com)'" which evaluates to 4 tokens, --branch <branch-name> and --change-url <URL> which may  need an interceptor script to filter/sanitize.

On Saturday, 21 January 2012 08:49:06 UTC-5, Lazo Apostolovski wrote:
Hi

I try to integrate trivial_rebase.py script for patchset-created hook on gerrit, and I have a couple of problems with that.

I created separate new user on gerrit for this and I gives him admin rights (its in Administrators group).

At first when I upload new patch sets suexec command is executed withTraceback (most recent call last): 

(['ssh', '-l', 'Gerrit Code Review', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'myemail...@gmail.com', '--', u"gerrit approve --project testproject --message 'Automatically re-added by Gerrit trivial rebase detection script.' --code-review 1 526930264d146823f62be809dfa3c02a215b39cd"]

I see in gerrit sshd_log that user try to log with "Gerrit Code Review" username. I change this with appropriate username and try again. I do some comments on previous patch set and set code review on +1. I do some changes, rebase and push it again. New patch set was created but my commit messages has not been copied. I see in error.log and I see this message:

  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 226, in <module>
    Main()
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 222, in Main
    ' '.join(gerrit_approve_cmd))
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 127, in SuExec
    CheckCall(suexec_cmd)
  File "/home/qbox/gerrit/Dzjinn/hooks/trivial_rebase.py", line 63, in CheckCall
    raise CheckCallError(command, cwd, process.returncode, std_out, std_err)
__main__.CheckCallError: (['ssh', '-l', 'appropriateusername', '-p', '29418', 'localhost', '-i', '/home/qbox/.ssh/id_rsa', 'suexec', '--as', u'my...@gmail.com', '--', u"gerrit approve --project testproject --code-review 1 5ac66c3e58ad14e76afdae6b0be9afb2e69fad64 --message 'Automatically re-added by Gerrit trivial rebase detection script.'"], None, 1, '', None)

any suggestions?

Thank you.

Pursehouse, David (Sony Mobile)

unread,
Apr 23, 2013, 8:21:33 PM4/23/13
to georgey, repo-d...@googlegroups.com

Note that the trivial_rebase script has been refactored quite a lot [1] in the 2.6 release.

 

[1] https://gerrit-review.googlesource.com/#/q/status:merged+project:gerrit+branch:stable-2.6+topic:trivial-rebase,n,z

--

---
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/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages