Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# How to contribute

External contributions are welcome and strongly encouraged. There are only a few
guidelines you need to follow.

## Commit and Pull Request Guidelines

We expect code submissions to go through code review. We use GitHub pull
requests for this purpose.

When submitting a change make sure to provide all the necessary context upfront
for maintainers to see. A well crafted commit message and PR description goes a
long way in speeding up the reviewing process.

Like other projects in the Open edX ecosystem, we use [Conventional Commits]. A
one-line commit message is sufficient for small or self-evident changes.
Extensive changes or those with deeper technical implications require longer
explanations in the commit body. If you are unsure how to start, read this guide
on [how to write good commit messages].

Document changes that have a direct effect on the user in the `CHANGELOG.md`
file. We use [`scriv`] to manage changelog entries and compile them into the
final `CHANGELOG.md` for each release. Run `make changelog-entry` to create a
fragment, edit it accordingly, and include it in your PR.

[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/
[how to write good commit messages]: https://cbea.ms/git-commit/
[`scriv`]: https://scriv.readthedocs.io/

## Development

We use [uv](https://github.com/astral-sh/uv) for project and dependency
management. You will need to install relatively recent version of the uv CLI to
make use of any the Makefile targets and common development workflow.

Run `uv sync` to set up the development environment. You can then run commands
prefixed with `uv run` for development, including running Tutor itself. We
recommend pointing the `TUTOR_ROOT` and `TUTOR_PLUGINS_ROOT` environment
variables to an isolated location for a clean environment.

Several Make targets are available for common actions. Run `make help` or `make`
without a target to list them.

## Releases

New releases are tagged on GitHub and published to PyPI via a manually triggered
GitHub Action.

Follow these steps to perform a release:

1. Create release commit bumping the package version and send a PR for review.
We follow [Semantic Versioning], but major versions are only bumped between
Open edX releases. Note: a release commit does not need to be standalone, it
can be bundled with a feature change.
2. Run `make changelog-collect` to gather changelog entries (this must be done
after bumping the version).
3. After reviewing and merging the release commit, manually trigger the CI
workflow in GitHub Actions targeting the `main` branch.
4. Verify the workflow runs without errors and the package is properly published
to PyPI.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
.PHONY: help

quality: ## Run linters
uv run ruff check
uv run ruff format --diff
uv run ty check
uv run ruff check
uv run ruff format --diff
uv run ty check
uv run rumdl check --diff README.md

quality-fix: ## Run automatic linter fixes
uv run ruff format
uv run ruff check --fix
uv run ruff format
uv run ruff check --fix
uv run rumdl fmt README.md

changelog-entry: ## Run scriv to create a changelog entry
uv run scriv create
Expand Down
127 changes: 79 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Drydock
=======

Drydock is an opinionated tool offering a set of Tutor plugins aiming to provide features that enhance the operation of OpenedX installations in Kubernetes. It is developed by [Edunext](https://www.edunext.co/).

- A set of Kubernetes Jobs that replace the current tutor jobs with [ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) that allow for a more controlled deployment of openedx.
- A set of Kustomization overrides adding [ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) annotations to needed additional resources such as debug, workers or hpa.
Drydock is an opinionated tool offering a set of Tutor plugins aiming to provide features that
enhance the operation of OpenedX installations in Kubernetes. It is developed by
[Edunext](https://www.edunext.co/).

- A set of Kubernetes Jobs that replace the current tutor jobs with
[ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) that allow
for a more controlled deployment of openedx.
- A set of Kustomization overrides adding
[ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) annotations
to needed additional resources such as debug, workers or hpa.
- Backup cronjobs that allow backup of the MySQL and MongoDB databases.
- Integration of New Relic monitoring
- Add a custom nginx and cert-manager configuration
Expand All @@ -14,25 +20,8 @@ Extra plugins added:

- Allows caddy to catch requests for multiple domains through `DRYDOCK_ENABLE_MULTITENANCY`
- Add scorm matcher to caddy through `DRYDOCK_ENABLE_SCORM`
- Patch for cms and lms worker pods to allow pod probes and lifecycle to work properly. Enabled via `DRYDOCK_POD_LIFECYCLE`

Version compatibility matrix
----------------------------

You must install a supported release of this plugin to match the Open
edX and Tutor version you are deploying. If you are installing this
plugin from a branch in this Git repository, you must select the
appropriate one:

| Open edX release | Tutor version | Plugin branch | Plugin release |
|------------------|-------------------|---------------|----------------|
| Maple | `>=13.2, <14` | Not supported | 0.7.x |
| Nutmeg | `>=14.0, <15` | Not supported | 0.7.x |
| Olive | `>=15.0, <16` | Not supported | 15.x.x |
| Palm | `>=16.0, <17` | Not supported | 16.x.x |
| Quince | `>=17.0, <18` | `quince` | 17.x.x |
| Redwood | `>=18.0, <19` | `redwood` | 18.x.x |
| Sumac | `>=19.0, <20` | `main` | >=19.0.0 |
- Patch for cms and lms worker pods to allow pod probes and lifecycle to work properly. Enabled via
`DRYDOCK_POD_LIFECYCLE`

Installation
------------
Expand All @@ -56,28 +45,51 @@ Configuration
The following configuration options are available:

- `DRYDOCK_INIT_JOBS`: Whether run the initialization jobs or not. Defaults to `false`.
- `DRYDOCK_INIT_JOBS_EXCLUDED`: A list of init jobs to exclude, eg.: `["mysql-job"]`. Defaults to `[]`.
- `DRYDOCK_INIT_JOBS_EXCLUDED`: A list of init jobs to exclude, eg.: `["mysql-job"]`. Defaults to
`[]`.
- `DRYDOCK_CMS_SSO_USER`: The username of the CMS SSO user. Defaults to `cms`.
- `DRYDOCK_AUTO_TLS`: Whether to use cert-manager to automatically generate TLS certificates. Defaults to `true`.
- `DRYDOCK_AUTO_TLS`: Whether to use cert-manager to automatically generate TLS certificates.
Defaults to `true`.
- `DRYDOCK_INGRESS`: Whether to deploy an ingress for the LMS and CMS. Defaults to `true`.
- `DRYDOCK_INGRESS_EXTRA_HOSTS`: A list of extra hosts to add to the ingress. Defaults to `[]`.
- `DRYDOCK_INGRESS_LMS_EXTRA_HOSTS`: A list of extra hosts to add to the LMS ingress. Defaults to `[]`.
- `DRYDOCK_CUSTOM_CERTS`: A dictionary of custom certificates to use with cert-manager. Defaults to `{}`.
- `DRYDOCK_INGRESS_LMS_EXTRA_HOSTS`: A list of extra hosts to add to the LMS ingress. Defaults to
`[]`.
- `DRYDOCK_CUSTOM_CERTS`: A dictionary of custom certificates to use with cert-manager. Defaults to
`{}`.
- `DRYDOCK_NEWRELIC_LICENSE_KEY`: The New Relic license key. Defaults to `""`.
- `DRYDOCK_DEBUG`: Whether to deploy debug resources. Defaults to `false`.
- `DRYDOCK_ENABLE_MULTITENANCY`: Whether to enable multitennacy. Defaults to `true`.
- `DRYDOCK_ENABLE_SCORM`: Whether to enable scorm. Defaults to `true`.
- `DRYDOCK_POD_LIFECYCLE`: Whether to enable pod lifecycle. Defaults to `true`.
- `DRYDOCK_REGISTRY_CREDENTIALS`: A string with the credentials to access the private registry. The format should follow the [kubernetes config.json interpretation](https://kubernetes.io/docs/concepts/containers/images/#config-json). Defaults to `""`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_MFE`: The minimum available percentage for the MFE's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_FORUM`: The minimum available percentage for the FORUM's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CADDY`: The minimum available percentage for the CADDY's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS`: The minimum available percentage for the LMS's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER`: The minimum available percentage for the LMS WORKER's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS`: The minimum available percentage for the CMS's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER`: The minimum available percentage for the worker's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_MIGRATE_FROM`: it allows defining the version of the OpenedX platform we are migrating from. It accepts the integer value mapping the origin release, for instance, `13`(maple) or `14`(nutmeg). When this variable is set, a group of `release-specific upgrade jobs` are added to the Kubernetes manifests. These jobs are applied to the cluster in a suitable order (thanks to the GitOps implementation with ArgoCD + sync waves) to guarantee the correct behavior of the platform in the new version. This brings the `tutor k8s upgrade <https://github.com/overhangio/tutor/blob/v15.3.7/tutor/commands/k8s.py#L484>`_ command to the GitOps pattern. The release-specific upgrade jobs are supported from release `13`(maple). Defaults to `0` (which disables release-specific upgrade jobs)
- `DRYDOCK_EDGE_PROXY_ENABLED`: Whether to deploy a dedicated edge proxy (Caddy) and redirect all Ingress backends to it. Defaults to `false`.
- `DRYDOCK_REGISTRY_CREDENTIALS`: A string with the credentials to access the private registry. The
format should follow the
[kubernetes config.json interpretation](https://kubernetes.io/docs/concepts/containers/images/#config-json).
Defaults to `""`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_MFE`: The minimum available percentage for the MFE's
PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_FORUM`: The minimum available percentage for the FORUM's
PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CADDY`: The minimum available percentage for the CADDY's
PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS`: The minimum available percentage for the LMS's
PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER`: The minimum available percentage for the LMS
WORKER's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS`: The minimum available percentage for the CMS's
PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER`: The minimum available percentage for the
worker's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_MIGRATE_FROM`: it allows defining the version of the OpenedX platform we are migrating
from. It accepts the integer value mapping the origin release, for instance, `13`(maple) or
`14`(nutmeg). When this variable is set, a group of `release-specific upgrade jobs` are added to
the Kubernetes manifests. These jobs are applied to the cluster in a suitable order (thanks to the
GitOps implementation with ArgoCD + sync waves) to guarantee the correct behavior of the platform
in the new version. This brings the
`tutor k8s upgrade <https://github.com/overhangio/tutor/blob/v15.3.7/tutor/commands/k8s.py#L484>`_
command to the GitOps pattern. The release-specific upgrade jobs are supported from release
`13`(maple). Defaults to `0` (which disables release-specific upgrade jobs)
- `DRYDOCK_EDGE_PROXY_ENABLED`: Whether to deploy a dedicated edge proxy (Caddy) and redirect all
Ingress backends to it. Defaults to `false`.

> **_NOTE:_** You also need to set `DRYDOCK_INIT_JOBS` to `true` to enable the
> release-specific upgrade jobs in the case of a platform migration.
Expand Down Expand Up @@ -137,14 +149,22 @@ edge-proxy service.
Job generation
--------------

Tutor doesn't generate manifest files for the initialization jobs, in consequence we can't use GitOps tools like ArgoCD to deploy the initialization jobs.
Tutor doesn't generate manifest files for the initialization jobs, in consequence we can't use
GitOps tools like ArgoCD to deploy the initialization jobs.

We had been using a static definition of the initialization jobs, but now we are using the `Tutor filters <https://docs.tutor.edly.io/reference/api/hooks/filters.html>`_ to generate the kubernetes definition of the initialization jobs. This is a big improvement because now we can add new initialization jobs without modifying the Drydock code. The jobs are taken from `COMMANDS_PRE_INIT`, `COMMANDS_INIT` and `CLI_DO_INIT_TASKS` Filters.
We had been using a static definition of the initialization jobs, but now we are using the
`Tutor filters <https://docs.tutor.edly.io/reference/api/hooks/filters.html>`_ to generate the
kubernetes definition of the initialization jobs. This is a big improvement because now we can add
new initialization jobs without modifying the Drydock code. The jobs are taken from
`COMMANDS_PRE_INIT`, `COMMANDS_INIT` and `CLI_DO_INIT_TASKS` Filters.

ArgoCD Sync Waves Support
-----------------------

[Tutor filter](https://docs.tutor.edly.io/reference/api/hooks/filters.html) **SYNC_WAVES_ORDER** was added to allow define [ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) order and apply to the kubernetes resources through **get_sync_waves_for_resource** function.
[Tutor filter](https://docs.tutor.edly.io/reference/api/hooks/filters.html) **SYNC_WAVES_ORDER** was
added to allow define
[ArgoCD Sync Waves](https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/) order and apply
to the kubernetes resources through **get_sync_waves_for_resource** function.

We are defined by defult the following order:

Expand All @@ -158,9 +178,13 @@ We are defined by defult the following order:
Workaround to upgrade from Maple to Palm or later
-------------------------------------------------

> **_NOTE:_** Quince uses Django 4.2 which only supports MySQL 8 or higher. You must upgrade your version of MySQL prior to performing the upgrade.
> **_NOTE:_** Quince uses Django 4.2 which only supports MySQL 8 or higher. You must upgrade your
> version of MySQL prior to performing the upgrade.

The upgrade from Maple to Palm fails because an issue with a squashed migration in [edx-enterprise](https://github.com/openedx/edx-enterprise/blob/3.61.11/integrated_channels/blackboard/migrations/0001_initial_squashed_0014_alter_blackboardlearnerassessmentdatatransmissionaudit_enterprise_course_enrollment_id.py). To go around this issue, we need to apply migrations using an older version of edx-enterprise (3.60.4).
The upgrade from Maple to Palm fails because an issue with a squashed migration in
[edx-enterprise](https://github.com/openedx/edx-enterprise/blob/3.61.11/integrated_channels/blackboard/migrations/0001_initial_squashed_0014_alter_blackboardlearnerassessmentdatatransmissionaudit_enterprise_course_enrollment_id.py).
To go around this issue, we need to apply migrations using an older version of edx-enterprise
(3.60.4).

1. Run the sync to Palm without enabling the init jobs or upgrade jobs.

Expand All @@ -174,12 +198,14 @@ The upgrade from Maple to Palm fails because an issue with a squashed migration

3. Now, you can enable the init jobs and upgrade jobs and run the sync again.

This workaround references the [Andrey's comment](https://discuss.openedx.org/t/updating-tutor-lilac-to-palm-now-that-palms-released-fails/10557/23)
This workaround references the
[Andrey's comment](https://discuss.openedx.org/t/updating-tutor-lilac-to-palm-now-that-palms-released-fails/10557/23)

Migration steps
---------------

This guide delineates the necessary steps for a seamless migration to Quince using Drydock, ensuring a smooth transition with careful consideration of potential challenges.
This guide delineates the necessary steps for a seamless migration to Quince using Drydock, ensuring
a smooth transition with careful consideration of potential challenges.

### Regarding initialization jobs

Expand All @@ -189,20 +215,25 @@ The generated files are meant to be used by ArgoCD for deployment.
Previously you would need to write the manifest files for the initialization jobs
manually if you wanted to use a tool like ArgoCD.

1. For Quince, it is necessary to update the version of [Drydock](https://github.com/eduNEXT/drydock) to the latest version 17.x.x in the requirements.txt file of your environment, including:
1. For Quince, it is necessary to update the version of
[Drydock](https://github.com/eduNEXT/drydock) to the latest version 17.x.x in the
requirements.txt file of your environment, including:

``` bash
git+https://github.com/edunext/drydock@v17.x.x#egg=drydock==17.x.x
```

2. In the `config.yml` file, include variables that activate the initialization jobs and post-migration jobs:
2. In the `config.yml` file, include variables that activate the initialization jobs and
post-migration jobs:

``` yaml
DRYDOCK_INIT_JOBS: True
DRYDOCK_MIGRATE_FROM: <MAJOR_OF_TUTOR_VERSION>
```

Set `DRYDOCK_MIGRATE_FROM` to the integer value mapping the origin release, for instance, `13`(Maple) or `14`(Nutmeg). Please refer to the Drydock configuration reference for a full description.
Set `DRYDOCK_MIGRATE_FROM` to the integer value mapping the origin release, for instance,
`13`(Maple) or `14`(Nutmeg). Please refer to the Drydock configuration reference for a full
description.

3. Re-generate the configuration by running:

Expand All @@ -220,7 +251,7 @@ manually if you wanted to use a tool like ArgoCD.
DRYDOCK_INIT_JOBS: False
```

remove `DRYDOCK_MIGRATE_FROM` from you config file and run:
remove `DRYDOCK_MIGRATE_FROM` from you config file and run:

```bash
tutor config save
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ lint.select = [
"UP",
]

[tool.rumdl]
# Global configuration options
line-length = 100
respect-gitignore = true

[tool.rumdl.MD004]
style = "dash" # Unordered list style (asterisk, plus, dash, consistent)

[tool.rumdl.MD007]
indent = 4 # Unordered list indentation

[tool.rumdl.MD013]
line-length = 100 # Line length
code-blocks = false # Exclude code blocks from line length check
tables = false # Exclude tables from line length check
headings = false
reflow = true

[tool.scriv]
version = "literal: pyproject.toml: project.version"
categories = "Added, Changed, Fixed, Removed"
Expand All @@ -65,6 +83,7 @@ build-backend = "uv_build"
[dependency-groups]
dev = [
"ruff>=0.14.6",
"rumdl>=0.2.78",
"scriv>=1.7.0",
"ty>=0.0.1a29",
]
Expand Down
Loading
Loading