-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows using robot accounts for Image replication #14905
Allows using robot accounts for Image replication #14905
Conversation
Codecov Report
@@ Coverage Diff @@
## master #14905 +/- ##
==========================================
+ Coverage 66.99% 67.01% +0.01%
==========================================
Files 930 930
Lines 76328 76327 -1
Branches 2233 2233
==========================================
+ Hits 51139 51153 +14
+ Misses 21278 21262 -16
- Partials 3911 3912 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
135a2e3
to
b76a50c
Compare
Signed-off-by: Vadim Bauer <vb@container-registry.com>
Signed-off-by: Vadim Bauer <vb@container-registry.com>
e5549d3
to
6aa517c
Compare
@Vad1mo, I think adding docs around this scenario will be helpful for users. can you write up some more context here about this use case? Or create an issue so we can track adding this into the docs? thanks! |
@reasonerjt can you check that please? |
Hi @wy65701436 I would be super interested in the issue with merging this bugfix? To me this seems to be a fairly obvious improvement of code quality and stability of Harbor. The current code which first retrieves the unfiltered list of all projects and then gets the wanted one by looping over them in memory to me seems to be a clear antipattern. It will cause sluggishness - especially when a Harbor instance is managing more and more projects. |
To make robot account support image replicaiton will in the next release, I'll have a review on the current design and find out the gaps. There are some details that needs to be discussed. |
@wy65701436 this PR makes Replication possible. We currently run replication like this. Let me know if I can be of any help |
@wy65701436 even though the title suggests otherwise, from my perspective this is really just a code quality improvement / bugfix. The fact that it also fixes replication using robot accounts (which does work! We're using a version of Harbor with this patch in production), is merely a nice side-effect. |
@Vad1mo do you allow every authenticated user to create projects? |
I don't know, probably yes as this is the default setting. Does this make any difference. |
harbor wants to create the project in the prepare method of the replication adpater, regadless if the project exists (it just ignores the error in this case). but if only admins are allowed to create projects, this api call will never succeed (old problem, mixing system and project level permissions in robot acocunts). we also had to patch out the code for creating the project in the prepare method and the replication succeeded (#14982). |
thank you @wy65701436, Would this PR not still make sense? Instead of iterating over |
This patch (more of a bug fix) will allow using robot accounts for image replication.
Currently, it is not possible to create a robot account that can replicate images from one Harbor registry to another. (You need a System Admin account, big no go in corp environments)
The patch only changes
getProject
to call the API directly, instead of filtering the list ofgetProjects
becausegetProjects
needs admin level permission and hence is not possible to be used with robot accounts.Side Effects
The change has no or littel side effects:
its only called by
listProjects
and is always providing and expect a single result,This patch only works for Harbor => 2.2.0 and resolves a bunch of open issues.
resolves #14640, resolves #13384, resolves #13795
related #8723
How to creaet a Robot Accounts for Replication
In order to a replication with robot accounts, a robot account with those permissions needs to be created.
Permissions needed for robot accounts.
Signed-off-by: Vadim Bauer vb@container-registry.com