E-Commerce Course Admin page threw datatable/ajax errors

I’ve installed the latest Tutor and enabled the discovery/e-commerce plugins. I successfully created a new course in Studio, but I’ve been struggling to specify the price for it.

I followed the instructions on " 6.4.2. Create Course Seats" to create a course but the courses page always pops up an error message about “DataTables warning: table id=courseTable - Ajax error. For more information about this error, please see http://datatables.net/tn/7”. Inspecting the network requests in the browser’s devtools revealed that it was the API call to “/api/v2/courses?format=datatables…” that was returning 502 Bad Gateway error. The same API request without the query parameters would work, and therefore I suspect that it’s the data table configuration that’s causing the error. Any ideas what’s going on? The “Coupons”/“Enterprise Coupons” tabs had the same error (even without any entries created), while “Program Offers”/“Enterprise Program Offers” were fine. Could it be that the Tutor plugin packaged an incompatible UI version?

An additional question is: how exactly should I configure the course price? I have found three possible options but I wonder which one to use:

  1. Create the course in e-commerce course admin for every corresponding course in Studio.
  2. Add a course mode in LMS admin.
  3. Use the Instructor Dashboard per the instructions from section 11.3.1.4 on this page (https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/named-release-cypress/running_course/manage_course_fees.html#configure-the-course). However there is no “E-Commerce” tab that was shown in the screenshot. Perhaps this tab has been removed in the current release?

Inspecting the network requests in the browser’s devtools revealed that it was the API call to “/api/v2/courses?format=datatables…” that was returning 502 Bad Gateway error.

502 error means that the service is temporarily unavailable. You did not specify what is the corresponding service: is it ecommerce, discovery, LMS? What is the host name to which the request is sent? What are the logs coming from this service?

It was the ecommerce API, and the service was actually available since I could enter this “https://ecommerce.<LMS.ROOT>/api/v2/courses/” in the browser and get a valid response.

In addition, “api/v2/coupons/categories/” and “/api/v2/catalogs/course_catalogs/” worked, but anything that had the query parameters “/?format=datatables&draw=1&…” would fail.

The ecommerce and discovery logs didn’t have any error messages.

Is there any command that I can run to reset all the ecommerce data?

I found quite a few entries like this in the ecommerce log:

invalid request block size: 5104 (max 4096)...skip
ecommerce_1         | [uwsgi-http key: ecommerce.<lms_root> client_addr: 172.18.0.15 client_port: 21151] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]

Then nginx reported that “upstream prematurely closed connection while reading response header from upstream”.

It seems that I need to increase the buffer size for uwsgi, according to this: https://stackoverflow.com/questions/15878176/uwsgi-invalid-request-block-size. But where can I specify this setting?

I tried to added the buffer-size setting to the uwsgi command in Dockerfile like this:

CMD uwsgi \
    --static-map /static=/openedx/staticfiles/ \
    --static-map /media=/openedx/media/ \
    --http 0.0.0.0:8000 \
    --thunder-lock \
    --single-interpreter \
    --enable-threads \
    --processes=${UWSGI_WORKERS:-2} \
    **--buffer-size=${UWSGI_BUFFER_SIZE:8196} \**
    --wsgi-file ${SERVICE_VARIANT}/wsgi.py

but the Dockerfile at “env/build/openedx/Dockerfile” always gets overwritten when running the “tutor config save” command. How do I make this setting persistent, @regis ?

Hi @hyx! Thanks for the thorough investigation and detailed report. This is most definitely a bug in tutor-ecommerce. As you discovered, the uwsgi buffer size should be increased. However, to do that, you should not modify the rendered templates from the $(tutor config printroot)/env/ folder, but the actual templates from the tutor-ecommerce plugin: https://github.com/overhangio/tutor-ecommerce/blob/master/tutorecommerce/templates/ecommerce/build/ecommerce/Dockerfile

Would you like to open a pull request on the tutor-ecommerce repo to push your fix upstream? You only need to add a --buffer-size=8192 option to the uwsgi command. There is no need to make this an environment parameter.

If for some reason you do not have the time to open a pull request, please create a Github issue in the tutor-ecommerce repo describe the problem and your proposed solution (and link to this conversation): https://github.com/overhangio/tutor-ecommerce/issues/new

Thanks for the prompt response, @regis. I filed an issue for this here: https://github.com/overhangio/tutor-ecommerce/issues/14. Unfortunately I couldn’t submit the PR, since I don’t have the dev setup to test the fix, and also there are three Dockerfiles and I’m not sure which one(s) to fix:
$(tutor config printroot)/env/build/openedx/Dockerfile
$(tutor config printroot)/env/plugins/ecommerce/build/ecommerce/Dockerfile
$(tutor config printroot)/env/plugins/discovery/build/discovery/Dockerfile

1 Like

This is resolved in v11.0.1.

Nice! But how do I upgrade the ecommerce plugin? I believe I have the new version installed:
$ cat /home/ubuntu/.local/lib/python3.8/site-packages/tutorecommerce/about.py
version = “11.0.1”

However, the list command still shows “ecommerce==11.0.0”:

$ tutor plugins list
discovery==11.0.1
ecommerce==11.0.0
license==11.0.0 (disabled)
minio==11.0.0 (disabled)
notes==11.0.0
xqueue==11.0.1 (disabled)

If you have downloaded the tutor binary instead of installing from pip, then tutor will not load your up-to-date plugin.

I initially downloaded the binary, but today I ran these commands:

$ git clone https://github.com/overhangio/tutor
$ cd tutor
$ sudo apt install python3 python3-pip libyaml-dev
$ python3 -m pip install -e .
$ python3 -m pip install tutor-ecommerce

I uninstalled tutor-openedx and then reinstalled it. Now I get the new version of ecommerce and the 502 error is gone! Thanks for your help, @regis!