Skip to content

Do not list buckets on S3 when generating the OpenAPI schema

Erwan Rouchet requested to merge kick-the-bucket into master

I noticed a while ago that some tests on my local setup appeared to be much slower than on other devs' setups. I got tired of that today and threw runprofileserver and KCacheGrind at the problem, which pointed me to botocore retrying a request for 10 seconds every time the API schema gets generated.

Spectacular calls get_queryset on each endpoint to get the model used by a view, even if in some cases it does not need it at all. ListBuckets was calling S3's ListBuckets API directly in this method, so the API schema generation could cause unnecessary calls to S3. When MinIO is not running locally, Botocore gets a ConnectionError and retries multiple times. Spectacular just ignores all exceptions from get_queryset, so this goes unnoticed.

This MR shaves off 1 minute from local tests when MinIO is not running (183→121 seconds), and 2 minutes from CI tests (21487).

Merge request reports

Loading