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

Upgrade Ruby to 3.2 #3216

Merged
merged 33 commits into from May 9, 2023
Merged

Upgrade Ruby to 3.2 #3216

merged 33 commits into from May 9, 2023

Conversation

knu
Copy link
Member

@knu knu commented Apr 16, 2023

Ruby 2.7 will soon reach EOL. We need to migrate to the latest version of Ruby.

@dmitrytrager
Copy link
Contributor

Are you working on this or it is possible to contribute?

@knu knu force-pushed the ruby-3.2 branch 2 times, most recently from b5b707c to 47a709c Compare April 16, 2023 18:29
@knu
Copy link
Member Author

knu commented Apr 17, 2023

@dmitrytrager There are many things to do at the same time to get Huginn working with Ruby 3.2, so I've been doing the work bit by bit. It's not just about our code base but problems lie in obsolete third-party libraries and we need to upgrade or just ditch them if no updates are available.

  • Builds:
    • There is no PPA repository that hosts the latest versions of Ruby in a timely manner, and Ubuntu 18.04 is too old anyway, so we are moving to the official Ruby images based on Ubuntu 22.04.
  • Assets:
    • Upgrade Sprockets: 3 -> 4
    • Drop CoffeeScript
      • Uglifier unable to parse the converted modern JavaScript code; migrate to terser
    • Upgrade select2: 3.5 -> 4
  • E2E testing
    • PhantomJS -> headless Chrome
  • Drop obsolete Agents that rely on no longer maintained gems
    • GrowlAgent
  • To be added

@knu knu force-pushed the ruby-3.2 branch 8 times, most recently from 87ef0d5 to c7da88a Compare April 17, 2023 17:14
knu added 2 commits April 20, 2023 02:56
- Use the `<select>` tag  as demanded in version 4
- Turn on `tags` to allow for manual input
- Drop complete API response caching and simplify:
  - Use the AjaxAdapter when cache_response is false
  - Use the ArrayAdapter when cache_response is true after calling the API
@knu knu requested a review from dsander April 20, 2023 03:55
@knu
Copy link
Member Author

knu commented Apr 20, 2023

I started to run this on my instance to see if it works fine.

@dsander
Copy link
Collaborator

dsander commented Apr 20, 2023

That is great! Can please you move 930da10 to a separate branch/PR? It makes reviewing the other changes very difficult.

@knu
Copy link
Member Author

knu commented Apr 20, 2023

@dsander Thank you for taking a look! Let me explain. The reformatting is done by rubocop and it introduces ruby 3.2 specific new syntax that cannot be parsed with ruby 2.7. On the other hand, upgrading ruby requires library updates, so the commit itself is just incomplete in the CI point of view, meaning it can't be solely extracted as a working change that passes required tests. So, would you please put up with a commit by commit review? 🥺

* foreman needs a bump to be compatible with ruby 3.2
* install supervisor-stdout from git to be compatible with python 3
* adjust configuration of build-in mysql server to newer verrsion
@dsander
Copy link
Collaborator

dsander commented Apr 20, 2023

@knu Understood, at first glance the commit looked like a simple rubocop -a 😄 I'll try to go though it on the
weekend.

I worked a bit on the multi process docker image, it now boots as a fresh container, migrating the mysql database from the old version to the current one still fails though. I also do not know if the required foreman version bump has negative implications for the manual installation guide (would love to get rid of that one 😉 ).

@dsander
Copy link
Collaborator

dsander commented Apr 20, 2023

This looks really annoying, apparently the current image doesn't properly show down the build in mysql server:

2023-04-20 22:08:10,960 INFO waiting for foreman, mysqld, stdout to die
2023-04-20 22:08:13,964 INFO waiting for foreman, mysqld, stdout to die
2023-04-20 22:08:16,967 INFO waiting for foreman, mysqld, stdout to die
2023-04-20 22:08:19,971 INFO waiting for foreman, mysqld, stdout to die
2023-04-20 22:08:20,972 WARN killing 'mysqld' (375) with SIGKILL
2023-04-20 22:08:20,973 INFO stopped: mysqld (terminated by SIGKILL)
foreman stdout | SIGTERM received
22:08:21 system | sending SIGTERM to all processes
foreman stdout | 22:08:21 web.1  | terminated by SIGTERM
foreman stdout | 22:08:21 jobs.1 | terminated by SIGTERM
2023-04-20 22:08:21,983 INFO stopped: foreman (exit status 0)
2023-04-20 22:08:21,983 INFO stopped: stdout (terminated by SIGTERM)

