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

Initial structure and block shipper #1

Merged
merged 14 commits into from Nov 2, 2017
Merged

Initial structure and block shipper #1

merged 14 commits into from Nov 2, 2017

Conversation

fabxc
Copy link
Collaborator

@fabxc fabxc commented Nov 2, 2017

@Bplotka This is mostly setup around the basic structure and some implementation to show what it would look like in practice. The block shipper is already working though.

A few design decisions/proposals:

  • use Go dep, don't checkin vendor/
  • go-kit/log for logging, structured logging only
  • prometheus/client_golang for metrics :)
  • kingpin for flags
  • cmd/ and pkg/ folder, no other Go packages at the top level
  • use Prometheus's promu tool for builds (not magic, just has a lot of crossbuild, container builds, versioning concerns solved in a simple way)
  • A simple custom testutil package for abbreviated checks

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.

This is great! (: Just one wrong copy-pasta you had + some questions


format:
@echo ">> formatting code"
@go fmt ./...
Copy link
Member

Choose a reason for hiding this comment

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

maybe goimports instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Literally cannot get it to run (: But I guess leaving gofmt here is fine since missing or extra imports will cause things to not compile anyway, which CI will catch.

Copy link
Member

Choose a reason for hiding this comment

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

yeah I was thinking about goimports just in terms of sorting imports (:


// registerStore registers a store command.
func registerStore(app *kingpin.Application, name string) runFunc {
cmd := app.Command(name, "sidecar for Prometheus server")
Copy link
Member

Choose a reason for hiding this comment

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

incorrect command description (copy-pasta from sidecar)

return false, err
}
// The first object found with the given filter indicates that the directory exists.
// XXX(fabxc): do a full check whether the files add up as well?
Copy link
Member

Choose a reason for hiding this comment

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

what do you mean add up? add up to what (:

Copy link
Member

Choose a reason for hiding this comment

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

You mean if are files are there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, basically just a bit more detailed check whether things are in sync.

Copy link
Member

Choose a reason for hiding this comment

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

Well I think we can skip that now, it will only increase GCS operations but no one actually can write to this after upload now. Only when upload + dir delete was broken. Let's see how often that happens

level.Error(r.logger).Log("msg", "upload failed; remove partial data", "dir", dir, "err", err)

// We don't want to leave partially uploaded directories behind. Cleanup everything related to it
// and use a uncanceled context.
Copy link
Member

Choose a reason for hiding this comment

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

👍


w := r.bucket.Object(target).NewWriter(ctx)
_, err = io.Copy(w, f)

Copy link
Member

Choose a reason for hiding this comment

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

kill newline? from the first glance err looks unchecked (:

return s.remote.Upload(ctx, dir)
}

// ReadDir returns the filenames in the given directory in sorted order.
Copy link
Member

Choose a reason for hiding this comment

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

s/ReadDir/readDir

case <-tick.C:
names, err := readDir(s.dir)
if err != nil {
continue
Copy link
Member

Choose a reason for hiding this comment

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

Not even log here? We are losing error here

func (s *Shipper) sync(ctx context.Context, dir string) error {
ok, err := s.remote.Exists(ctx, dir)
if err != nil {
return errors.Wrap(err, "check exists")
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we just skip it? This will be spamming with log a lot on every case after some time, doesn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd only expect an error here if we failed to verify whether it is there or not. If it doesn't exist, err is still nil.

Copy link
Member

Choose a reason for hiding this comment

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

ah, my bad, did not see ok, err := ):

@@ -0,0 +1,67 @@
// The MIT License (MIT)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

He, fun story. So I actually rolled out those libs to a significant fraction of Prometheus code bases. We had a longer upstream discussion recently and concluded that the diffs it shows are rarely readable, which removes one expected benefit. Additionally, the rich equality checks were often behaving in unexpected ways. This caused us to work around it in non-obvious ways.

Overall, all we wanted was short versions for "no error occurred" and reflect.DeepEqual. Those few simple functions give us just that and are easy to use. Thus we decided to migrate Prometheus upstream to those.

Copy link
Member

@bwplotka bwplotka Nov 2, 2017

Choose a reason for hiding this comment

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

Additionally, the rich equality checks were often behaving in unexpected ways.

We did not notice these.. I guess only for some edge cases, right?
OK, so let's stick to these, I will try to limit usage to only these four ^^

@@ -0,0 +1,67 @@
// The MIT License (MIT)
Copy link
Member

@bwplotka bwplotka Nov 2, 2017

Choose a reason for hiding this comment

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

Additionally, the rich equality checks were often behaving in unexpected ways.

We did not notice these.. I guess only for some edge cases, right?
OK, so let's stick to these, I will try to limit usage to only these four ^^

@fabxc fabxc merged commit 0710eb7 into master Nov 2, 2017
@fabxc fabxc deleted the fabxc-init branch November 2, 2017 10:45
@Jerryhax Jerryhax mentioned this pull request Jul 25, 2018
@Jerryhax Jerryhax mentioned this pull request Aug 6, 2018
povilasv added a commit to povilasv/thanos that referenced this pull request Aug 28, 2018
bwplotka pushed a commit that referenced this pull request Mar 31, 2019
paulfantom pushed a commit to paulfantom/thanos that referenced this pull request Jul 19, 2019
add OWNERS file and basic Dockerfile
codesome pushed a commit to codesome/thanos that referenced this pull request May 26, 2020
 Delete mmapped chunks after creating block from head
GiedriusS added a commit that referenced this pull request Jul 21, 2022
fpetkovski pushed a commit that referenced this pull request May 4, 2023
…-func

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

Successfully merging this pull request may close these issues.

None yet

2 participants