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

feat: Upgrade built-in graphs automatically (DEV-3552) #3216

Merged
merged 7 commits into from Apr 27, 2024

Conversation

seakayone
Copy link
Collaborator

@seakayone seakayone commented Apr 25, 2024

The last releases where updating only the built in graphs.

The built in graphs should be upgraded automatically added in certain cases.

An upgrade is necessary under these conditions:

  • If the server version (defined in knora-base.ttl and org.knora.webapi#KnoraBaseVersion) is higher than the version in the database.
  • If there is no version in the database all plugins must be run
  • The application startup should fail if the database version is higher than the server version

When collecting the necessary plugins results in an empty list of plugins then a PluginForKnoraBaseVersion(versionNumber = serverVersion, plugin = new MigrateOnlyBuiltInGraphs) should be run.

When collecting the necessary plugins to run results in a list which contains at least one plugin nothing has to be done because every UpgradePlugin must provide a MigrateSpecificGraphs object which in all cases contains the built in graphs.

Pull Request Checklist

Task Description/Number

Issue Number: DEV-3552

PR Type

  • build/chore: maintenance tasks (no production code change)
  • docs: documentation changes (no production code change)
  • feat: represents new features
  • fix: represents bug fixes
  • perf: performance improvements
  • refactor: represents production code refactoring
  • test: adding or refactoring tests (no production code change)
  • deprecated: Deprecation warning (ideally referencing a migration guide)

Basic requirements for bug fixes and features

  • Tests for the changes have been added
  • Docs have been added / updated

Does this PR introduce a breaking change?

  • Yes

Does this PR change client-test-data?

  • Yes

Remove the need to add a MigrateOnlyBuiltInGraphs to the RepositoryUpdatePlan
@seakayone seakayone marked this pull request as ready for review April 25, 2024 13:00
// Yes. Nothing more to do.
ZIO.succeed(RepositoryUpdatedResponse(s"Repository is up to date at $requiredRepositoryVersion"))
} else {
if (repositoryVersion.contains(KnoraBaseVersion)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it check that it's strictly smaller? or are you anyway relying on the fact that only the plugins that are bigger are filtered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have not changed the general logic of this:
If the version in the db does not exactly match the version of our server we need do proceed with doing an update.

Are you referring to the edge case of having a db version which is greater than the server version? This case was and still is not covered. What do you think should happen? I guess it would be best to prevent the startup entirely in this case.

Copy link
Contributor

@siers siers Apr 25, 2024

Choose a reason for hiding this comment

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

Yes, I think it would make most sense to not do anything in case it's bigger.

(Note: comment edited.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add this behaviour in this PR then.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this case be even possible?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This happens regularly on dev servers, when the API version deployed there is lower than the one on prod, and then prod data gets mirrored to that dev server.

And previously, in this scenario the start-up would fail because of the exception raised in L139 which killed the fiber. I think we should keep that behaviour, unless we have good reasons to change it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This commit add the behaviour back again:
bf97820

@seakayone seakayone requested a review from siers April 25, 2024 14:07
// Yes. Nothing more to do.
ZIO.succeed(RepositoryUpdatedResponse(s"Repository is up to date at $requiredRepositoryVersion"))
} else {
if (repositoryVersion.contains(KnoraBaseVersion)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this case be even possible?

@seakayone seakayone requested review from mpro7 and siers April 26, 2024 09:03
@seakayone seakayone changed the title feat: Upgrade built-in graphs automatically feat: Upgrade built-in graphs automatically (DEV-3552) Apr 26, 2024
Copy link

linear bot commented Apr 26, 2024

@seakayone
Copy link
Collaborator Author

if (repositoryVersion.contains(KnoraBaseVersion))

Would this case be even possible?

Yes, every time the application is restarting.

Replace if else with pattern matching
Replace Option.get with value
Copy link
Collaborator

@BalduinLandolt BalduinLandolt left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator

@mpro7 mpro7 left a comment

Choose a reason for hiding this comment

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

Thanks! There is still some test failing...

@seakayone seakayone merged commit f46d658 into main Apr 27, 2024
11 checks passed
@seakayone seakayone deleted the feat/update-built-in-graphs-automatically branch April 27, 2024 19:43
@seakayone
Copy link
Collaborator Author

Seems to be a fluke. org.knora.webapi.it.v2.KnoraSipiIntegrationV2ITSpec pass locally and after a rerun.

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

Successfully merging this pull request may close these issues.

None yet

4 participants