Files
horizon/openstack_dashboard/dashboards/project/containers/views.py
Tobias Urdin ceb677d489 Add SWIFT_PANEL_FULL_LISTING config option
The swiftclient supports setting full_listing to
True which will ignore the limit/marker parameters
and internally do a while loop to retrieve all the
containers or objects.

We pass in full_listing=True to both get_container()
and get_account() and in both cases that is bad, one
reason it's bad is because it ignores any limit sent.

Now that in itself is not bad since we dont use those
parameters at all, in fact we rely on client side
pagination in Angular using st-pagination for the
hz-dynamic-table that lists all containers and objects.

The bad part here is that with full_listing if we have
a customer with 100k containers or 100k objects the
Horizon REST API will try to gather all those resources
and return it in the API response to the Angular client
side code.

This makes it easy for a end-user to starve Horizon of
resources, create a container, upload 1M objects, go
to Horizon and try to list the container and Horizon
will after some refreshes hang because it's processing
the requests for a long time or because it runs out of
memory and crashes.

This adds the configuration option SWIFT_PANEL_FULL_LISTING
that defaults to True keeping the current behaviour but can
be set to False by operators to prevent this issue until
the Swift panel has been migrated to use correct pagination.

Change-Id: Id41200aaeec3df4aff1ace887a42352728fc4419
Signed-off-by: Tobias Urdin <tobias.urdin@binero.com>
2025-10-09 13:04:54 +00:00

33 lines
1.2 KiB
Python

# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf import settings
from django.views import generic
class NgIndexView(generic.TemplateView):
"""View for managing Swift containers."""
template_name = 'project/containers/ngindex.html'
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['API_RESULT_LIMIT'] = settings.API_RESULT_LIMIT
context['SWIFT_PANEL_FULL_LISTING'] = settings.SWIFT_PANEL_FULL_LISTING
return context