Package_check : unable to reproduce 502 issue

Hello,
I’m trying to check my app Testing branch through package_check.
The script is issuing an error 502 on the root install but I’m not able to reproduce it via my test VM.
Here is the check_process file:

;; Complete Test
# Comment ignored
        ; Manifest
                domain="domain.tld"     (DOMAIN)
                path="/calibre" (PATH)
                calibre_path="/home/yunohost.app/calibreweb"
                admin="john"    (USER)
                language="en"
                is_public=0     (PUBLIC|public=1|private=0)
                upload=1
                password="password"
#               port="8083"     (PORT)
        ; Checks
                pkg_linter=1
                setup_sub_dir=0
                setup_root=1
                setup_private=0
                setup_public=0
                upgrade=0
#               upgrade=0       from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
                backup_restore=0
                multi_instance=0
                incorrect_path=0
                port_already_use=0 (8083)
                change_url=0
;;; Levels
        Level 1=auto
        Level 2=auto
        Level 3=auto
        Level 4=0
        Level 5=auto
        Level 6=auto
        Level 7=auto
        Level 8=0
        Level 9=0
        Level 10=0
;;; Options
Email=
Notification=none
;;; Upgrade options
#       ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
                name=Name of this previous version
                manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=0&

Here is the Yunohost log from package_check:
https://paste.yunohost.org/ojayunogub

The log from package_check itself:
https://paste.yunohost.org/boweresome

And here is the install log from my test VM:
https://paste.yunohost.org/juzawisuze

Hope it’s not too much logs :slight_smile:

Anyway, when I try to install my app with exactly the same settings as package check, it’s working perfectly as the app’s logon page is displayed and no 502 error is thrown.

Any idea of how I could investigate this error?
Thanks for your help!

Actually, that’s a common error, shown by Package check.
Package check will try to reach your app immediately after the installation, and that’s often to quickly after.
But, for an user on a slow device, it can happens as well.

So, a solution could be to add a sleep after the start of your service, here https://github.com/YunoHost-Apps/calibre_ynh/blob/master/scripts/install#L215.

But, the best thing to do is to have a look to this experimental helper, https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_systemd_action/ynh_systemd_action.
This helper is meant to handle services, and also with the --line_match argument, you can define a line in the log which indicate that the service is fully started and ready to work.
That’s the best solution to fix that issue with Package check, and to enhance the user experience.

1 Like

Almost there!

Package linter:                  SUCCESS
Installation:                    SUCCESS
Deleting:                        SUCCESS
Installation in a sub path:      SUCCESS
Deleting from a sub path:        SUCCESS
Installation on the root:        SUCCESS
Deleting from root:              SUCCESS
Upgrade:                         FAIL
Installation in private mode:    SUCCESS
Installation in public mode:     SUCCESS
Multi-instance installations:    Not evaluated.
Malformed path:                  SUCCESS
Port already used:               SUCCESS
Backup:                          SUCCESS
Restore:                         FAIL
Change URL:                      FAIL

I implemented ynh_systemd_action and it worked immediately!
Thanks a lot

I still have an issue with package_check:
Upgrade from previous commit fails due to following error:

Try to access by url...
Test url: sous.domain.tld/calibre
Real url: https://domain.tld/yunohost/sso/?r=aHR0cHM6Ly9zb3VzLmRvbWFpbi50bGQvY2FsaWJyZQ==
HTTP code: 200
Title of the page: YunoHost Portal
The connection attempt fall on the YunoHost portal.

But what I don’t understand is that both my manifest and my upgrade_option use is_public=0, meaning private install.

;; Complete Test
# First Run of complete test
        ; Manifest
                domain="domain.tld"     (DOMAIN)
                path="/calibre" (PATH)
                calibre_path="/home/yunohost.app/calibreweb"
                admin="john"    (USER)
                language="en"
                is_public=0     (PUBLIC|public=1|private=0)
                upload=1
                password="a very long password"
        ; Checks
                pkg_linter=1
                setup_sub_dir=1
                setup_root=1
                setup_private=1
                setup_public=1
                upgrade=1       from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341
                backup_restore=1
                multi_instance=0
                incorrect_path=1
                port_already_use=1 (8083)
                change_url=1
;;; Levels
        Level 1=auto
        Level 2=auto
        Level 3=auto
        Level 4=0
        Level 5=auto
        Level 6=auto
        Level 7=auto
        Level 8=0
        Level 9=0
        Level 10=0
;;; Options
Email=
Notification=none
;;; Upgrade options
        ; commit=3b9c5041e4fa73cb965368379f2b83d076c65341
                name=First in progress release of the app 0.9~ynh1
                manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=0&

If I set is_public=1 for upgrade option, it works, but it seems wrong to me.
Any idea?

Turn is_public to 1, otherwise your app will be private.

Hmm…
I’m not sure I understand the way package_check perform this part of the test or its purpose in this case?
Should it not be checking the upgrade also in private mode? As per standard install where is_public is set to 0 but the test is successful nevertheless?

For the other tests, package_check is using is_public to turn your app as publicly accessible in purpose of the test. Except for the private test of course. It doesn’t matter what’s the value of is_public at the beginning of the check_process.
But, for this test, the values put in manifest_arg will be used as they are. So the app is here installed as a private app then upgraded as private. So the app is still private and package_check can’t reach it.

1 Like

OK, I understand now. I would recommend adding this explanation to the package_check manual as it is not very clear (or is it me? :thinking: )

By the way: Quickest answers I have never had in any forum I asked a question, GG!