Is it possible to provide a REST API and UI from the replica servers? For example HTTP authentication

195 views
Skip to first unread message

hanji wang

unread,
Jul 6, 2022, 11:58:58 AM7/6/22
to Repo and Gerrit Discussion
20220705-111906.png

Matthias Sohn

unread,
Jul 6, 2022, 5:54:30 PM7/6/22
to hanji wang, Repo and Gerrit Discussion
On Wed, Jul 6, 2022 at 5:58 PM hanji wang <whzsanw...@gmail.com> wrote:
20220705-111906.png


No, replica servers do not serve REST API, UI and search index.
You may consider using a multi-master or multi-site setup.

-Matthias

程洋

unread,
Jul 6, 2022, 10:54:11 PM7/6/22
to Repo and Gerrit Discussion
Even if replica doesn't support restAPI. Does it serve git fetch and clone via HTTP/HTTPS with authentication?
ASAIK, replica is for fetch and clone. Then how can i authenticate users by HTTPS?

Matthias Sohn

unread,
Jul 7, 2022, 3:14:20 AM7/7/22
to 程洋, Repo and Gerrit Discussion
On Thu, Jul 7, 2022 at 4:54 AM 程洋 <d171...@gmail.com> wrote:
Even if replica doesn't support restAPI. Does it serve git fetch and clone via HTTP/HTTPS with authentication?
ASAIK, replica is for fetch and clone. Then how can i authenticate users by HTTPS?

Can you please avoid top posting on this list and use interleaved posting instead ?
Please also avoid posting the same question in multiple threads since this scatters the discussion.

Yes, you need to configure the auth section of both primary and replica consistently according to your needs.
You didn't post your configuration hence it's hard to guess what you are trying to do.
User accounts and their settings are to be replicated from the primary to the replica server so that they are also
available there. They reside in the All-Users repository.

-Matthias

On Thursday, July 7, 2022 at 5:54:30 AM UTC+8 Matthias Sohn wrote:
On Wed, Jul 6, 2022 at 5:58 PM hanji wang <whzsanw...@gmail.com> wrote:
20220705-111906.png


No, replica servers do not serve REST API, UI and search index.
You may consider using a multi-master or multi-site setup.

-Matthias

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/eab3f326-b83f-4543-bcbc-b51ea8931b0an%40googlegroups.com.

hanji wang

unread,
Jul 7, 2022, 3:56:03 AM7/7/22
to Repo and Gerrit Discussion
Sorry, I will only use this thread to discuss related issues in the future.


We intend to git clone from the replica server using HTTP protocol only, and operations such as git push occur on the master server.
In actual use, it is found that there is no authentication when the replica server performs git clone, and anyone can git clone.
What we want is that the replica server can authenticate the git clone operation like the master server.

Nasser Grainawi

unread,
Jul 7, 2022, 9:00:57 PM7/7/22
to hanji wang, Repo and Gerrit Discussion
On Thu, Jul 7, 2022 at 1:56 AM hanji wang <whzsanw...@gmail.com> wrote:
Sorry, I will only use this thread to discuss related issues in the future.

Thank you, I'll reply here too. You're still top posting though. https://en.wikipedia.org/wiki/Posting_style#Top-posting
 


We intend to git clone from the replica server using HTTP protocol only, and operations such as git push occur on the master server.
In actual use, it is found that there is no authentication when the replica server performs git clone, and anyone can git clone.
What we want is that the replica server can authenticate the git clone operation like the master server.

Please share the gerrit.config (especially the 'auth' section) from your primary server and your replica. They should be very similar except for the 'replica = ' value.
 

hanji wang

unread,
Jul 8, 2022, 5:23:12 AM7/8/22
to Repo and Gerrit Discussion
Below is mine gerrit.conf

master:
master.png


replica:
slave.png

Also, I don't know how to make my other posts stop being top posting.I will not reply in it.

hanji wang

unread,
Jul 12, 2022, 8:12:12 AM7/12/22
to Repo and Gerrit Discussion
Probably because I didn't describe the problem clearly.Below are my questions

Notice:
1.All the following operations use the HTTP protocol
2.We disable read access from anonymous user on all projects
3.We have two Gerrit servers, one primary and one replica:
primary ip: 82.157.232.50
replica ip: 101.42.251.175
4.primary gerrit.config
master.png

