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

fix: Remove the usage of pkg_resources + add debugging instructions #2375

Merged
merged 2 commits into from
Dec 2, 2024
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
40 changes: 39 additions & 1 deletion dev/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,48 @@ Run with legacy oci-env, check the [Running oci-env integration tests](../../doc

## Tips and Tricks.

**TBD**
---

### Debugging

#### Step 1 - Add the breakpoint

Edit the file you want to debug and add a breakpoint

```python
__import__("ipdb").set_trace()
```

> [!TIP]
> Replace if you are using a different debugger, however the images has only **pdb** and **ipdb** installed.

If you discover other ways of debugging, like connecting dap protocol or vscode debugger, please update this file!

#### Step 2 - Now execute your stack or just the container you are trying to debug.

Example:

```bash
$ export DEV_SOURCE_PATH=galaxy_ng
$ docker compose -f dev/compose/aap.yaml up migrations
# The container will keep running stopped on the breakpoint.
```

#### Step 3 - Attach

```bash
$ docker compose -f dev/compose/aap.yaml attach migrations
ipdb>
```

> [!IMPORTANT]
> To detach from the container DO NOT use <kbd>Ctrl+c</kbd>,
> instead, use <kbd>Ctrl-p Ctrl-q</kbd>

---

**TBD**

### Connecting to Database

### Dumping and restoring the database
Expand Down
17 changes: 13 additions & 4 deletions dev/compose/aap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ x-common-env: &common-env
# $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up
DEV_SOURCE_PATH:

# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
Expand Down Expand Up @@ -127,6 +131,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand Down Expand Up @@ -160,10 +165,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"
Expand All @@ -187,10 +193,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"
Expand All @@ -209,10 +216,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

# Worker needs gpg in order to consume signing tasks;
gpg --list-secret-keys;
Expand All @@ -235,10 +243,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

# Give some time for API to start;
sleep 5;
Expand Down
18 changes: 14 additions & 4 deletions dev/compose/community.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ x-common-env: &common-env
DEV_SOURCE_PATH:


# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
build:
Expand Down Expand Up @@ -148,6 +153,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand Down Expand Up @@ -181,10 +187,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"

Expand All @@ -207,10 +214,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"

Expand All @@ -228,10 +236,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker
"

Expand All @@ -250,10 +259,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

# Give some time for API to start;
sleep 5;
Expand Down
19 changes: 14 additions & 5 deletions dev/compose/insights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ x-common-env: &common-env
# $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up
DEV_SOURCE_PATH:


# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
build:
Expand Down Expand Up @@ -127,6 +131,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand Down Expand Up @@ -160,10 +165,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"

Expand All @@ -186,10 +192,11 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"

Expand All @@ -207,10 +214,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

# Worker needs gpg in order to consume signing tasks;
gpg --list-secret-keys;
Expand All @@ -233,10 +241,11 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;

# Give some time for API to start;
sleep 5;
Expand Down
16 changes: 12 additions & 4 deletions galaxy_ng/app/dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import logging
import os
import re
import sys
from typing import Any

import ldap
import pkg_resources
from ansible_base.lib.dynamic_config.settings_logic import get_dab_settings
from crum import get_current_request
from django.apps import apps
Expand All @@ -27,6 +27,13 @@

from galaxy_ng.app.dynamic_settings import DYNAMIC_SETTINGS_SCHEMA

if sys.version_info < (3, 10):
# Python 3.9 has a rather different interface for `entry_points`.
# Let's use a compatibility version.
from importlib_metadata import EntryPoint
else:
from importlib.metadata import EntryPoint

logger = logging.getLogger(__name__)

DAB_SERVICE_BACKED_REDIRECT = (
Expand Down Expand Up @@ -535,9 +542,10 @@ def configure_ldap(settings: Dynaconf) -> dict[str, Any]:
"AUTH_LDAP_GROUP_TYPE_CLASS",
default="django_auth_ldap.config:GroupOfNamesType"
):
group_type_class = pkg_resources.EntryPoint.parse(
f"__name = {classpath}"
).resolve()
entry_point = EntryPoint(
name=None, group=None, value=classpath
)
group_type_class = entry_point.load()
group_type_params = settings.get(
"AUTH_LDAP_GROUP_TYPE_PARAMS",
default={"name_attr": "cn"}
Expand Down
Loading