-
Notifications
You must be signed in to change notification settings - Fork 157
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
feat: Implement Image Rescanning using Harbor Webhook API #3116
base: topic/11-13-feat_implement_management_api_for_controlling_harbor_per-project_quota
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
bb8a301
to
8b4b017
Compare
I tried to implement logic to remove the ImageRow upon receiving a In the case of the However, for |
5c30e46
to
6e92403
Compare
573457b
to
2d4af78
Compare
6e92403
to
b7773cc
Compare
|
||
query = sa.select(ContainerRegistryRow).where( | ||
(ContainerRegistryRow.type == ContainerRegistryType.HARBOR2) | ||
& (ContainerRegistryRow.url.like(f"%{registry_url}%")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ideal to check using registry_name
, but the Harbor webhook request does not include registry_name
information.
@@ -428,6 +428,16 @@ async def auth_middleware(request: web.Request, handler) -> web.StreamResponse: | |||
Fetches user information and sets up keypair, user, and is_authorized | |||
attributes. | |||
""" | |||
allow_list = request.app["auth_middleware_allowlist"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lot of other code accessing the RootContext
field stored in request.app[“_root.context”]
, is there a reason why you stored it directly in the app here?
I'd like to know what separates the cases that access app directly from those that access RootContext. @achimnol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RootContext
contains mutable configurations such as local_config
and shared_config
, as well as many objects that are frequently accessed throughout the codebase.
So I thought it might be better to inject hardcoded values into the app
instead.
(But this is just my personal opinion.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be fine if the API was only used for harbor webhooks.
The API currently supports only Harbor webhooks, but it could be expanded to accommodate other container registries's webhook in the future. |
b4b1ee6
to
628d41a
Compare
d0186e5
to
f4a60c4
Compare
628d41a
to
e6dfa69
Compare
…ng_harbor_per-project_quota' into topic/11-19-feat_implement_image_rescan_based_on_harbor_webhook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be merged.
Resolves #1913 (BA-143).
Important
Currently, the Image Rescanning through Webhook API implemented in this PR is only available for the HarborV2 registry.
Details
auth_middleware
. It would be great to generalize this approach or find a better solution in the following works.Implementation details
Events to Monitor
We will need to pay attention to the following events to ensure the image table is updated automatically.
PUSH_ARTIFACT
DELETE_ARTIFACT
Events to ignore
We won't need to care about the following events in this PR.
PULL_ARTIFACT
UPLOAD_CHART
DOWNLOAD_CHART
DELETE_CHART
SCANNING_COMPLETED
SCANNING_FAILED
QUOTA_EXCEED
QUOTA_WARNING
REPLICATION
How to setup webhook
webhook_auth_header
to theContainerRegistry
row'sextra
column. Event handler is executed only when thewebhook_auth_header
equals the auth header value set in the webhook policy. If the auth header in the webhook policy is empty, the event handler will still be executed even if thewebhook_auth_header
is not set.Tip
We don't need to subscribe to events for which event handlers are not implemented.
Checklist: (if applicable)
📚 Documentation preview 📚: https://sorna--3116.org.readthedocs.build/en/3116/
📚 Documentation preview 📚: https://sorna-ko--3116.org.readthedocs.build/ko/3116/