Skip to content

fix: Bug 404 for state RETIRING_FORUMS user retirement#33024

Merged
AhtishamShahid merged 2 commits intoopenedx:masterfrom
DmytroAlipov:fix-user-retirement-master
Sep 18, 2023
Merged

fix: Bug 404 for state RETIRING_FORUMS user retirement#33024
AhtishamShahid merged 2 commits intoopenedx:masterfrom
DmytroAlipov:fix-user-retirement-master

Conversation

@DmytroAlipov
Copy link
Contributor

Description

We ran into a problem when running the retire_users.sh command. The user must first delete their account from the platform. After that, the /edx/app/retirement_service/retire_users.sh command is launched. However, for one step, an error appears

sudo -sHu edx_retirement_worker
edx_retirement_worker@lms-palm:/home/company$ cd
edx_retirement_worker@lms-palm:~$ /edx/app/retirement_service/retire_users.sh
=== [Tue Aug  1 07:19:04 UTC 2023] /edx/app/retirement_service/retire_users.sh: Started
Writing logs to: /edx/var/log/retirement_service/edx.log
Deleting user: test_user_5...
b'Learner Retirement: Starting learner retirement for test_user_5 using config file /edx/app/retirement_service/config.yml'
b'Learner Retirement: Starting state RETIRING_FORUMS'
ERROR:tubular.edx_api:API Error: 404 Client Error: Not Found for url: https://lms-palm-dev.raccoongang.com/api/discussion/v1/accounts/retire_forum/ with status code: 404
INFO:tubular.edx_api:No information about learner retirement
b'Learner Retirement: State RETIRING_FORUMS completed in 0.36619019508361816 seconds'
b'Learner Retirement: Progressing to state FORUMS_COMPLETE'
b'Learner Retirement: Starting state RETIRING_ENROLLMENTS'
b'Learner Retirement: State RETIRING_ENROLLMENTS completed in 3.4557716846466064 seconds'
b'Learner Retirement: Progressing to state ENROLLMENTS_COMPLETE'
b'Learner Retirement: Starting state RETIRING_LMS_MISC'
b'Learner Retirement: State RETIRING_LMS_MISC completed in 0.11767053604125977 seconds'
b'Learner Retirement: Progressing to state LMS_MISC_COMPLETE'
b'Learner Retirement: Starting state RETIRING_LMS'
b'Learner Retirement: State RETIRING_LMS completed in 0.18668651580810547 seconds'
b'Learner Retirement: Progressing to state LMS_COMPLETE'
b'Learner Retirement: Retirement complete for learner test_user_5'
edx_retirement_worker@lms-palm:~$

At the same time, all user actions for the forum remain, since this retirement stage is not completed.
A problem was detected with the WALL of this endpoint.
URL looks like:
https://lms-palm.com/api/discussion/v1/accounts/retire_forum/
However, this URL is expected on the platform:
https://lms-palm.com/api/discussion/v1/accounts/retire_forum

The URL is created in LmsApi, and the append_slash argument is responsible for adding a slash at the end of the URL. This addition of a slash is carried out for all retirement steps.

After fixing, the entire flow passes without errors:

=== [Wed Aug 16 10:18:31 UTC 2023] /edx/app/retirement_service/retire_users.sh: Started
Writing logs to: /edx/var/log/retirement_service/edx.log
Deleting user: test_user_5...
b'Learner Retirement: Starting learner retirement for test_user_5 using config file /edx/app/retirement_service/config.yml'
b'Learner Retirement: Starting state RETIRING_FORUMS'
b'Learner Retirement: State RETIRING_FORUMS completed in 0.40157532691955566 seconds'
b'Learner Retirement: Progressing to state FORUMS_COMPLETE'
b'Learner Retirement: Starting state RETIRING_ENROLLMENTS'
b'Learner Retirement: State RETIRING_ENROLLMENTS completed in 0.5397000312805176 seconds'
b'Learner Retirement: Progressing to state ENROLLMENTS_COMPLETE'
b'Learner Retirement: Starting state RETIRING_LMS_MISC'
b'Learner Retirement: State RETIRING_LMS_MISC completed in 0.30715203285217285 seconds'
b'Learner Retirement: Progressing to state LMS_MISC_COMPLETE'
b'Learner Retirement: Starting state RETIRING_LMS'
b'Learner Retirement: State RETIRING_LMS completed in 0.16425585746765137 seconds'
b'Learner Retirement: Progressing to state LMS_COMPLETE'
b'Learner Retirement: Retirement complete for learner test_user_5'

User data is deleted in the Discussion:
screen_53

Note:

We do not have all stages of retirement. Only such:

{
    "client_id": "our_client_id",
    "client_secret": "our_client_secret",
    "base_urls": {
        "lms": "https://lms-palm.com/",
        "ecommerce": "https://ecommerce-palm.com/",
        "credentials": "https://credentials-palm.com/",
    },
    "retirement_pipeline": [
        ["RETIRING_FORUMS", "FORUMS_COMPLETE", "LMS", "retirement_retire_forum"],
        ["RETIRING_ENROLLMENTS", "ENROLLMENTS_COMPLETE", "LMS", "retirement_unenroll"],
        ["RETIRING_LMS_MISC", "LMS_MISC_COMPLETE", "LMS", "retirement_lms_retire_misc"],
        ["RETIRING_LMS", "LMS_COMPLETE", "LMS", "retirement_lms_retire"],
    ],
}

Might have similar problems for other stages.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 16, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @DmytroAlipov! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@mphilbrick211
Copy link

Hi @openedx/edx-infinity! Is something you could please review/merge for us? Thanks!

@mphilbrick211
Copy link

Hi @DmytroAlipov! Please see here regarding the 2 checks that have popped up and need to be run. I think rebasing should fix it.

name="discussion_course"
),
path('v1/accounts/retire_forum', RetireUserView.as_view(), name="retire_discussion_user"),
path('v1/accounts/retire_forum/', RetireUserView.as_view(), name="retire_discussion_user"),
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if URI can handle both with and without trailing \

Suggested change
path('v1/accounts/retire_forum/', RetireUserView.as_view(), name="retire_discussion_user"),
re_path(r'^v1/accounts/retire_forum/?$', RetireUserView.as_view(), name="retire_discussion_user"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@DmytroAlipov DmytroAlipov force-pushed the fix-user-retirement-master branch from 749de95 to 2e71a3f Compare September 13, 2023 10:39
@DmytroAlipov DmytroAlipov force-pushed the fix-user-retirement-master branch from 2e71a3f to b86bd98 Compare September 13, 2023 11:22
@mphilbrick211
Copy link

Hi @openedx/edx-infinity! Flagging that this is ready for review. Thanks!

@AhtishamShahid AhtishamShahid merged commit 20efcdc into openedx:master Sep 18, 2023
@openedx-webhooks
Copy link

@DmytroAlipov 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@DmytroAlipov DmytroAlipov deleted the fix-user-retirement-master branch September 18, 2023 09:04
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants