docker-hook icon indicating copy to clipboard operation
docker-hook copied to clipboard

Not working anymore with docker registry 2 ?

Open kheraud opened this issue 9 years ago • 1 comments

I see exceptions raised by docker-hook for every single action I do with my registry.

Exception happened during processing of request from ('127.0.0.1', 41065)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/usr/local/bin/docker-hook", line 40, in do_POST
    for var, val in json_params['repository'].items())
KeyError: 'repository'

This issue comes from the fact that docker-hook expects the POSTed Json to contain a single event. Digging in the code, it seems that nothing is built to handle "grouped" events ({events: [...]})

Docker doc for registry notifications states:

While events may be sent in the same envelope, the set of events within that envelope have no implied relationship. For example, the registry may choose to group unrelated events and send them in the same envelope to reduce the total number of requests.

I am wondering if the script is made to be used with docker registry 2 (private registry) ?

kheraud avatar Aug 12 '16 09:08 kheraud

If any data is included, that does not parse as JSON, the json parser will throw this exception. I made a pull-request with a fix for this (pr #16).

stixes avatar Feb 22 '18 13:02 stixes