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

receiver/compact/store/sidecar: Added a provision in the bucket config to add a prefix #3289

Closed
wants to merge 18 commits into from

Conversation

dsayan154
Copy link

@dsayan154 dsayan154 commented Oct 7, 2020

This PR is to address issue #1318 .

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  • Added prefix to BucketConfig struct in factory.go
  • Wrote wrapper function prefixedBucket wrapper struct and related wrapper functions in objstore.go

Verification

Not yet verified, this is for the maintainers to review, if this is the right approach to address this issue. I am struggling to add unit tests for this, so any hints would be helpful. But, I can test it manually if the overall feedback on this approach is positive.

Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
…dated the documentation for it. To address [issue 1318](thanos-io#1318)

Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
@dsayan154 dsayan154 changed the title objectstore: Added a provision in the bucket config to add a prefix [receiver][compact][store][sidecar]: Added a provision in the bucket config to add a prefix Oct 7, 2020
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments!

Amazing and clean work BTW ❤️

docs/storage.md Outdated Show resolved Hide resolved
pkg/objstore/objstore.go Show resolved Hide resolved
pkg/objstore/objstore.go Outdated Show resolved Hide resolved
Addressing a suggestion to modify the comment.

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks ❤️

I have a couple of suggestions.

  • How about embedding Bucket into new struct?
  • Could we maybe add some end-to-end tests?
  • We need a changelog entry.

pkg/objstore/objstore.go Show resolved Hide resolved
@kakkoyun kakkoyun changed the title [receiver][compact][store][sidecar]: Added a provision in the bucket config to add a prefix receiver/compact/store/sidecar: Added a provision in the bucket config to add a prefix Oct 14, 2020
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just minor comments to address, then we can merge! (:

Thanks!

docs/storage.md Outdated Show resolved Hide resolved
pkg/objstore/client/factory.go Outdated Show resolved Hide resolved
pkg/objstore/objstore.go Show resolved Hide resolved
…gelog entry

Signed-off-by: dsayan154 <dsayan154@gmail.com>
pkg/objstore/client/factory.go Outdated Show resolved Hide resolved
}

func (pbkt *prefixedBucket) Delete(ctx context.Context, name string) (err error) {
pname := filepath.Join(pbkt.prefix, name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should juse path.Join() and not filepath.Join(). The former guarantees paths are joined with /, which is what object stores expect.

Same comment applies across the change set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aso the .Join() is used quite a lot. You could add an help prefixedBucket.nameWithPrefix(name string)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, might be good to add a helper function but I don't know how will it reduce the redundancy of the code, as I'll have to call the helper function same number of times as I have called filepath.Join().
But I'll update the code with your suggestion. I think it will add consistency to the code.

return pbkt.bkt.Close()
}

func (pbkt *prefixedBucket) Iter(ctx context.Context, dir string, f func(string) error) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be possible to add a unit test on this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pracucci ,
I have added few unit tests for the Iter(), can you please review this? the tests are running fine locally.

pkg/objstore/objstore.go Show resolved Hide resolved
@dsayan154
Copy link
Author

Sorry for such a late response on this PR, I was busy with office deliverables. I hope to address these comments by next weekend.

dsayan154 and others added 2 commits December 6, 2020 20:17
Co-authored-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
Signed-off-by: dsayan154 <dsayan154@gmail.com>
@stale
Copy link

stale bot commented Feb 13, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Feb 13, 2021
@kakkoyun kakkoyun removed the stale label Feb 13, 2021
Base automatically changed from master to main February 26, 2021 16:30
@ashuec90
Copy link

ashuec90 commented Mar 16, 2021

Getting below error while building thanos docker image after taking this PR through make docker

>> building Thanos binary in /go/bin
 >   thanos
# github.com/thanos-io/thanos/pkg/objstore
pkg/objstore/objstore.go:488:10: cannot use &prefixedBucket literal (type *prefixedBucket) as type Bucket in return argument:
	*prefixedBucket does not implement Bucket (wrong type for Iter method)
		have Iter(context.Context, string, func(string) error) error
		want Iter(context.Context, string, func(string) error, ...IterOption) error
pkg/objstore/objstore.go:493:2: cannot use pbkt (type *prefixedBucket) as type Bucket in return argument:
	*prefixedBucket does not implement Bucket (wrong type for Iter method)
		have Iter(context.Context, string, func(string) error) error
		want Iter(context.Context, string, func(string) error, ...IterOption) error
!! command failed: build -o /go/bin/thanos -ldflags -X github.com/prometheus/common/version.Version=0.20.0-dev -X github.com/prometheus/common/version.Revision=82ea6ff33a65a109c6d8b70ef3687479a9f04325 -X github.com/prometheus/common/version.Branch=added_prefix -X github.com/prometheus/common/version.BuildUser=root@237fa8b74dcf -X github.com/prometheus/common/version.BuildDate=20210316-08:19:18  -extldflags '-static' -a -tags netgo github.com/thanos-io/thanos/cmd/thanos: exit status 2
make: *** [Makefile:130: build] Error 1

@sfc-gh-jburns
Copy link

What would it take to get this done?

@@ -112,6 +114,16 @@ Highlights:
- [#3114](https://github.com/thanos-io/thanos/pull/3114) Query Frontend: Added support for Memacached cache.
- **breaking** Renamed flag `log_queries_longer_than` to `log-queries-longer-than`.
- [#3166](https://github.com/thanos-io/thanos/pull/3166) UIs: Added UI for passing a `storeMatch[]` parameter to queries.
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to clean these

@stale
Copy link

stale bot commented Jun 2, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants