NASA-IMPACT / veda-backend

Backend services for VEDA
Other
13 stars 5 forks source link

TiTiler Pgstac search method problems with RDS Proxy #315

Closed anayeaye closed 9 months ago

anayeaye commented 9 months ago

What

Certain raster-api endpoints are not yet working with the new veda-backend RDS-Proxy set up (PR 299).

For example, The /mosaic/register endpoint is not OK

curl -X 'POST' \
  'http://dev.openveda.cloud/api/raster/mosaic/register' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"filter-lang":"cql2-json","filter":{"op":"and","args":[{"op":">=","args":[{"property":"datetime"},"2016-01-01T00:00:00.000Z"]},{"op":"<=","args":[{"property":"datetime"},"2016-01-01T23:59:59.999Z"]},{"op":"eq","args":[{"property":"collection"},"no2-monthly"]}]}}'

Connections are timing out and a 504 is returned from the server

CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.

In the CloudWatch logs for the raster-api lambda we see connection pool <> RDS Proxy errors

error connecting in 'pool-1': connection failed: FATAL:  Feature not supported: RDS Proxy currently doesn't support command-line options.
connection to server at "10.41.147.222", port 5432 failed: FATAL:  Feature not supported: RDS Proxy currently doesn't support command-line options.

The titiler can render tiles for the asset that the registered search would have found https://dev.openveda.cloud/api/raster/cog/viewer?url=s3://veda-data-store-staging/no2-monthly/OMI_trno2_0.10x0.10_201601_Col3_V4.nc.tif

The same search body does yield results from the stac-api

curl -X 'POST' \
  'https://dev.openveda.cloud/api/stac/search' \
  -H 'accept: application/geo+json' \
  -H 'Content-Type: application/json' \
  -d '{"filter-lang":"cql2-json","filter":{"op":"and","args":[{"op":">=","args":[{"property":"datetime"},"2016-01-01T00:00:00.000Z"]},{"op":"<=","args":[{"property":"datetime"},"2016-01-01T23:59:59.999Z"]},{"op":"eq","args":[{"property":"collection"},"no2-monthly"]}]}}'

Note

When working this issue, confirm that the proxy is enabled (we may disable it while working on other backend issues). I will try and keep the status of the proxy configuration in the comments for this issue!

AC

smohiudd commented 9 months ago

@anayeaye so because of the mosaic/register failure we shouldn't be seeing any datasets visualized in the front end right?

I also I wonder if the /cog/viewer is functioning because it doesn't need database access unlike the mosaic endpoint.

anayeaye commented 9 months ago

@smohiudd

because of the mosaic/register failure we shouldn't be seeing any datasets visualized in the front end right

Yes, but because the proxy is configurable, the dashboard is safe even if we promote these intermediate changes

I also I wonder if the /cog/viewer is functioning because it doesn't need database access unlike the mosaic endpoint

I think so. I wonder if it could be something as simple as the new caching of the database connection secret for the tiler not working as expected--except the errors continue to be about RDS Proxy currently doesn’t support command-line options, not access denied.

moradology commented 9 months ago

Going out on a limb here, I think this search path argument is the issue: https://github.com/stac-utils/titiler-pgstac/blob/115183534e362c49f60503c7c4584be44841c375/titiler/pgstac/db.py#L25

If that's correct, we'll have to establish the connection and then set search path to use RDS proxy. -c flags aren't supported despite being baked into titiler pgstac's db.py connection logic

moradology commented 9 months ago

This PR should provide a suitable workaround: https://github.com/NASA-IMPACT/veda-backend/pull/317

smohiudd commented 9 months ago

As an alternative, here is a change to titiler-pgstac: https://github.com/stac-utils/titiler-pgstac/pull/155

vincentsarago commented 9 months ago

☝️ was merged and release intotitiler.pgstac==0.8.3