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

How do we fix Kolibri Channel Import failures with http://box/kolibri configured by KOLIBRI_URL_PATH_PREFIX=/kolibri ? #9455

Closed
holta opened this issue May 20, 2022 · 14 comments · Fixed by #9533
Assignees

Comments

@holta
Copy link

holta commented May 20, 2022

Thanks to @shanti-bhardwa who helped spell out this longstanding issue, and also @jvonau, @tim-moody who both reconfirmed!

The solution might not be simple (?) but let's try to find a way forward here together — as there are a quickly growing number of Internet-in-a-Box communities around the world using Kolibri:

PROBLEM SUMMARY: If you try to import a Kolibri channel using Kolibri > Channels > Import > Select a source > "Local network or internet", it will fail as the other Kolibri machine's KOLIBRI_URL_PATH_PREFIX=/kolibri is somehow being ignored:

  • The problem occurs when The Other Kolibri Machine has the form http://box/kolibri
  • Whereas if The Other Kolibri Machine is manually hacked to instead run Kolibri on http://box:8009, the channel import then works.

BACKGROUND: KOLIBRI_URL_PATH_PREFIX=/kolibri is installed within /etc/systemd/system/kolibri.service whenever you install Internet-in-a-Box, as seen on Line 10 below.

[Unit]
Description=Kolibri

[Service]
Type=forking
RemainAfterExit=yes
Environment=KOLIBRI_USER=kolibri
Environment=KOLIBRI_HOME=/library/kolibri
Environment=KOLIBRI_HTTP_PORT=8009
Environment=KOLIBRI_URL_PATH_PREFIX=/kolibri
User=kolibri
Group=www-data
# 2020-10-03: Kolibri was timing out on RaspiOS & Ubuntu 20 NUC: iiab/iiab#2555
TimeoutStartSec=1200
# The following is the systemd default, which is too much for most teachers in
# low-electricity environments (30-60 sec is about all they can handle before
# pulling the power cord, typically every hour at the end of class).  But since
# 90 seconds is the Linux / systemd default, it's prob good enough for now:
# TimeoutStopSec=90
# 2020-04-18 @jvonau: comment out both timeouts for now, in favor of 90 seconds
# or whatever systemd / Kolibri favor? https://github.com/iiab/iiab/issues/2318
# TimeoutStartSec=infinity
# TimeoutStopSec=10
ExecStart=/usr/bin/kolibri start
ExecStop=/usr/bin/kolibri stop

[Install]
WantedBy=multi-user.target

GENERAL KOLIBRI QUESTION (PERHAPS UNRELATED?) /etc/kolibri/daemon.conf currently always contains the single line KOLIBRI_HOME="/library/kolibri" on Internet-in-a-Box machines, so a suggestion was made — should this really contain all 4 variables above including KOLIBRI_URL_PATH_PREFIX=/kolibri ? As background, here's the current /etc/kolibri configuration of all Internet-in-a-Box machines:

root@box:/etc/kolibri# ls
conf.d  daemon.conf  README  username

root@box:/etc/kolibri# ls conf.d

root@box:/etc/kolibri# more username
kolibri

root@box:/etc/kolibri# more daemon.conf
KOLIBRI_HOME="/library/kolibri"

CONTEXT: Internet-in-a-Box installs Kolibri's latest .deb (https://learningequality.org/r/kolibri-deb-latest) according to the instructions provided by many helpful Learning Equality staff over the years (e.g. Benjamin Bach and others!) Then it runs...

export KOLIBRI_HOME=/library/kolibri &&
/usr/bin/kolibri manage provisiondevice \
--facility Kolibri-in-a-Box \
--superusername Admin \
--superuserpassword changeme \
--preset formal \
--language_id en

...according to https://github.com/iiab/iiab/blob/b1ce429f500cbac544a6f6f5f66eb2542d616039/roles/kolibri/tasks/install.yml#L70-L80

DOC: https://kolibri.readthedocs.io/en/latest/manage/resources.html#import-from-a-local-network-or-internet

Tangentially related:

@shanti-bhardwa
Copy link

How do you apply this hack and test that IMPORT works ??
"Whereas if The Other Kolibri Machine is manually hacked to instead run Kolibri on http://box:8009/, the channel import then works".

@tim-moody
Copy link

How do you apply this hack

On the server from which you wish to import:

  • manually edit /etc/systemd/system/kolibri.service, commenting out Environment=KOLIBRI_URL_PATH_PREFIX=/kolibri
  • systemctl daemon-reload
  • systemctl restart kolibri

With this change I was able to successfully import a channel as usual.

@rtibbles
Copy link
Member

This is a long standing issue with the Kolibri peer discovery not encoding the URL prefix information into the information it broadcasts to its peers. This would be best fixed by having peers broadcast their URL prefix to allow construction of the full base url for the Kolibri instance.

@rtibbles rtibbles added this to the Planned Patch 3: TBD milestone May 23, 2022
@rtibbles
Copy link
Member

I have added this to the next planned patch milestone for the 0.15.x series, so hopefully we can release a fix for this by sometime in mid-July.

@tim-moody
Copy link

Please note that even if I add a custom server with the prefix in the url, that prefix is stripped out when issuing the api call.

@shanti-bhardwa
Copy link

I have tested the suggested fix by commenting out the line Environment=KOLIBRI_URL_PATH_PREFIX=/kolibri in /etc/systemd/system/kolibri.service, and then
systemctl daemon-reload
systemctl restart kolibri
followed by kolibri start as well.

The fix works and I can import channels from two IIAB servers, one running IIAB 8.0 on PI400 Desktop and the second on IIAB 8.0 on Linux Mint 2.3. Both servers connect to each other on the LAN.

when I do kolibri status the on PI400 I get
iiab-admin@PI400:~ $ kolibri status
INFO: No C extensions are available for this platform
Stopped (1)

but systemctl status kolibri.service gives me
kolibri.service - Kolibri
Loaded: loaded (/etc/systemd/system/kolibri.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-05-23 16:48:01 EDT; 29min ago
Process: 3415 ExecStart=/usr/bin/kolibri start (code=exited, status=0/SUCCESS)
Main PID: 3425 (kolibri)
Tasks: 123 (limit: 4163)
CPU: 4min 40.575s
CGroup: /system.slice/kolibri.service
└─3425 /usr/bin/python3 /usr/bin/kolibri start

May 23 16:47:59 PI400 kolibri[3415]: INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
May 23 16:48:00 PI400 kolibri[3415]: INFO Importing 'tasks' module from django apps
May 23 16:48:00 PI400 kolibri[3415]: INFO Kolibri running on: http://192.168.1.249:8009/
May 23 16:48:00 PI400 kolibri[3415]: INFO Kolibri running on: http://127.0.0.1:8009/
May 23 16:48:00 PI400 kolibri[3415]: INFO Kolibri running on: http://192.168.1.248:8009/

May 23 16:48:00 PI400 kolibri[3415]: INFO Starting Kolibri 0.15.2
May 23 16:48:00 PI400 kolibri[3415]: INFO Bus state: ENTER
May 23 16:48:00 PI400 kolibri[3415]: INFO Running Kolibri as background process
May 23 16:48:00 PI400 kolibri[3415]: INFO Going to background mode, logging to /library/kolibri/logs/kolibri.txt
May 23 16:48:01 PI400 systemd[1]: Started Kolibri.

My WIFI interface is running on PI400 hence I get the three above entries in BOLD.

On the Linux server, hostapd is not running for some reason so I get

sb01@boxwiki:$ kolibri status
Unclean shutdown (7)
sb01@boxwiki:
$ sb01@boxwiki:~$ systemctl status kolibri.service
● kolibri.service - Kolibri
Loaded: loaded (/etc/systemd/system/kolibri.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-05-23 22:05:22 BST; 18min ago
Process: 557 ExecStart=/usr/bin/kolibri start (code=exited, status=0/SUCCESS)
Main PID: 1415 (kolibri)
Tasks: 122 (limit: 4393)
Memory: 148.2M
CGroup: /system.slice/kolibri.service
└─1415 /usr/bin/python3 /usr/bin/kolibri start

May 23 22:05:21 boxwiki kolibri[557]: INFO Running Kolibri with the following settings: kolibri.deployment.default.settings.base
May 23 22:05:21 boxwiki kolibri[557]: INFO Importing 'tasks' module from django apps
May 23 22:05:22 boxwiki kolibri[557]: INFO Kolibri running on: http://172.18.96.1:8009/
May 23 22:05:22 boxwiki kolibri[557]: INFO Kolibri running on: http://192.168.1.221:8009/
May 23 22:05:22 boxwiki kolibri[557]: INFO Kolibri running on: http://127.0.0.1:8009/

May 23 22:05:22 boxwiki kolibri[557]: INFO Starting Kolibri 0.15.2
May 23 22:05:22 boxwiki kolibri[557]: INFO Bus state: ENTER
May 23 22:05:22 boxwiki kolibri[557]: INFO Running Kolibri as background process
May 23 22:05:22 boxwiki kolibri[557]: INFO Going to background mode, logging to /library/kolibri/logs/kolibri.txt
May 23 22:05:22 boxwiki systemd[1]: Started Kolibri

I cannot open Kolibri from the IIAB home page as this does not work 192.168.1.221/kolibri does not work
But 192.168.1.221:8009 works as suggested in the description of the issue.

So we have a solution. I will do some more testing, this time building a MASTER Kolibri with all the channels we need and then IMPORT these on to a second server over the LAN. LAN IMPORT is much faster than Internet IMPORT

@rtibbles
Copy link
Member

Please note that even if I add a custom server with the prefix in the url, that prefix is stripped out when issuing the api call.

Yeah, we should also address that behaviour for cases where the auto-discovery is not suitable (such as connecting to an online instance of Kolibri).

@shanti-bhardwa
Copy link

This fix is not critical as we can EXPORT & IMPORT channels via local drive. One simple work around ( not very elegant) would be do a command like iiab-kolibri-lan-import-on which applies the fix and the iiab-kolibri-lan-import-off which reverses it. This is only required for Admin purposes.

@jvonau
Copy link

jvonau commented May 24, 2022

This fix is not critical as we can EXPORT & IMPORT channels via local drive. One simple work around ( not very elegant) would be do a command like iiab-kolibri-lan-import-on which applies the fix and the iiab-kolibri-lan-import-off which reverses it. This is only required for Admin purposes.

That comment would seem more appropriate for IIAB's tracker as IIAB, to my knowledge is the only place where KOLIBRI_URL_PATH_PREFIX is being used and summarizes what was discussed in chat. Just need someone to do up the PR for the kluge for IIAB or wait for the real fix.

@holta
Copy link
Author

holta commented May 24, 2022

wait for the real fix

Agreed.

@shanti-bhardwa is a rare person who can tolerate command-line interventions. (Thankfully he now has a workaround for the coming months.)

The general public however, cannot tolerate "kludgy" command-line workarounds. We need a more intuitive fix in the end. (Hopefully in July or soon!)

@holta
Copy link
Author

holta commented Jun 22, 2022

I have added this to the next planned patch milestone for the 0.15.x series, so hopefully we can release a fix for this by sometime in mid-July.

Looks like Kolibri 0.15.4 was released today:

https://github.com/learningequality/kolibri/releases/tag/v0.15.4

Hopefully Kolibri Channel Imports will work with the KOLIBRI_URL_PATH_PREFIX variable starting with 0.15.5 (-:

@holta
Copy link
Author

holta commented Jul 1, 2022

Thanks @rtibbles for your ongoing efforts:

With Kolibri 0.15.5 now released, are sync'ing improvements possible as part of 0.15.6 or "Planned Patch 4" in coming weeks (or in August if July's not possible?)

@marcellamaki
Copy link
Member

marcellamaki commented Jul 1, 2022

Hi @holta - yes. As Richard mentioned in May, this issue is part of our planned/themed patch release schedule, which are released on a 6 week cadence. This is still our timeline - Planned Patch 4 for is scheduled for mid-July as Richard noted then, with the planned release date being July 20th, as indicated on the milestone. The PR associated with this issue will be part of that release.

@rtibbles
Copy link
Member

This has now been fixed in #9533 - this update will be released by July 20th in 0.15.6.

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