Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix swift: fixed missing Content-Type headers issue #2665

Merged
merged 5 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ We use *breaking* word for marking changes that are not backward compatible (rel

## Unreleased

### Fixed

* [#2665](https://github.com/thanos-io/thanos/pull/2665) Swift: fix issue with missing Content-Type HTTP headers.

### Changed

## [v0.14.0](https://github.com/thanos-io/thanos/releases) - IN PROGRESS

### Fixed
Expand Down
14 changes: 11 additions & 3 deletions pkg/objstore/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Container) Iter(ctx context.Context, dir string, f func(string) error)
dir = strings.TrimSuffix(dir, DirDelim) + DirDelim
}

options := &objects.ListOpts{Full: false, Prefix: dir, Delimiter: DirDelim}
options := &objects.ListOpts{Full: true, Prefix: dir, Delimiter: DirDelim}
return objects.List(c.client, c.name, options).EachPage(func(page pagination.Page) (bool, error) {
objectNames, err := objects.ExtractNames(page)
if err != nil {
Expand All @@ -120,9 +120,17 @@ func (c *Container) Get(ctx context.Context, name string) (io.ReadCloser, error)

// GetRange returns a new range reader for the given object name and range.
func (c *Container) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) {
lowerLimit := ""
upperLimit := ""
if off >= 0 {
lowerLimit = fmt.Sprintf("%d", off)
}
if length > 0 {
upperLimit = fmt.Sprintf("%d", off+length-1)
}
options := objects.DownloadOpts{
Newest: true,
Range: fmt.Sprintf("bytes=%d-%d", off, off+length-1),
Range: fmt.Sprintf("bytes=%s-%s", lowerLimit, upperLimit),
}
response := objects.Download(c.client, c.name, name, options)
return response.Body, response.Err
Expand Down Expand Up @@ -251,7 +259,7 @@ func configFromEnv() SwiftConfig {
ProjectName: os.Getenv("OS_PROJECT_NAME"),
UserDomainID: os.Getenv("OS_USER_DOMAIN_ID"),
UserDomainName: os.Getenv("OS_USER_DOMAIN_NAME"),
ProjectDomainID: os.Getenv("OS_PROJET_DOMAIN_ID"),
ProjectDomainID: os.Getenv("OS_PROJECT_DOMAIN_ID"),
ProjectDomainName: os.Getenv("OS_PROJECT_DOMAIN_NAME"),
}

Expand Down