As a result of this the new mysql refuses to update the database:

2023-04-20T22:09:43.116686Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.22.04.2) starting as process 1186
2023-04-20T22:09:43.117838Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2023-04-20T22:09:43.125791Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.
2023-04-20T22:09:43.125808Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-04-20T22:09:43.182357Z 1 [ERROR] [MY-012526] [InnoDB] Upgrade is not supported after a crash or shutdown with innodb_fast_shutdown = 2. This redo log was created with MySQL 5.7.41, and it appears logically non empty. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html
2023-04-20T22:09:43.182383Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2023-04-20T22:09:43.642496Z 1 [ERROR] [MY-011013] [Server] Failed to initialize DD Storage Engine.
2023-04-20T22:09:43.642759Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-04-20T22:09:43.642779Z 0 [ERROR] [MY-010119] [Server] Aborting

@dsander
Copy link
Collaborator

dsander commented Apr 21, 2023

Got it working with this commit but I hope we come up with a better solution than installing a binary that was build for 18.04.

@knu knu mentioned this pull request Apr 23, 2023
app/assets/config/manifest.js Outdated Show resolved Hide resolved
@@ -28,7 +28,7 @@ class CommanderAgent < Agent

- If you want to update a WeatherAgent based on a UserLocationAgent, you could use `'action': 'configure'` and set 'configure_options' to `{ 'location': '{{_location_.latlng}}' }`.

- In templating, you can use the variable `target` to refer to each target agent, which has the following attributes: #{AgentDrop.instance_methods(false).map { |m| "`#{m}`" }.to_sentence}.
- In templating, you can use the variable `target` to refer to each target agent, which has the following attributes: #{Agent::Drop.instance_methods(false).map { |m| "`#{m}`" }.to_sentence}.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if any Agent gems are using AgentDrop in a similar way, do you think it is possible/makes sense to also define the new class as AgentDrop? If not we should probably mention it in the changelog.

Copy link
Member Author

Choose a reason for hiding this comment

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

GitHub code search didn't find any occurrence of it, but I agree it is worth a mention.

app/models/scenario.rb Show resolved Hide resolved
knu and others added 2 commits April 24, 2023 11:20
@knu
Copy link
Member Author

knu commented Apr 24, 2023

Got it working with this commit but I hope we come up with a better solution than installing a binary that was build for 18.04.

That hurts, but it's okay as long as it works. 🥺
We have about six months before MySQL 5.7 goes EOL, so let's find out a smooth upgrade path by then.

@dsander
Copy link
Collaborator

dsander commented Apr 25, 2023

That hurts, but it's okay as long as it works. 🥺 We have about six months before MySQL 5.7 goes EOL, so let's find out a smooth upgrade path by then.

Yeah I think it is better to find a solution that makes the update easier for users that upgraded to a fixed image that properly shuts down the mysql server. A brief look into why supervisord kills the processes but didn't show anything obvious (it seems it never forwards the TERM to the child processes).

Have you ever worked with s6-overlay? It looks like a simpler and more modern(?) alternative to supervisord.

I have a custom build running on my instance without issues, I am good with the PR. Do you want me to push my mysql5 hack to the branch or do you cherry pick it?

@knu knu requested a review from dsander May 4, 2023 19:11
@dsander
Copy link
Collaborator

dsander commented May 6, 2023

Like I said before, this looks good to me except that we need a way to support existing users of the build in mysql server.

This certainly isn't pretty but allows users of the build in mysql
server to update. Switching to mysql 8 directly isn't an option at the
moment because the docker image never cleanly shuts down it's processes
and mysql_upgrade does not work in that case.
@knu
Copy link
Member Author

knu commented May 6, 2023

@dsander Ah, I just forgot to incorporate your patch. I've cherry-picked the last commit from https://github.com/dsander/huginn/tree/ruby-3.2-mysql-5-hack. How does this look now?

Copy link
Collaborator

@dsander dsander left a comment

Choose a reason for hiding this comment

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

I have the latest revision running for a few days on my system without issues and the docker specs also pass.

Thanks for all the work on this! 💯 :shipit:

@knu knu merged commit ed91c16 into master May 9, 2023
14 checks passed
@knu knu deleted the ruby-3.2 branch May 9, 2023 07:26
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

3 participants