From 6b648ea9e1491bf057c9d3c41a46d27fbb950869 Mon Sep 17 00:00:00 2001 From: Martin Chodur Date: Mon, 8 Jun 2020 11:00:56 +0200 Subject: [PATCH] fix swift: CR minor fixes Signed-off-by: Martin Chodur --- CHANGELOG.md | 2 +- pkg/objstore/swift/swift.go | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6d3bc3354e..a0e5d069a8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel - [#2739](https://github.com/thanos-io/thanos/pull/2739) Changed `bucket tool bucket verify` `--id-whitelist` flag to `--id`. - [#2748](https://github.com/thanos-io/thanos/pull/2748) Upgrade Prometheus to [@66dfb951c4ca](https://github.com/prometheus/prometheus/commit/66dfb951c4ca2c1dd3f266172a48a925403b13a5) which is after v2.19.0. - PromQL now allow us to executed concurrent selects. -- [#TBA](https://github.com/thanos-io/thanos/pull/TBA) Swift: Switched to a new library [ncw/swift]() providing large objects support. +- [#2732](https://github.com/thanos-io/thanos/pull/2732) Swift: Switched to a new library [ncw/swift]() providing large objects support. By default, segments will be uploaded to the same container directory `segments/` if the file is bigger than `1GB`. To change the defaults see [the docs](./docs/storage.md#openstack-swift). diff --git a/pkg/objstore/swift/swift.go b/pkg/objstore/swift/swift.go index 22489bc3056..0da70e7769b 100644 --- a/pkg/objstore/swift/swift.go +++ b/pkg/objstore/swift/swift.go @@ -182,18 +182,18 @@ func NewContainerFromConfig(logger log.Logger, sc *Config, createContainer bool) if sc.SegmentContainerName == "" { sc.SegmentContainerName = sc.ContainerName } else if _, err := ensureContainer(connection, sc.SegmentContainerName, createContainer); err != nil { - return nil, err - } + return nil, err } +} - container := Container{ - logger: logger, - name: sc.ContainerName, - connection: connection, - chunkSize: sc.ChunkSize, - segmentsContainer: sc.SegmentContainerName, - } - return &container, nil +container := Container{ +logger: logger, +name: sc.ContainerName, +connection: connection, +chunkSize: sc.ChunkSize, +segmentsContainer: sc.SegmentContainerName, +} +return &container, nil } // Name returns the container name for swift. @@ -264,10 +264,10 @@ func (c *Container) Attributes(ctx context.Context, name string) (objstore.Objec // Exists checks if the given object exists. func (c *Container) Exists(ctx context.Context, name string) (bool, error) { _, _, err := c.connection.Object(c.name, name) + if c.IsObjNotFoundErr(err) { + err = nil + } if err != nil { - if c.IsObjNotFoundErr(err) { - err = nil - } return false, errors.Wrap(err, "swift check if file exists") } return true, nil