gnocchixyz / gnocchi

Timeseries database
Apache License 2.0
299 stars 85 forks source link

SAWarning: relationship 'ResourceHistory.metrics' conflicts with 'Metric.resource' #1406

Open Callum027 opened 2 months ago

Callum027 commented 2 months ago

With the latest master, I get an error from SQLAlchemy about a relationship conflict between ResourceHistory.metrics, Metric.resource and Resource.metrics.

I'm unsure of the effects of this. Everything appears to work fine. It might simply be the result of still using older (deprecated) relationship syntax in parts of the codebase.

More detail about the specific error here: https://docs.sqlalchemy.org/en/14/errors.html#error-qzyx

Which version of Gnocchi are you using

How to reproduce your problem

Run Gnocchi API or metricd, and check the logs.

What is the result that you get

2024-09-02 03:29:26,743 [135] WARNING  py.warnings: /var/lib/openstack/lib/python3.10/site-packages/gnocchi/indexer/sqlalchemy.py:841: SAWarning: relationship 'ResourceHistory.metrics' will copy column resource_history.id to column metric.resource_id, which conflicts with relationship(s): 'Metric.resource' (copies resource.id to metric.resource_id), 'Resource.metrics' (copies resource.id to metric.resource_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="metrics,resource"' to the 'ResourceHistory.metrics' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
  return list(session.scalars(q).all())

What is result that you expected

No warning.