You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Trying to create a coveragestore fails, but the store and layer are created correctly.
It seems the return self.get_stores(names=name, workspaces=[workspace])[0] doesn't find the store, but if you wait a few seconds, running the same sentence returns ok.
See error:
Traceback (most recent call last):
File "createcoverage.py", line 6, in
cat.create_coveragestore(name='1', workspace='geoplatform', path='./1.tiff', upload_data=True, overwrite=False)
File "/home/administrator/gateways_venv/lib/python3.8/site-packages/geoserver/catalog.py", line 646, in create_coveragestore
return self.get_stores(names=name, workspaces=[workspace])[0]
IndexError: list index out of range
Expected behavior
No exception should be raised as store and layer are created
Screenshots
If applicable, add screenshots to help explain your problem.
OS (please complete the following information):
OS: Ubuntu server 18.04
Python 3.8.10
Additional context
adding a time.sleep(5) before the line return self.get_stores(names=name, workspaces=[workspace])[0] makes the method work correctly on this script, but this is a not reliable workaround.
The text was updated successfully, but these errors were encountered:
@emilianocastaneda I faced the same problem exactly as you described. I don't know a better way than just waiting. Afaik the requests.response object doesn't contain any information about whether the server (geoserver) finished processing or not. If you want to make sure that the time (5 s) is enough, you could check if the store is created in a loop, e.g.:
if resp.status_code != 201:
raise FailedRequestError('Failed to create coverage/layer {} for : {}, {}'.format(layer_name, name, resp.status_code, resp.text))
while name not in [store.name for store in self.get_stores(workspaces=[workspace])]:
time.sleep(1)
This should be after the request status is checked to not end up in an infinite loop.
Any comments/ideas from the developers of the package?
seesteins
added a commit
to seesteins/geoserver-restconfig
that referenced
this issue
Mar 2, 2024
Describe the bug
Trying to create a coveragestore fails, but the store and layer are created correctly.
It seems the return self.get_stores(names=name, workspaces=[workspace])[0] doesn't find the store, but if you wait a few seconds, running the same sentence returns ok.
To Reproduce
Steps to reproduce the behavior:
Execute the following script createcov.py:
from geoserver.catalog import Catalog
cat = Catalog("http://localhost/geoserver/rest", "admin", "geoserver")
cat.create_coveragestore(name='1', path='./1.tiff', upload_data=True, overwrite=False)
See error:
Traceback (most recent call last):
File "createcoverage.py", line 6, in
cat.create_coveragestore(name='1', workspace='geoplatform', path='./1.tiff', upload_data=True, overwrite=False)
File "/home/administrator/gateways_venv/lib/python3.8/site-packages/geoserver/catalog.py", line 646, in create_coveragestore
return self.get_stores(names=name, workspaces=[workspace])[0]
IndexError: list index out of range
Expected behavior
No exception should be raised as store and layer are created
Screenshots
If applicable, add screenshots to help explain your problem.
OS (please complete the following information):
Additional context
adding a time.sleep(5) before the line return self.get_stores(names=name, workspaces=[workspace])[0] makes the method work correctly on this script, but this is a not reliable workaround.
The text was updated successfully, but these errors were encountered: