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

[WIP] update gorm and related libraries #1637

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

miguelsorianod
Copy link
Contributor

Description

Continuation of #1314. Full context there.

Verification Steps

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

@miguelsorianod miguelsorianod added the do-not-merge A Pull Request with this label should not be merged: it might be due to pending questions, feedback label Mar 14, 2023
@miguelsorianod miguelsorianod requested review from a team as code owners March 14, 2023 13:10
@machi1990
Copy link
Contributor

Can't wait for this update to land! Thanks @miguelsorianod @manstis for making this possible

@miguelsorianod
Copy link
Contributor Author

miguelsorianod commented Mar 16, 2023

Some tests are still failing. Both kafka and connector ones.
I have been working on reviewing the kafka related ones. After investigating the issues I found that there are a couple of issues: The way the Scan method is implemented for api.JSON with some edge cases and the api.MarshalJSON with some edge cases too.
I got some local changes implemented that made the tests pass but at the same time I found out there are newer gorm and db drivers versions. After locally updating them I found out that that makes the tests pass so it seems to be a bug introduced in the current versions of the libraries in the PR.
I would have updated and pushed the changes but when updating gorm and related libraries the way they are defined point to an arbitrary commit in gorm instead of a tag. Because of this I am going to wait until they update the dependencies to point to a git tag, to provide us with higher stability guarantees.

I observed the connector tests are still failing but let's wait until we update the gorm libraries to see if they still fail.

go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@miguelsorianod
Copy link
Contributor Author

I updated the gorm and gorm postgres dependencies to the versions show below:

  gorm.io/driver/postgres v1.5.0
  gorm.io/gorm v1.25.0

@miguelsorianod
Copy link
Contributor Author

miguelsorianod commented Apr 11, 2023

After performing the upgrades mentioned in #1637 (comment) the unit tests pass, the kafka integration tests also pass but the connectors tests fail.

It seems all connectors tests are failing:

2023-04-11T10:08:23.3263810Z DONE 33 tests, 33 failures in 46.126s

@miguelsorianod
Copy link
Contributor Author

After performing the upgrades mentioned in #1637 (comment) the unit tests pass, the kafka integration tests also pass but the connectors tests fail.

It seems all connectors tests are failing:

2023-04-11T10:08:23.3263810Z DONE 33 tests, 33 failures in 46.126s

cc @manstis could you take a look? I suspect it might have to do with the migrations again as all the tests are failing with "unknown" state.

@manstis
Copy link

manstis commented Apr 12, 2023

@miguelsorianod I suspect it is caused by go-gorm/playground#571

Newer (latest) versions of gorm's postgres driver fail to migrate XXXserial columns.

@manstis
Copy link

manstis commented Apr 12, 2023

@miguelsorianod I am doing some more investigations locally and will report back.

@miguelsorianod
Copy link
Contributor Author

@miguelsorianod I am doing some more investigations locally and will report back.

Thanks 👍

@manstis
Copy link

manstis commented Apr 12, 2023

Hi @miguelsorianod

I've made the applicable changes to my fork: manstis@57abdc7

You could include them in this PR and it should be OK.

@miguelsorianod
Copy link
Contributor Author

miguelsorianod commented Apr 12, 2023

Hi @miguelsorianod

I've made the applicable changes to my fork: manstis@57abdc7

You could include them in this PR and it should be OK.

Can your changes be merged to main through a PR before this PR? or they depend on the changes of this PR being available? If not I will include the change as you said

@manstis
Copy link

manstis commented Apr 12, 2023

@miguelsorianod Since the changes are only required due to the gorm upgrade I think they should be part of this PR (for the same reason as to why there are kafka changes in this PR already too and they have not first been applied to main).

@miguelsorianod
Copy link
Contributor Author

@miguelsorianod Since the changes are only required due to the gorm upgrade I think they should be part of this PR (for the same reason as to why there are kafka changes in this PR already too and they have not first been applied to main).

It seems reasonable. I will add it into the PR. The authorship will be lost though.

@miguelsorianod
Copy link
Contributor Author

miguelsorianod commented Apr 12, 2023

