Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Callum027 opened this issue Sep 2, 2024 · 0 comments

Comments

@Callum027
Copy link
Contributor

Callum027 commented Sep 2, 2024

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

  • Gnocchi: Latest master (potentially has been occurring for a while, though)
  • OpenStack upper constraints: 2024.1 Caracal (SQLAlchemy 1.4)
  • OS: Ubuntu 22.04 LTS container image
  • Python: 3.10 (system Python)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant