YunoHost-Apps / jenkins_ynh

Jenkins package for YunoHost
https://jenkins.io/
Apache License 2.0
5 stars 10 forks source link

Fix upgrade and restore for alt ports #131

Closed CodeShakingSheep closed 7 months ago

CodeShakingSheep commented 10 months ago

Problem

Solution

PR Status

Automatic tests

Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ after creating the PR, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

CodeShakingSheep commented 10 months ago

!testme

yunohost-bot commented 10 months ago

May the CI gods be with you! Test Badge

PatBriPerso commented 10 months ago

On a YunoHost test server I own, I tried to test this pull request and conclude that it works (at least for the upgrade script).

Hope this helps.

Details of my tests

On my test server, I already have installed Jupyter Lab that use the 8080 port.

I install Jenkins v2.414.1 from my own fork of jenkins_ynh with:

sudo yunohost app install https://github.com/computablefacts/jenkins_ynh/tree/2.414.1 --force --args "domain=jenkins.mydomain.com&path=/&is_public=yes"
...
Success! Installation completed
Full command output

``` Info: Installing jenkins... Info: [+...................] > Validating installation parameters... Info: [#+..................] > Storing installation settings... Info: [##+.................] > Finding an available port... Info: [###++...............] > Installing dependencies... Info: [#####+..............] > Configuring system user... Info: [######+.............] > Setting up source files... Info: [#######+............] > Configuring NGINX web server... Info: [########++..........] > Installing Jenkins... Warning: Job for jenkins.service failed because the control process exited with error code. Warning: See "systemctl status jenkins.service" and "journalctl -xe" for details. Warning: invoke-rc.d: initscript jenkins, action "start" failed. Warning: dpkg: error processing package jenkins (--install): Warning: installed jenkins package post-installation script subprocess returned error exit status 1 Warning: Errors were encountered while processing: Warning: jenkins Warning: The service jenkins cannot be started for now. Info: [##########+.........] > Setuping application on port 8095... Info: The service jenkins has correctly executed the action restart. Info: [###########+........] > Installing plugins... Info: [############+.......] > Adding a configuration file... Info: [#############++.....] > Integrating service in YunoHost... Info: [###############+....] > Starting a systemd service... Info: The service jenkins has correctly executed the action restart. Info: [################+...] > Configuring permissions... Info: [#################+..] > Reloading NGINX web server... Info: [##################++] > Installation of jenkins completed Success! Installation completed ```

Then I update with the master branch of jenkins_ynh with:

sudo yunohost app upgrade jenkins --url https://github.com/YunoHost-Apps/jenkins_ynh
...
Error: The operation 'Upgrade the 'jenkins' app' could not be completed.
Full command output

``` Info: Now upgrading jenkins... Info: [+...................] > Loading installation settings... Info: [#+..................] > Checking version... Info: [##+.................] > Backing up the app before upgrading (may take a while)... Info: [###++...............] > Stopping a systemd service... Info: The service jenkins has correctly executed the action stop. Info: [#####+..............] > Ensuring downward compatibility... Info: [######+.............] > Making sure dedicated system user exists... Info: [#######+............] > Upgrading source files... Warning: Job for jenkins.service failed because the control process exited with error code. Warning: See "systemctl status jenkins.service" and "journalctl -xe" for details. Warning: invoke-rc.d: initscript jenkins, action "restart" failed. Warning: dpkg: error processing package jenkins (--install): Warning: installed jenkins package post-installation script subprocess returned error exit status 1 Warning: Errors were encountered while processing: Warning: jenkins Warning: [Error] Upgrade failed. Warning: failed to remove jenkins system user Warning: 62615 Job for jenkins.service failed because the control process exited with error code. Warning: 62616 See "systemctl status jenkins.service" and "journalctl -xe" for details. Warning: 62617 invoke-rc.d: initscript jenkins, action "start" failed. Warning: 62956 dpkg: error processing package jenkins (--install): Warning: 62958 installed jenkins package post-installation script subprocess returned error exit status 1 Warning: 63007 Errors were encountered while processing: Warning: 63008 jenkins Warning: 64523 Could not restore jenkins: An error occured inside the app restore script Warning: 64566 Here's an extract of the logs before the crash. It might help debugging the error: Warning: 70873 failed to remove jenkins system user Warning: 93057 The operation 'Restore 'jenkins' from a backup archive' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20240104-170751-backup_restore_app-jenkins' to get help Warning: 93518 Nothing was restored Warning: Uhoh ... Yunohost failed to restore the app to the way it was before the failed upgrade :| Error: Could not upgrade jenkins: An error occurred inside the app upgrade script Info: The operation 'Upgrade the 'jenkins' app' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20240104-170636-app_upgrade-jenkins' to get help Warning: Here's an extract of the logs before the crash. It might help debugging the error: Info: DEBUG - 64567 DEBUG - Selecting previously unselected package jenkins. Info: DEBUG - 64567 DEBUG - (Reading database ... 60316 files and directories currently installed.) Info: DEBUG - 64567 DEBUG - Preparing to unpack ../conf/jenkins.deb ... Info: DEBUG - 64567 DEBUG - Unpacking jenkins (2.414.1) ... Info: DEBUG - 64567 DEBUG - Setting up jenkins (2.414.1) ... Info: DEBUG - 64567 DEBUG - Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service. Info: DEBUG - 64568 WARNING - Job for jenkins.service failed because the control process exited with error code. Info: DEBUG - 64568 WARNING - See "systemctl status jenkins.service" and "journalctl -xe" for details. Info: DEBUG - 64568 WARNING - invoke-rc.d: initscript jenkins, action "start" failed. Info: DEBUG - 64568 DEBUG - ● jenkins.service - Jenkins Continuous Integration Server Info: DEBUG - 64568 DEBUG - Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled) Info: DEBUG - 64568 DEBUG - Active: activating (auto-restart) (Result: exit-code) since Thu 2024-01-04 17:08:52 UTC; 11ms ago Info: DEBUG - 64568 DEBUG - Process: 953920 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE) Info: DEBUG - 64568 DEBUG - Main PID: 953920 (code=exited, status=1/FAILURE) Info: DEBUG - 64569 DEBUG - CPU: 4.951s Info: DEBUG - 64569 WARNING - dpkg: error processing package jenkins (--install): Info: DEBUG - 64569 WARNING - installed jenkins package post-installation script subprocess returned error exit status 1 Info: DEBUG - 64569 WARNING - Errors were encountered while processing: Info: DEBUG - 64569 WARNING - jenkins Info: DEBUG - 64569 DEBUG - + ynh_exit_properly Error: The operation 'Upgrade the 'jenkins' app' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20240104-170636-app_upgrade-jenkins' to get help ```

==> I reproduce the issue due to the 8080 port already in use

So I install Jenkins v2.414.1 again with:

sudo yunohost app install https://github.com/computablefacts/jenkins_ynh/tree/2.414.1 --force --args "domain=jenkins.mydomain.com&path=/&is_public=yes"

Then I update with the pull request branch of jenkins_ynh with:

sudo yunohost app upgrade jenkins --url https://github.com/CodeShakingSheep/jenkins_ynh/tree/fix-upgrade-and-restore-for-alt-ports
...
Success! jenkins upgraded
Success! Upgrade complete
Full command output

``` Info: Now upgrading jenkins... Info: [+...................] > Loading installation settings... Info: [#+..................] > Checking version... Info: [##+.................] > Backing up the app before upgrading (may take a while)... Info: [###++...............] > Stopping a systemd service... Info: The service jenkins has correctly executed the action stop. Info: [#####+..............] > Ensuring downward compatibility... Info: [######+.............] > Making sure dedicated system user exists... Info: [#######+............] > Upgrading source files... Warning: Job for jenkins.service failed because the control process exited with error code. Warning: See "systemctl status jenkins.service" and "journalctl -xe" for details. Warning: invoke-rc.d: initscript jenkins, action "restart" failed. Warning: dpkg: error processing package jenkins (--install): Warning: installed jenkins package post-installation script subprocess returned error exit status 1 Warning: Errors were encountered while processing: Warning: jenkins Warning: The service jenkins cannot be started for now. Info: [########++..........] > Setuping application on port 8095... Info: The service jenkins has correctly executed the action restart. Info: [##########+.........] > Upgrading dependencies... Info: [###########+........] > Upgrading NGINX web server configuration... Info: [############+.......] > Reloading NGINX web server... Info: [#############++.....] > Upgrading plugins... Info: [###############+....] > Integrating service in YunoHost... Info: [################+...] > Starting a systemd service... Info: The service jenkins has correctly executed the action restart. Info: [#################+..] > Reloading NGINX web server... Info: [##################++] > Upgrade of jenkins completed Success! jenkins upgraded Success! Upgrade complete ```

==> The pull request upgrade Jenkins successfully

CodeShakingSheep commented 10 months ago

Thanks a lot for the detailed testing of this PR @PatBriPerso. Did you also have the opportunity to test the restore script? I applied the same fix there. Would help a lot if you could confirm it works for you.

PatBriPerso commented 10 months ago

Thanks a lot for the detailed testing of this PR @PatBriPerso. Did you also have the opportunity to test the restore script? I applied the same fix there. Would help a lot if you could confirm it works for you.

I'll try to do that this week. I'll keep you informed.

CodeShakingSheep commented 10 months ago

!testme

yunohost-bot commented 10 months ago

Alrighty! Test Badge

Salamandar commented 7 months ago

It looks like the required changes (customizing the port) were merged onto master. Thanks <3

CodeShakingSheep commented 7 months ago

@Salamandar The required port changes were only merged for the install script. However, they are required too for upgrade and restore scripts. This is what I did in this PR. Without the changes from this PR a user with a Jenkins installation on an alternative port is still f`***** as it's neither possible to upgrade the app nor to restore it. It happened to me which was why I did this PR. So please reopen it and merge it. It was thorougly tested from my side and another user.