5.replica gerrit.config
slave.png


What experiment did i do?
1. Execute git clone[1] from primary server
[root@VM-8-11-centos code]# git clone "http://82.157.232.50:8080/a/sync_repo"
Cloning into 'sync_repo'...
Username for 'http://82.157.232.50:8080': admin
remote: Counting objects: 26, done
remote: Finding sources: 100% (26/26)
remote: Total 26 (delta 5), reused 24 (delta 5)
Receiving objects: 100% (26/26), 2.26 KiB | 2.26 MiB/s, done.
Resolving deltas: 100% (5/5), done.

2. Execute git clone[2] from primary server
[root@VM-8-11-centos code]# git clone "http://82.157.232.50:8080/sync_repo"
Cloning into 'sync_repo'...
warning: You appear to have cloned an empty repository.

3. Execute git clone[3] from replica server
[root@VM-8-11-centos code]# git clone "http://101.42.251.175:8080/a/sync_repo"
Cloning into 'sync_repo'...
warning: You appear to have cloned an empty repository.

4. Execute git clone[4] from replica server
[root@VM-8-11-centos code]# git clone "http://101.42.251.175:8080/sync_repo"
Cloning into 'sync_repo'...
warning: You appear to have cloned an empty repository.

What is the expected output?
When doing git clone [3], I am able to clone the full repository and require a username and password for Gerrit authentication

What do you see instead?
[root@VM-8-11-centos code]# git clone "http://101.42.251.175:8080/a/sync_repo"
Cloning into 'sync_repo'...
warning: You appear to have cloned an empty repository.
Clone an empty repository, and no username, password authentication appears

You can try to execute the command [1][2][3][4]

Björn Pedersen

unread,
Jul 13, 2022, 11:46:17 AM7/13/22
to Repo and Gerrit Discussion


The problems is that you are running the replica with a different server id, it should be set to the primary server id. See




hanji wang

unread,
Jul 13, 2022, 10:45:27 PM7/13/22
to Repo and Gerrit Discussion
Thanks.

I set the gerrit.serverId of the replica server to be the same as the primary server.Then try to do git clone[1] again, and the displayed result did not change from before. It doesn't seem to use the data in NoteDb. 

The execution result is as follows
[root@VM-8-11-centos code]# git clone "http://101.42.251.175:8080/a/sync_repo
Cloning into 'sync_repo'... 
warning: You appear to have cloned an empty repository.

Nasser Grainawi

unread,
Jul 14, 2022, 1:15:55 PM7/14/22
to hanji wang, Repo and Gerrit Discussion
On Wed, Jul 13, 2022 at 8:45 PM hanji wang <whzsanw...@gmail.com> wrote:
Thanks.

I set the gerrit.serverId of the replica server to be the same as the primary server.Then try to do git clone[1] again, and the displayed result did not change from before. It doesn't seem to use the data in NoteDb. 

Did you reindex the replica after updating the serverId? I'm not certain it would affect anything, but it could.
 

The execution result is as follows
[root@VM-8-11-centos code]# git clone "http://101.42.251.175:8080/a/sync_repo
Cloning into 'sync_repo'... 
warning: You appear to have cloned an empty repository.

在2022年7月13日星期三 UTC+8 23:46:17<ice...@googlemail.com> 写道:


The problems is that you are running the replica with a different server id, it should be set to the primary server id. See




--
--
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.

hanji wang

unread,
Jul 18, 2022, 10:16:20 PM7/18/22
to Repo and Gerrit Discussion
Thank you for your replies, it helped me a lot.

I found another reason for this problem. When I made the following modifications, and executed git clone [1] from the replication server, authentication appeared and the complete code could be cloned.
But I don't know why it solves the problem

[access "refs/meta/version"] 
-    read = group Anonymous Users
+    read = group Registered Users
auth.png

hanji wang

unread,
Jul 19, 2022, 5:39:31 AM7/19/22
to Repo and Gerrit Discussion
Or you need to remove all Anonymous Users in All-Projects, I have not tested this
Reply all
Reply to author
Forward
0 new messages