Skip to content

Commit 1e05df7

Browse files
Merge pull request openshift#6707 from shiftstack/204_nocontent_objects
OCPBUGS-4941: OpenStack: Force JSON content-type in Swift object listing
2 parents 2473a10 + 3b6dbeb commit 1e05df7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/destroy/openstack/openstack.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,20 @@ func deleteContainers(opts *clientconfig.ClientOpts, filter Filter, logger logru
11061106
if metadata[titlekey] == val {
11071107
logger.Debugf("Bulk deleting container %q objects", container)
11081108
pager := objects.List(conn, container, &objects.ListOpts{
1109+
// Listing with `Full == true` so that Gophercloud sets the `Accept`
1110+
// header to `application/json`. If `Full` is not true, Gophercloud
1111+
// sets `Accept: text/plain`, to which some objectstorage instances may
1112+
// respond with an HTTP status code of 204 in case there are no
1113+
// occurrences to list. Some, but not all, of these objectstorage
1114+
// instances omit the `content-type` header from their 204 responses.
1115+
// While being perfectly correct, this case is mishandled by the
1116+
// currently vendored version of Gophercloud. On the other hand, the
1117+
// JSON response always HTTP status code 200, a JSON content (possibly
1118+
// `{}`), and most importantly a `content-type` header.
1119+
//
1120+
// This option can be reverted to `false` once Gophercloud learns to
1121+
// correctly handle empty 204 responses.
1122+
Full: true,
11091123
Limit: 50,
11101124
})
11111125
err = pager.EachPage(func(page pagination.Page) (bool, error) {

0 commit comments

Comments
 (0)