@miguelsorianod Since the changes are only required due to the gorm upgrade I think they should be part of this PR (for the same reason as to why there are kafka changes in this PR already too and they have not first been applied to main).

It seems reasonable. I will add it into the PR. The authorship will be lost though.

I have been able to keep the authorship by getting your fork's branch and cherry-picking the commit. Could you verify that the changes have been included correctly in this PR?

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #1637 (04641f3) into main (ce2958d) will decrease coverage by 0.11%.
The diff coverage is 26.92%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1637      +/-   ##
==========================================
- Coverage   82.26%   82.15%   -0.11%     
==========================================
  Files         161      161              
  Lines       14989    15009      +20     
==========================================
+ Hits        12330    12331       +1     
- Misses       2223     2242      +19     
  Partials      436      436              
Flag Coverage Δ
unittests 82.15% <26.92%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/db/config.go 77.90% <26.92%> (-22.10%) ⬇️

@miguelsorianod
Copy link
Contributor Author

miguelsorianod commented Apr 12, 2023

All the checks are passing now. I will do a re-review and start planning the rollout of this changes for KAS Fleet Manager, as merging it will rollout those changes to KAS Fleet Manager Stage and Production.

dependabot bot and others added 16 commits April 18, 2023 10:46
Bumps [gorm.io/driver/postgres](https://github.com/go-gorm/postgres) from 1.0.8 to 1.3.10.
- [Release notes](https://github.com/go-gorm/postgres/releases)
- [Commits](go-gorm/postgres@v1.0.8...v1.3.10)

---
updated-dependencies:
- dependency-name: gorm.io/driver/postgres
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
When updating gorm from 1.21.7 to 1.23.10 kafka migrations
start to return an error:
Could not migrate: ERROR: cached plan must not change result type (SQLSTATE 0A000)
This error happens due to in the kafka migrations we perform database
queries and schema table modifications in an interleaved way and
prepared statements are cached. This leads scenarios where a specific
table is queried and thus some prepared statements cached, then some
table schemas are modified and then when queries are performed again against
those queries are outdated cached prepared statements which causes the
observed error.
This behavior is likely a bug in gorm related to prepared statement
caching due to only updating gorm minor version should not break changes.
To workaround this for now this commit updates code to disable prepared
statements during kafka migrations. This includes the kafka migrations when
integration tests are run too.
During serve command execution, for connectors migrations and for the
integration tests (excluding the migrations part of them) the prepared
statements are enabled being the behavior the same as before this change.
gorm.io/gorm has been updated to v1.24.1
gorm.io/driver/postgres has been updated to v1.4.5
the bug related to db prepared statements has been fixed
on gorm.io/driver/postgres v1.4.5. We are now using that version
so this reenables db prepared statements for kafka migrations
gorm.io/gorm has been updated to v1.24.3
gorm.io/driver/postgres has been updated to v1.4.6
gorm.io/gorm has been updated to v1.25.0
gorm.io/driver/postgres has been updated to v1.5.0
After gorm version update to 1.25.0 the Save method does not return
values.
Copy link

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@miguelsorianod
Copy link
Contributor Author

I've made the following manual tests in a development environment:

  • Performing Kafkas DB migration twice works correctly when using the new gorm version
  • Performing Connectors DB migration twice works correctly when using the gorm version
  • Performing Kafka creation before gorm update, then migrating to new gorm version including reapplying db migration works correctly. The kafka intsances remain ready and no errors are observed
  • Creating Kafka instances after gorm update works correctly
  • Kafka instances can be listed after gorm updates for both newly created instances and also for previously created instances
  • Kafka instances can be deleted after form updates for both newly created instances and also for previously created instances
  • Instances created before the gorm update and instances created after the gorm update look the same. This includes empty and null values
  • OCP cluster entry pre and post migration looks the same. This includes empty and null values

I am currently waiting for some midstream pipelines issues to be fixed. Once that is done I will proceed to merge this and release it to stage

@manstis manstis mentioned this pull request Apr 22, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common connector do-not-merge A Pull Request with this label should not be merged: it might be due to pending questions, feedback kafka
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants