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

feanil/fix uwsgi xml issues #1156

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f3f5e45
fix: nightly version suffix
regisb Jun 19, 2024
cf7e76b
Merge remote-tracking branch 'origin/master' into nightly
Jun 21, 2024
9379dc0
Merge remote-tracking branch 'origin/master' into nightly
Jun 25, 2024
30fa1ea
chore: ensure plugins are installed from nightly branches in nightly
DawoudSheraz Jun 25, 2024
0dc8bf7
Merge remote-tracking branch 'origin/master' into nightly
Jun 25, 2024
3e7c558
Merge remote-tracking branch 'origin/master' into nightly
Jul 4, 2024
b8a6d53
Merge remote-tracking branch 'origin/master' into nightly
Jul 4, 2024
ae53c49
Merge remote-tracking branch 'origin/master' into nightly
Jul 11, 2024
53cffff
Merge remote-tracking branch 'origin/master' into nightly
Jul 15, 2024
044eede
Merge remote-tracking branch 'origin/master' into nightly
Jul 26, 2024
55d8289
Merge remote-tracking branch 'origin/master' into nightly
Jul 30, 2024
ba666e3
Merge remote-tracking branch 'origin/master' into nightly
Jul 30, 2024
27117e3
Merge remote-tracking branch 'origin/master' into nightly
Jul 30, 2024
91bffc9
Merge remote-tracking branch 'origin/master' into nightly
Aug 8, 2024
7bec007
Merge remote-tracking branch 'origin/master' into nightly
Aug 13, 2024
1b1e20f
Merge remote-tracking branch 'origin/master' into nightly
Aug 20, 2024
bbd5207
Merge remote-tracking branch 'origin/master' into nightly
Aug 27, 2024
5f1e6be
Merge remote-tracking branch 'origin/master' into nightly
Aug 27, 2024
487a433
Merge remote-tracking branch 'origin/master' into nightly
Sep 19, 2024
c9a5d89
Merge remote-tracking branch 'origin/master' into nightly
Sep 23, 2024
3892dd2
Merge remote-tracking branch 'origin/master' into nightly
Sep 24, 2024
0f2229b
fix: upgrade MySQL from 5.7 to 8.1 first and then to 8.4
Danyal-Faheem Sep 26, 2024
5520973
Merge remote-tracking branch 'origin/master' into nightly
Sep 27, 2024
613a9b8
Merge remote-tracking branch 'origin/master' into nightly
Oct 1, 2024
c7b8cef
Merge remote-tracking branch 'origin/master' into nightly
Oct 1, 2024
6843f14
feat: create volume for private LMS/CMS media assets (#1124)
ormsbee Oct 2, 2024
905c7a4
Merge branch 'master' into nightly
regisb Oct 8, 2024
b1acd73
Merge remote-tracking branch 'origin/master' into nightly
Oct 11, 2024
eccae41
Merge remote-tracking branch 'origin/master' into nightly
Oct 14, 2024
f7e223c
Merge remote-tracking branch 'origin/master' into nightly
Oct 15, 2024
a49c5a5
feat: migrate from *.local.edly.io to *.local.openedx.io
regisb Oct 10, 2024
5eea38d
Merge remote-tracking branch 'origin/master' into nightly
Oct 21, 2024
a78018e
Merge remote-tracking branch 'origin/master' into nightly
Oct 24, 2024
a695896
Merge remote-tracking branch 'origin/master' into nightly
Oct 24, 2024
3a11581
Merge remote-tracking branch 'origin/master' into nightly
Oct 24, 2024
7e68baa
feat: update Open edX image to use ubuntu 22.04 as base OS (#1117)
DawoudSheraz Oct 25, 2024
75aab6e
fix: run MySQL 8.1 as a separate container during upgrade from Olive …
Danyal-Faheem Oct 28, 2024
d1cc140
Merge remote-tracking branch 'origin/master' into nightly
Oct 29, 2024
d26ce46
Merge remote-tracking branch 'origin/master' into nightly
Oct 30, 2024
4bee2c0
Merge remote-tracking branch 'origin/master' into nightly
Nov 1, 2024
d4e6c6c
feat: add do command to change MySQL charset to utf8mb4 (#1079)
Danyal-Faheem Nov 11, 2024
ed456b1
fix: Don't build uwsgi with xml support.
feanil Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# It's important that we build the tutor binaries with the *oldest* possible
# OS releases and Python version. See these docs for more information:
# https://pyinstaller.org/en/stable/usage.html#making-gnu-linux-apps-forward-compatible
- os: ubuntu-20.04
- os: ubuntu-22.04
locale: C.UTF-8
# https://endoflife.date/macos
- os: macos-12
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ bootstrap-dev-plugins: bootstrap-dev ## Install dev requirements and all support
pip install -r requirements/plugins.txt

pull-base-images: # Manually pull base images
docker image pull docker.io/ubuntu:20.04
docker image pull docker.io/ubuntu:22.04

ci-info: ## Print info about environment
python --version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- 💥[Feature] Upgrade default charset and collation of mysql to utf8mb4 and utf8mb4_unicode_ci respectively (by @Danyal-Faheem)
- Add do command to upgrade the charset and collation of tables in mysql.
- The command will perform the following upgrades:
- Upgrade all `utf8mb3` charset to `utf8mb4`
- Upgrade collation `utf8mb3_general_ci` to `utf8mb4_unicode_ci`
- Upgrade collation `utf8mb3_bin` to `utf8mb4_bin`
- Upgrade collation `utf8mb3_*` to `utf8mb4_*`
1 change: 1 addition & 0 deletions changelog.d/20240926_151223_dave_private_media.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Feature] Create a new /data/openedx-media-private volume to store media files that are not publicly accessible via the browser, and create configuration that Learning Core (openedx-learning) will use to access this storage space. Learning Core will use a sub-directory of /data/openedx-media-private to store Content Library file uploads, but other apps can create their own sub-directories for their own use. (by @ormsbee)
2 changes: 2 additions & 0 deletions changelog.d/20241010_122752_dawoud.sheraz_ubuntu_upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- 💥[Feature] Update Open edX Image to use Ubuntu 22.04 as base OS. (by @dawoudsheraz)
- Adds xmlsec related dependencies to fix xmlsec import issues during translations build
1 change: 1 addition & 0 deletions changelog.d/20241010_131903_regis_local_openedx_io.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 💥[Feature] Migrate from local.edly.io to local.openedx.io. (by @regisb)
6 changes: 3 additions & 3 deletions docs/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This will perform several tasks. It will:
* build the "openedx-dev" Docker image, which is based on the "openedx" production image but is `specialized for developer usage`_ (eventually with your fork),
* stop any existing locally-running Tutor containers,
* disable HTTPS,
* set ``LMS_HOST`` to `local.edly.io <http://local.edly.io>`_ (a convenience domain that simply `points at 127.0.0.1 <https://dnschecker.org/#A/local.edly.io>`_),
* set ``LMS_HOST`` to `local.openedx.io <http://local.openedx.io>`_ (a convenience domain that simply `points at 127.0.0.1 <https://dnschecker.org/#A/local.openedx.io>`_),
* prompt for a platform details (with suitable defaults),
* start LMS, CMS, supporting services, and any plugged-in services,
* ensure databases are created and migrated, and
Expand All @@ -42,8 +42,8 @@ Additionally, when a local clone of edx-platform is bind-mounted, it will:

Once setup is complete, the platform will be running in the background:

* LMS will be accessible at `http://local.edly.io:8000 <http://local.edly.io:8000>`_.
* CMS will be accessible at `http://studio.local.edly.io:8001 <http://studio.local.edly.io:8001>`_.
* LMS will be accessible at `http://local.openedx.io:8000 <http://local.openedx.io:8000>`_.
* CMS will be accessible at `http://studio.local.openedx.io:8001 <http://studio.local.openedx.io:8001>`_.
* Plugged-in services should be accessible at their documented URLs.

Now, use the ``tutor dev ...`` command-line interface to manage the development environment. Some common commands are described below.
Expand Down
27 changes: 27 additions & 0 deletions docs/local.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,33 @@ The default Open edX theme is rather bland, so Tutor makes it easy to switch to

Out of the box, only the default "open-edx" theme is available. We also developed `Indigo, a beautiful, customizable theme <https://github.com/overhangio/indigo>`__ which is easy to install with Tutor.

Changing the mysql charset and collation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note:: This command has been tested only for users upgrading from Quince. While it is expected to work for users on earlier releases, please use it with caution as it has not been tested with those versions.

The database's charset and collation might not support specific characters or emojis. Tutor will function normally without this change unless specific characters are used in the instance.

.. warning:: This change is potentially irreversible. It is recommended to make a backup of the MySQL database. See the :ref:`database dump instructions <database_dumps>` to create a DB dump.

To change the charset and collation of all the tables in the openedx database, run::

tutor local do convert-mysql-utf8mb4-charset

Alternatively, to change the charset and collation of certain tables or to exclude certain tables, the ``--include`` or ``--exclude`` options can be used. These options take comma separated names of tables/apps with no space in-between. To upgrade the ``courseware_studentmodule`` and ``courseware_studentmodulehistory`` tables, run::

tutor local do convert-mysql-utf8mb4-charset --include=courseware_studentmodule,courseware_studentmodulehistory

Tutor performs pattern matching from the start of the table name so just the name of the app is enough to include/exclude all the tables under that app. To upgrade all the tables in the database except the ones under the student and wiki apps, run::

tutor local do convert-mysql-utf8mb4-charset --exclude=student,wiki

In the above command, all the tables whose name starts with either student or wiki will be excluded from the upgrade process.

By default, only the tables in the openedx database are changed. For upgrading tables in any additional databases used by plugins, the ``--database`` option can be used to upgrade them. To upgrade all the tables in the discovery database, run::

tutor local do convert-mysql-utf8mb4-charset --database=discovery

Running arbitrary ``manage.py`` commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions docs/tutorials/datamigration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ With Tutor, all data are stored in a single folder. This means that it's extreme

tutor local start -d

.. _database_dumps:

Making database dumps
---------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/theming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Then, run a local webserver::

tutor dev start lms

The LMS can then be accessed at http://local.edly.io:8000. You will then have to :ref:`enable that theme <settheme>`::
The LMS can then be accessed at http://local.openedx.io:8000. You will then have to :ref:`enable that theme <settheme>`::

tutor dev do settheme mythemename

Watch the themes folders for changes (in a different terminal)::

tutor dev run watchthemes

Make changes to some of the files inside the theme directory: the theme assets should be automatically recompiled and visible at http://local.edly.io:8000.
Make changes to some of the files inside the theme directory: the theme assets should be automatically recompiled and visible at http://local.openedx.io:8000.
28 changes: 14 additions & 14 deletions requirements/plugins.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# change version ranges when upgrading from redwood
tutor-android>=18.0.0,<19.0.0
tutor-cairn>=18.0.0,<19.0.0
tutor-credentials>=18.0.0,<19.0.0
tutor-discovery>=18.0.0,<19.0.0
tutor-ecommerce>=18.0.0,<19.0.0
tutor-forum>=18.0.0,<19.0.0
tutor-indigo>=18.0.0,<19.0.0
tutor-jupyter>=18.0.0,<19.0.0
tutor-mfe>=18.0.0,<19.0.0
tutor-minio>=18.0.0,<19.0.0
tutor-notes>=18.0.0,<19.0.0
tutor-webui>=18.0.0,<19.0.0
tutor-xqueue>=18.0.0,<19.0.0
# # For Tutor Nightly, we install plugins from their nightly branches instead of from PyPI
tutor-android@git+https://github.com/overhangio/tutor-android@nightly
tutor-cairn@git+https://github.com/overhangio/tutor-cairn@nightly
tutor-credentials@git+https://github.com/overhangio/tutor-credentials@nightly
tutor-discovery@git+https://github.com/overhangio/tutor-discovery@nightly
tutor-ecommerce@git+https://github.com/overhangio/tutor-ecommerce@nightly
tutor-forum@git+https://github.com/overhangio/tutor-forum@nightly
tutor-indigo@git+https://github.com/overhangio/tutor-indigo@nightly
tutor-jupyter@git+https://github.com/overhangio/tutor-jupyter@nightly
tutor-mfe@git+https://github.com/overhangio/tutor-mfe@nightly
tutor-minio@git+https://github.com/overhangio/tutor-minio@nightly
tutor-notes@git+https://github.com/overhangio/tutor-notes@nightly
tutor-webui@git+https://github.com/overhangio/tutor-webui@nightly
tutor-xqueue@git+https://github.com/overhangio/tutor-xqueue@nightly
75 changes: 75 additions & 0 deletions tests/commands/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,78 @@ def test_set_theme(self) -> None:
self.assertIn("lms-job", dc_args)
self.assertIn("assign_theme('beautiful', 'domain1')", dc_args[-1])
self.assertIn("assign_theme('beautiful', 'domain2')", dc_args[-1])

def test_convert_mysql_utf8mb4_charset_all_tables(self) -> None:
with temporary_root() as root:
self.invoke_in_root(root, ["config", "save"])
with patch("tutor.utils.docker_compose") as mock_docker_compose:
result = self.invoke_in_root(
root,
[
"local",
"do",
"convert-mysql-utf8mb4-charset",
"--non-interactive",
],
)
dc_args, _dc_kwargs = mock_docker_compose.call_args

self.assertIsNone(result.exception)
self.assertEqual(0, result.exit_code)
self.assertIn("lms-job", dc_args)
self.assertIn("utf8mb4", dc_args[-1])
self.assertIn("openedx", dc_args[-1])
self.assertIn("utf8mb4_unicode_ci", dc_args[-1])
self.assertNotIn("regexp", dc_args[-1])

def test_convert_mysql_utf8mb4_charset_include_tables(self) -> None:
with temporary_root() as root:
self.invoke_in_root(root, ["config", "save"])
with patch("tutor.utils.docker_compose") as mock_docker_compose:
result = self.invoke_in_root(
root,
[
"local",
"do",
"convert-mysql-utf8mb4-charset",
"--include=courseware_studentmodule,xblock",
],
)
dc_args, _dc_kwargs = mock_docker_compose.call_args

self.assertIsNone(result.exception)
self.assertEqual(0, result.exit_code)
self.assertIn("lms-job", dc_args)
self.assertIn("openedx", dc_args[-1])
self.assertIn("utf8mb4", dc_args[-1])
self.assertIn("utf8mb4_unicode_ci", dc_args[-1])
self.assertIn("regexp", dc_args[-1])
self.assertIn("courseware_studentmodule", dc_args[-1])
self.assertIn("xblock", dc_args[-1])

def test_convert_mysql_utf8mb4_charset_exclude_tables(self) -> None:
with temporary_root() as root:
self.invoke_in_root(root, ["config", "save"])
with patch("tutor.utils.docker_compose") as mock_docker_compose:
result = self.invoke_in_root(
root,
[
"local",
"do",
"convert-mysql-utf8mb4-charset",
"--database=discovery",
"--exclude=course,auth",
],
)
dc_args, _dc_kwargs = mock_docker_compose.call_args

self.assertIsNone(result.exception)
self.assertEqual(0, result.exit_code)
self.assertIn("lms-job", dc_args)
self.assertIn("utf8mb4", dc_args[-1])
self.assertIn("utf8mb4_unicode_ci", dc_args[-1])
self.assertIn("discovery", dc_args[-1])
self.assertIn("regexp", dc_args[-1])
self.assertIn("NOT", dc_args[-1])
self.assertIn("course", dc_args[-1])
self.assertIn("auth", dc_args[-1])
2 changes: 1 addition & 1 deletion tutor/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# the nightly branch.
# The suffix is cleanly separated from the __version__ in this module to avoid
# conflicts when merging branches.
__version_suffix__ = ""
__version_suffix__ = "nightly"

# The app name will be used to define the name of the default tutor root and
# plugin directory. To avoid conflicts between multiple locally-installed
Expand Down
106 changes: 106 additions & 0 deletions tutor/commands/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from tutor import config as tutor_config
from tutor import env, fmt, hooks
from tutor.commands.context import Context
from tutor.commands.jobs_utils import get_mysql_change_charset_query
from tutor.hooks import priorities


Expand Down Expand Up @@ -315,6 +317,109 @@ def sqlshell(args: list[str]) -> t.Iterable[tuple[str, str]]:
yield ("lms", command)


@click.command(
short_help="Convert the charset and collation of mysql to utf8mb4.",
help=(
"Convert the charset and collation of mysql to utf8mb4. You can either upgrade all tables, specify only certain tables to upgrade or specify certain tables to exclude from the upgrade process"
),
context_settings={"ignore_unknown_options": True},
)
@click.option(
"--include",
is_flag=False,
nargs=1,
help="Apps/Tables to include in the upgrade process. Requires comma-seperated values with no space in-between.",
)
@click.option(
"--exclude",
is_flag=False,
nargs=1,
help="Apps/Tables to exclude from the upgrade process. Requires comma-seperated values with no space in-between.",
)
@click.option(
"--database",
is_flag=False,
nargs=1,
default="{{ OPENEDX_MYSQL_DATABASE }}",
show_default=True,
required=True,
type=str,
help="The database of which the tables are to be upgraded",
)
@click.option("-I", "--non-interactive", is_flag=True, help="Run non-interactively")
@click.pass_obj
def convert_mysql_utf8mb4_charset(
context: Context,
include: str,
exclude: str,
database: str,
non_interactive: bool,
) -> t.Iterable[tuple[str, str]]:
"""
Do command to upgrade the charset and collation of tables in MySQL

Can specify whether to upgrade all tables, or include certain tables/apps or to exclude certain tables/apps
"""

config = tutor_config.load(context.root)

if not config["RUN_MYSQL"]:
fmt.echo_info(
f"You are not running MySQL (RUN_MYSQL=false). It is your "
f"responsibility to upgrade the charset and collation of your MySQL instance."
)
return

# Prompt user for confirmation of upgrading all tables
if not include and not exclude and not non_interactive:
upgrade_all_tables = click.confirm(
"Are you sure you want to upgrade all tables? This process is potentially irreversible and may take a long time.",
prompt_suffix=" ",
)
if not upgrade_all_tables:
return

charset_to_upgrade_from = "utf8mb3"
charset = "utf8mb4"
collation = "utf8mb4_unicode_ci"

query_to_append = ""
if include or exclude:

def generate_query_to_append(tables: list[str], exclude: bool = False) -> str:
include = "NOT" if exclude else ""
table_names = f"^{tables[0]}"
for i in range(1, len(tables)):
table_names += f"|^{tables[i]}"
# We use regexp for pattern matching the names from the start of the tablename
query_to_append = f"AND table_name {include} regexp '{table_names}' "
return query_to_append

query_to_append += (
generate_query_to_append(include.split(",")) if include else ""
)
query_to_append += (
generate_query_to_append(exclude.split(","), exclude=True)
if exclude
else ""
)
click.echo(
fmt.title(
f"Updating charset and collation of tables in the {database} database to {charset} and {collation} respectively."
)
)
query = get_mysql_change_charset_query(
database, charset, collation, query_to_append, charset_to_upgrade_from
)

mysql_command = (
"mysql --user={{ MYSQL_ROOT_USERNAME }} --password={{ MYSQL_ROOT_PASSWORD }} --host={{ MYSQL_HOST }} --port={{ MYSQL_PORT }} --skip-column-names --silent "
+ shlex.join([f"--database={database}", "-e", query])
)
yield ("lms", mysql_command)
fmt.echo_info("MySQL charset and collation successfully upgraded")


def add_job_commands(do_command_group: click.Group) -> None:
"""
This is meant to be called with the `local/dev/k8s do` group commands, to add the
Expand Down Expand Up @@ -390,6 +495,7 @@ def do_callback(service_commands: t.Iterable[tuple[str, str]]) -> None:

hooks.Filters.CLI_DO_COMMANDS.add_items(
[
convert_mysql_utf8mb4_charset,
createuser,
importdemocourse,
importdemolibraries,
Expand Down
Loading