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

Set markdown to None in module cache to prevent it being imported by DRF. #11897

Merged

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented Feb 17, 2024

Summary

Django REST Framework automatically attempts to import the markdown module if available.
The version we use checks the version attribute, however the latest versions of the markdown module use version instead of version, and an error happens at runtime.
Fix this by setting markdown to None in module cache.
This means that when DRF tries to import markdown, it will raise an ImportError and DRF will carry on, rather than trying to check the version.

References

Fixes #11895

Reviewer guidance

This is best tested in a fresh virtual environment using Python 3.11.
First download the whl file from this PR and install it into the virtual environment pip install <path to whl file.
Then install markdown: pip install markdown
Confirm that running Kolibri does not immediately give an error (as it does in the issue referenced).


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Feb 17, 2024
@rtibbles rtibbles changed the title Add dummy markdown module into dist to prevent markdown from being used by DRF. Set markdown to None in module cache to prevent it being imported by DRF. Feb 17, 2024
Copy link
Member

@jredrejo jredrejo left a comment

Choose a reason for hiding this comment

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

LGTM

@marcellamaki marcellamaki self-requested a review February 19, 2024 17:21
Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

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

confirming manual qa checks out

@radinamatic
Copy link
Member

Installing DEB on Ubuntu gave one Job for kolibri.service failed error (see below), but apparently no user-facing consequences, as I went through the setup wizard and channel import without issues.

Kolibri was also running fine after the VM reboot, so the system service seems to be running also... 🤷🏽

2024-02-19_20-28-05
kolibrien@kolibriU20:~/Desktop$ sudo dpkg -i kolibri_0.16.0rc1.dev0+git.2.g5c520040-0ubuntu1_all.deb 
[sudo] password for kolibrien: 
Selecting previously unselected package kolibri.
(Reading database ... 304021 files and directories currently installed.)
Preparing to unpack kolibri_0.16.0rc1.dev0+git.2.g5c520040-0ubuntu1_all.deb ...
Unpacking kolibri (0.16.0rc1.dev0+git.2.g5c520040-0ubuntu1) ...
Setting up kolibri (0.16.0rc1.dev0+git.2.g5c520040-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/kolibri.service → /lib/systemd/system/kolibri.service.
Job for kolibri.service failed because the control process exited with error code.
See "systemctl status kolibri.service" and "journalctl -xe" for details.
Synchronizing state of kolibri.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable kolibri
Processing triggers for systemd (245.4-4ubuntu3.23) ...
kolibrien@kolibriU20:~/Desktop$ systemctl status kolibri.service
● kolibri.service - LSB: kolibri daemon, an offline education platform
     Loaded: loaded (/etc/init.d/kolibri; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-02-19 20:15:18 CET; 18s ago
      Tasks: 123 (limit: 9430)
     Memory: 111.0M
     CGroup: /system.slice/kolibri.service
             └─3882 /usr/bin/python3 /bin/kolibri start

Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 Running installation routines for kolibri.plugins.user_profile,>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 kolibri.plugins.user_profile successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,404 Starting Kolibri 0.16.0rc1.dev0+git.2.g5c520040
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Bus state: ENTER
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Running Kolibri as background process
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://127.0.0.1:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://192.168.1.44:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Kolibri running on: http://172.27.63.113:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Going to background mode, logging to /home/kolibrien/.kolibri/l>
Feb 19 20:15:18 kolibriU20 systemd[1]: Started LSB: kolibri daemon, an offline education platform.
lines 1-18/18 (END)...skipping...
● kolibri.service - LSB: kolibri daemon, an offline education platform
     Loaded: loaded (/etc/init.d/kolibri; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-02-19 20:15:18 CET; 18s ago
      Tasks: 123 (limit: 9430)
     Memory: 111.0M
     CGroup: /system.slice/kolibri.service
             └─3882 /usr/bin/python3 /bin/kolibri start

Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 Running installation routines for kolibri.plugins.user_profile,>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 kolibri.plugins.user_profile successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,404 Starting Kolibri 0.16.0rc1.dev0+git.2.g5c520040
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Bus state: ENTER
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Running Kolibri as background process
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://127.0.0.1:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://192.168.1.44:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Kolibri running on: http://172.27.63.113:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Going to background mode, logging to /home/kolibrien/.kolibri/l>
Feb 19 20:15:18 kolibriU20 systemd[1]: Started LSB: kolibri daemon, an offline education platform.
~
~
~
~
~
~
lines 1-18/18 (END)...skipping...


~
~

kolibrien@kolibriU20:~/Desktop$ journalctl -xe
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,247 Running installation routines for kolibri.plugins.learn, instal>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,248 kolibri.plugins.learn successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,248 Running installation routines for kolibri.plugins.user_auth, in>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,248 kolibri.plugins.user_auth successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,249 Running installation routines for kolibri.plugins.facility, ins>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,249 kolibri.plugins.facility successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,249 Running installation routines for kolibri.plugins.html5_viewer,>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,249 kolibri.plugins.html5_viewer successfully updated
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 Running installation routines for kolibri.plugins.user_profile,>
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,250 kolibri.plugins.user_profile successfully updated
Feb 19 20:15:17 kolibriU20 systemd[1]: Started Daemon for generating UUIDs.
-- Subject: A start job for unit uuidd.service has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit uuidd.service has finished successfully.
-- 
-- The job identifier is 3382.
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,404 Starting Kolibri 0.16.0rc1.dev0+git.2.g5c520040
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Bus state: ENTER
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,551 Running Kolibri as background process
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://127.0.0.1:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,552 Kolibri running on: http://192.168.1.44:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Kolibri running on: http://172.27.63.113:8080/
Feb 19 20:15:17 kolibriU20 kolibri[3783]: INFO     2024-02-19 20:15:17,553 Going to background mode, logging to /home/kolibrien/.kolibri/l>
Feb 19 20:15:18 kolibriU20 runuser[3782]: pam_unix(runuser:session): session closed for user kolibrien
Feb 19 20:15:18 kolibriU20 systemd[1]: Started LSB: kolibri daemon, an offline education platform.
-- Subject: A start job for unit kolibri.service has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit kolibri.service has finished successfully.
-- 
-- The job identifier is 3305.
Feb 19 20:15:18 kolibriU20 systemd[1]: Reloading.
Feb 19 20:15:18 kolibriU20 sudo[3512]: pam_unix(sudo:session): session closed for user root
lines 2533-2568/2568 (END)

@radinamatic
Copy link
Member

Similarly to above, installing EXE asset on Windows 11 did complete eventually, but gave 2 errors, with apparently no user facing consequences, as I was able to go through the setup wizard, and import the facility from the Ubuntu VM.

Zipped home folder:
.kolibri.zip

1 2
2024-02-19_21-07-19 2024-02-19_21-06-47

@marcellamaki
Copy link
Member

Smoke test on pex and dmg work with no errors

@marcellamaki
Copy link
Member

Merging to cut an rc2 and test the pi build from there

@marcellamaki marcellamaki merged commit 96c528b into learningequality:release-v0.16.x Feb 19, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: small SIZE: very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants