denshoproject / ddr-cmdln

Command-line tools for automating the Densho Digital Repository's various processes.
Other
0 stars 2 forks source link

Bad url parsing in docstore.delete #176

Open densho opened 4 years ago

densho commented 4 years ago

The syntax for the string formatter that passes the ES host and port to the requests module in docstore.delete is incorrect causing an error when the code attempts to connect to ES.

Note that the item is still successfully deleted from the repo (in this case, it was a File.delete) even though the indexing operation fails. The repo was left in a good state with no hanging commits.

Traceback reads:

  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/opt/ddr-local/ddrlocal/webui/tasks/files.py", line 405, in delete_file
    ds.delete(file_.id)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/ddr_cmdln-0.9.4b0-py2.7.egg/DDR/docstore.py", line 771, in delete
    r = requests.request('DELETE', url)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/opt/ddr-local/venv/ddrlocal/local/lib/python2.7/site-packages/requests/models.py", line 381, in prepare_url
    raise InvalidURL(*e.args)
InvalidURL: Failed to parse: http://[{'host': '10.0.1.135', 'port': '9200'}]/ddrfile/_doc/ddr-pc-44-50-mezzanine-43a80d022e/

See: https://github.com/densho/ddr-cmdln/blob/master/ddr/DDR/docstore.py#L766

densho commented 4 years ago

TODO: @pkikawa Please check that indexing is off in ddrlocal-local.cfg

pkikawa commented 4 years ago

i checked her ddrlocal-local.cfg and it was set to TRUE - i have now changed it to FALSE

i tested deleting a binary on my vm with indexing disabled and it did NOT throw the failure message.

closing issue.

pkikawa commented 4 years ago

or actually did we want it open?