AtlasOfLivingAustralia / image-service

Image repository and tiling services
https://images.ala.org.au
0 stars 17 forks source link

Image delete webservice broken #90

Closed djtfmartin closed 4 years ago

djtfmartin commented 4 years ago
groovy.lang.MissingMethodException: No signature of method: au.org.ala.images.ImageService.scheduleImageDeletion() is applicable for argument types: (au.org.ala.images.Image, java.lang.String) values: [au.org.ala.images.Image : 59587, efd78f89-9e5d-4730-b892-df9d9dec99f3]
Possible solutions: scheduleImageDeletion(long, java.lang.String)
    at au.org.ala.images.WebServiceController.deleteImageService(WebServiceController.groovy:86)
    at org.grails.core.DefaultGrailsControllerClass$MethodHandleInvoker.invoke(DefaultGrailsControllerClass.java:223)
    at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
    at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
djtfmartin commented 4 years ago

This is fixed on the develop branch

nickdos commented 4 years ago

Does this need code review? I presume it needs to be tested via this service:

DELETE ​/ws​/image​/{id} Delete image

Testing on version 1.0.12 (images-dev).

How does it authenticate the caller has permissions to delete? ApiKey or AUTH session? OpenApi docs don't mention it... and I get 403 unauthorised error.

https://images-dev.ala.org.au/ws#/JSON%20services%20for%20accessing%20and%20updating%20metadata/scheduleArtifactGeneration%2F%7BimageID%7D

Update: PA told me about the whitelist config var... trying that. Worked when sending apiKey as header AND setting IP whitelist. Got 200 response with message "scheduled for deletion".

Deletion looks like it hasn't worked. Image page on UI doesn't show the flag "scheduled for deletion" and the following error appears in logs:

2019-11-05 12:46:45.806 ERROR --- [eduler_Worker-1] au.org.ala.images.ImageService           : Error executing task: au.org.ala.images.ImageBackgroundTask@480565fb
2019-11-05 12:46:45.822 ERROR --- [eduler_Worker-1] au.org.ala.images.ImageService           : Error executing task: Elasticsearch exception [type=cluster_block_exception, reason=index [images] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]

org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=cluster_block_exception, reason=index [images] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]
    at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
...
Suppressed: org.elasticsearch.client.ResponseException: method [DELETE], host [http://127.0.0.1:9200], URI [/images/_doc/7f368d97-1809-4af9-964a-5b71fcdd15d0?timeout=1m], status line [HTTP/1.1 403 Forbidden]
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [images] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"index [images] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}
        at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:260)

Postgres query showed record (7f368d97-1809-4af9-964a-5b71fcdd15d0) has no deleted attribute:

  id   | version |      date_uploaded      | recognised_license_id | width |          contentmd5hash          | file_size | uploader | square_thumb_size | mime_type | extension | deleted | rights | harvestable |                     license                     |           image_identifier           |      title       | thumb_height | height | zoom_levels | mm_per_pixel | original_filename_old |             contentsha1hash              | rights_holder | data_resource_uid |       date_taken        | creator  | description | thumb_width | parent_id | date_deleted | calibrated_by_user | occurrence_id | original_filename 
-------+---------+-------------------------+-----------------------+-------+----------------------------------+-----------+----------+-------------------+-----------+-----------+---------+--------+-------------+-------------------------------------------------+--------------------------------------+------------------+--------------+--------+-------------+--------------+-----------------------+------------------------------------------+---------------+-------------------+-------------------------+----------+-------------+-------------+-----------+--------------+--------------------+---------------+-------------------
 59968 |       2 | 2019-11-05 12:13:58.142 |                 33788 |   233 | 11ff7e2552ae7921ddfea92870c00abb |     57610 | 13       |               300 | image/png | png       |         | none   | f           | https://creativecommons.org/licenses/by/2.5/au/ | 7f368d97-1809-4af9-964a-5b71fcdd15d0 | Nick's test moth |          193 |    150 |           4 |              |                       | 6eb4df8762e52ce24a1cdf310f3278dfdadd2c9d | me            | dr1411            | 2019-11-05 12:13:58.142 | Nick dos | Moth        |         300 |           |              |                    |               | Picture1.png
djtfmartin commented 4 years ago

thanks @nickdos

I cant reproduce this now on images-dev.ala.org.au. Im wondering if the elastic search error was a temporary problem after an re-install. There are some index changes on develop branch for fixing partial text matches #101 that require a re-index.

Just tested with API keys (whitelist not necessary if api key supplied) and its working as expected.

e.g.

 curl -X DELETE https://images-dev.ala.org.au/ws/image/7a5b7964-c87e-4c36-b35c-2891822ced7c -H "apiKey: <INSERT-API_KEY>" 

images-dev.ala.org.au is pointing at auth-test - so the API key should be generated on auth-test to be recognised.

I think this can be closed.

nickdos commented 4 years ago

FYI, https://github.com/AtlasOfLivingAustralia/image-service/issues/104

Yep, worked when I tested just now, so can close.