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

ConnectionError when running init task #85

Closed
OAburub opened this issue Oct 13, 2024 · 1 comment
Closed

ConnectionError when running init task #85

OAburub opened this issue Oct 13, 2024 · 1 comment

Comments

@OAburub
Copy link

OAburub commented Oct 13, 2024

2024-10-13 11:56:41,889 INFO 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/discovery/course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py:134 - Command is not using threads to write data.
2024-10-13 11:56:41,903 INFO 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/discovery/course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py:178 - Executing Loader CoursesApiDataLoader, url: https://OUR_LMS/api/courses/v1/
2024-10-13 11:56:42,058 INFO 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/venv/lib/python3.12/site-packages/backoff/_common.py:105 - Backing off run_loader(...) for 0.7s (requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://lms:8000/oauth2/access_token)
2024-10-13 11:56:42,809 INFO 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/venv/lib/python3.12/site-packages/backoff/_common.py:105 - Backing off run_loader(...) for 43.0s (requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://lms:8000/oauth2/access_token)
2024-10-13 11:57:25,824 ERROR 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/venv/lib/python3.12/site-packages/backoff/_common.py:120 - Giving up run_loader(...) after 3 tries (requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://lms:8000/oauth2/access_token)
2024-10-13 11:57:25,824 ERROR 56 [course_discovery.apps.course_metadata.management.commands.refresh_course_metadata] /openedx/discovery/course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py:40 - CoursesApiDataLoader failed!
Traceback (most recent call last):
  File "/openedx/discovery/course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py", line 37, in execute_loader
    run_loader()
  File "/openedx/venv/lib/python3.12/site-packages/backoff/_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/discovery/course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py", line 34, in run_loader
    return loader_class(*loader_args).ingest()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/discovery/course_discovery/apps/course_metadata/data_loaders/api.py", line 50, in __init__
    super().__init__(partner, api_url, max_workers, is_threadsafe, enable_api)
  File "/openedx/discovery/course_discovery/apps/course_metadata/data_loaders/__init__.py", line 36, in __init__
    self.username = self.get_username_from_client(self.api_client)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/discovery/course_discovery/apps/course_metadata/data_loaders/__init__.py", line 46, in get_username_from_client
    token = client.get_jwt_access_token()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.12/site-packages/edx_rest_api_client/client.py", line 283, in get_jwt_access_token
    self._ensure_authentication()
  File "/openedx/venv/lib/python3.12/site-packages/edx_rest_api_client/client.py", line 262, in _ensure_authentication
    oauth_access_token_response = get_and_cache_oauth_access_token(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.12/site-packages/edx_rest_api_client/client.py", line 177, in get_and_cache_oauth_access_token
    oauth_access_token_response = get_oauth_access_token(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.12/site-packages/edx_rest_api_client/client.py", line 127, in get_oauth_access_token
    response.raise_for_status()  # Raise an exception for bad status codes.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.12/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://lms:8000/oauth2/access_token
CommandError: One or more of the data loaders above failed.
Error: Command failed with status 1: docker compose -f /home/x/.local/share/tutor/env/local/docker-compose.yml -f /home/x/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /home/x/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm discovery-job sh -e -c make migrate

# Development partners
./manage.py create_or_update_partner  \
  --site-id 1 \
  --site-domain discovery.OUR_LMS:8381 \
  --code dev \
  --name "Open edX - development" \
  --lms-url="http://lms:8000" \
  --studio-url="http://cms:8000" \
  --courses-api-url "http://OUR_LMS:8000/api/courses/v1/" \
  --organizations-api-url "http://OUR_LMS:8000/api/organizations/v1/"

# Production partner
./manage.py create_or_update_partner  \
  --site-id 2 \
  --site-domain discovery.OUR_LMS \
  --code openedx \
  --name "Open edX" \
  --lms-url="http://lms:8000" \
  --studio-url="http://cms:8000" \
  --courses-api-url "https://OUR_LMS/api/courses/v1/" \
  --organizations-api-url "https://OUR_LMS/api/organizations/v1/"

./manage.py refresh_course_metadata --partner_code=$DEFAULT_PARTNER_CODE
./manage.py update_index --disable-change-limit

To fix this, change "http://lms:8000" into "http://{{ LMS_HOST }}:8000" and "http://cms:8000" into "http://{{CMS_HOST}}:8000"

@OAburub
Copy link
Author

OAburub commented Oct 16, 2024

as per the conversation in #86, this issue is not a result of a problem from discovery, rather a problem from other services not being initialized properly.

@OAburub OAburub closed this as completed Oct 16, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Tutor project management Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant