SUSE / Portus

Authorization service and frontend for Docker registry (v2)
http://port.us.org/
Apache License 2.0
3k stars 471 forks source link

In example docker compose, how does "background" talk to the registry? #2275

Closed kylegoetz closed 4 years ago

kylegoetz commented 4 years ago

I am running a docker compose very similar to the example with the DB, portus, portus-in-background, and the registry (plus adminer).

The images I push to the registry succeed, but the Portus UI never reflects the changes. If I log in to the DB with adminer, I can see the images in the registry_events table.

As per the compose file, registry hits the portus container with the webhooks. This explains how the events are showing up in the DB. (And the correct namespace exists in Portus that matches the container's namespace when pushed to the registry.)

My understanding is that you only get the updates if you are running the background process, which ensures the synchronization of registry and DB+Portus.

I am running background as well. However, looking at the compose structure, background depends on portus, but nowhere is portus configured to know about background's existence or URL (which would be http(s)://background:3000 as nginx does not have any mention of background in the config you have for it).

Moreover, background has nothing configured in it to know how to communicate with registry. It depends on the database and portus, but no mention of registry, so how does it ensure the database is synced with the registry?

Is the docker-compose.yml file not set up correctly? Or am I missing something?

kylegoetz commented 4 years ago

Well, the answer appears to be that I needed to put in my docker-compose.yml file under background.environment:

# Sync config
- PORTUS_BACKGROUND_REGISTRY_ENABLED=true
- PORTUS_BACKGROUND_SYNC_ENABLED=true
- PORTUS_BACKGROUND_SYNC_STRATEGY=update

Looks like Portus will only sync with the registry when you first create the containers, but never after that, unless you configure background to sync regularly, which the above does.

I suggest this be added to the example, or an explanation given as to why this is missing, as I can't imagine why anyone would only ever want to import a registry's data on first creation rather than keeping it synced going forward. Is the example just for a read-only demo and no read-write demo?

Jean-Baptiste-Lasselle commented 4 years ago

unless

(All tested on portus 2.4.3)

Hi @kylegoetz Thank you so much for your issue :

I do agree with you, on your point, support your request, and there is a real need for even more...

However

I have a setup where none of :

  background: 
    environment:
    # Sync config
      - PORTUS_BACKGROUND_REGISTRY_ENABLED=true
      - PORTUS_BACKGROUND_SYNC_ENABLED=true
      - PORTUS_BACKGROUND_SYNC_STRATEGY=update

are set for the background

Yet, I do have a webui that refreshes when I docker push a new OCI image.

So setting :

  background: 
    environment:
    # Sync config
      - PORTUS_BACKGROUND_REGISTRY_ENABLED=true
      - PORTUS_BACKGROUND_SYNC_ENABLED=true
      - PORTUS_BACKGROUND_SYNC_STRATEGY=update

has no relation with your problem or solves your problem by accident. Indeed :

As for your accurate problem, I found such issues caused by things like :

Never the less

I also did wonder how the background service could refresh the portus web app, and what I understood, first, is that it's through the database :

But obviously enough as I write now, this flow is weirdo/bizarre (why portus doesn't update database himself ? ), and you remind me of all my tests results :

All in all, thank you so much for this issue, sharing about those env. variables,and I'll read with interest any further comments, add infos, from you.

Jean-Baptiste-Lasselle commented 4 years ago

@kylegoetz honestly, look at https://github.com/SUSE/Portus/issues/2241#issuecomment-586653023 it's crazy :laughing: :rocket: (biiiiiiig thank you)

Jean-Baptiste-Lasselle commented 4 years ago

@kylegoetz about :

why anyone would only ever want to import a registry's data on first creation rather than keeping it synced going forward.

Actually, this is the best business case ever :

Jean-Baptiste-Lasselle commented 4 years ago

Hi @kylegoetz I want today give more info, interesting :

So when you explicitly set your variables, well it did... nothing. So I now even more think that you solved your problem by accident, not by setting those variables you talked about.

I am really interested in any future tests results you'll feedback here.

And I think I can say now, that I characterized a problem with portus documentation, thanks to your issue, see. : https://github.com/SUSE/Portus/issues/2241#issuecomment-586972528

stale[bot] commented 4 years ago

Thanks for all your contributions! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.