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

[DRAFT] MGDCTRS-2034: Remove dbapi.ConnectorDeployment.Annotations #1565

Closed
wants to merge 1 commit into from

Conversation

manstis
Copy link
Contributor

@manstis manstis commented Feb 12, 2023

=== DRAFT ===

Depends on a fix to gorm. See go-gorm/gorm#6058

Depends on #1637 to upgrade to latest gorm libraries.

Description

See https://issues.redhat.com/browse/MGDCTRS-2034

dbapi.ConnectorDeployment.Annotations is not needed. See JIRA for more information.

Checklist (Definition of Done)

  • All acceptance criteria specified in JIRA have been completed
  • Unit and integration tests added that prove the fix is effective or the feature works (tested against emulated and non-emulated OCM environment)
  • [ ] Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer
  • All PR comments are resolved either by addressing them or creating follow up tasks
  • [ ] Required metrics/dashboards/alerts have been added (or PR created).
  • [ ] Required Standard Operating Procedure (SOP) is added.
  • [ ] JIRA has been created for changes required on the client side

@manstis
Copy link
Contributor Author

manstis commented Feb 13, 2023

I can see why this is failing.. and it highlights why ConnectorAnnotations also lives on ConnectorDeployment.

When a Connector is deleted the ConnectorDeployment is left dangling. Retrieval of the soft-deleted Connector.Annotations is not that easy with gorm (go-gorm/gorm#6054) and use of native SQL has other issues (go-gorm/gorm#6052).

I am investigating a bit more.. but the simple solution is to keep the hack and close this PR.

@valdar
Copy link
Contributor

valdar commented Feb 14, 2023

@manstis just reading the error message without any more sophisticated investigation, I would have assumed that gorm still try to load the connectorDeployment -> Annotation relation somehow?

@manstis
Copy link
Contributor Author

manstis commented Feb 15, 2023

@manstis just reading the error message without any more sophisticated investigation, I would have assumed that gorm still try to load the ConnectorDeployment -> Annotation relation somehow?

Yes, keeping ConnectorDeployment.Annotations works around a bug in gorm but this PR tries to remove ConnectorDeployment.Annotations as it really lives on ConnectorDeployment.Connector.Annotations at the database level. i.e. there is no foreign key between connector_deployments->connector_annotations only between connector_deployments->connectors->connector_annotations. If a FK is added it causes other problems (I encountered when adding support for Smart Event Processors).

When gorm runs this for the "dangling" ConnectorDeployment's test it fails to return Connector instances as they have been soft-deleted. I tried adding Unscoped() to the query locally but it is not honoured by the Preload("Annotations") and hence zero Annotations are returned making the test still fail. I have reported it and provide a fix: go-gorm/gorm#6058.

I'll keep this PR pending.. as when gorm is fixed we may be able to upgrade and complete this PR.

@manstis manstis marked this pull request as draft February 15, 2023 10:58
@manstis manstis changed the title MGDCTRS-2034: Remove dbapi.ConnectorDeployment.Annotations [DRAFT] MGDCTRS-2034: Remove dbapi.ConnectorDeployment.Annotations Feb 15, 2023
@manstis
Copy link
Contributor Author

manstis commented Apr 28, 2023

RHOC has been cancelled.

@manstis manstis closed this Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants