Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion pkg/destroy/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,20 @@ func deleteContainers(opts *clientconfig.ClientOpts, filter Filter, logger logru
logger.Error(err)
return false, nil
}
listOpts := containers.ListOpts{Full: false}
// Listing with `Full == true` so that Gophercloud sets the `Accept`
// header to `application/json`. If `Full` is not true, Gophercloud
// sets `Accept: text/plain`, to which some objectstorage instances may
// respond with an HTTP status code of 204 in case there are no
// occurrencies to list. Some, but not all, of these objectstorage
// instances omit the `content-type` header from their 204 responses.
// While being perfectly correct, this case is mishandled by the
// currently vendored version of Gophercloud. On the other hand, the
// JSON response always HTTP status code 200, a JSON content (possibly
// `{}`), and most importantly a `content-type` header.
//
// This option can be reverted to `false` once Gophercloud learns to
// correctly handle empty 204 responses.
listOpts := containers.ListOpts{Full: true}

allPages, err := containers.List(conn, listOpts).AllPages()
if err != nil {
Expand Down Expand Up @@ -1040,6 +1053,20 @@ func deleteContainers(opts *clientconfig.ClientOpts, filter Filter, logger logru
if metadata[titlekey] == val {
logger.Debugf("Bulk deleting container %q objects", container)
pager := objects.List(conn, container, &objects.ListOpts{
// Listing with `Full == true` so that Gophercloud sets the `Accept`
// header to `application/json`. If `Full` is not true, Gophercloud
// sets `Accept: text/plain`, to which some objectstorage instances may
// respond with an HTTP status code of 204 in case there are no
// occurrences to list. Some, but not all, of these objectstorage
// instances omit the `content-type` header from their 204 responses.
// While being perfectly correct, this case is mishandled by the
// currently vendored version of Gophercloud. On the other hand, the
// JSON response always HTTP status code 200, a JSON content (possibly
// `{}`), and most importantly a `content-type` header.
//
// This option can be reverted to `false` once Gophercloud learns to
// correctly handle empty 204 responses.
Full: true,
Limit: 50,
})
err = pager.EachPage(func(page pagination.Page) (bool, error) {
Expand Down