Skip to content

Conversation

@gotjosh
Copy link
Contributor

@gotjosh gotjosh commented Apr 6, 2020

What this PR does:

Previously, we had samples and metadata using the ring on their own to
send data to the ingesters. Since the WriteRequest supports metadata
alongside samples there's no reason to split the calls so we unify them. There's an
additional tiny refactor to inline the metadata validation as it is just
a single function call.

Signed-off-by: gotjosh [email protected]

Which issue(s) this PR fixes:
A follow up from #2336

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Previously, we had samples and metadata using the ring on their own to
send data to the ingesters. Since the `WriteRequest` supports metadata
alongside samples there's no reason to split the calls so we unify them. There's an
additional tiny refactor to inline the metadata validation as it is just
a single function call.

Signed-off-by: gotjosh <[email protected]>
@gotjosh gotjosh force-pushed the unify-metadata-samples branch from 53c6865 to d48e918 Compare April 6, 2020 16:48
}

if len(req.Metadata) > 0 {
// Given requests can only contain either metadata or samples, no-op if there is metadata for now.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, this is "no longer true" from an implementation perspective. The remote write protocol only sends metadata or samples (for now) but IMO that comment/responsibility belongs in the distributor. The ingester should operate under no assumption that you'd receive one or the other if we can (e.g. no increase of complexity).

Obviously, this is my own personal opinion with what I know about the system, but others feel free to suggest any alternatives.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to handle samples and metadata in the same push, then I would suggest that we return errors for them separately. As it is now, errors reported by ingesters will be counted for both samples and metadata (provided both were present in the request).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry Peter, I'm not following your comment. With this change, we're no longer making assumptions that a WriteRequest can come with one or the other.

The error handling in send is purely for metrics reporting. In the ingesters, we simply log when we receive metadata, so erroring out on that is not an option at the moment.

The comment I originally left in the distributors is an operational concern, but for the code itself, it wouldn't make a difference - that is indented.

@gotjosh
Copy link
Contributor Author

gotjosh commented Apr 6, 2020

Should I be updating any tests? I didn't see anything that felt worth updating but feel free to suggest otherwise.

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Thanks @gotjosh for this refactoring! The design LGTM. I left a couple of comments.

Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Code looks good, but there are some mixed signals about samples/metadata being mixed. On one hand, code looks like it's processing both at the same time, but on the other hand, it relies on the fact that they are sent separately for error processing.

}

if len(req.Metadata) > 0 {
// Given requests can only contain either metadata or samples, no-op if there is metadata for now.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to handle samples and metadata in the same push, then I would suggest that we return errors for them separately. As it is now, errors reported by ingesters will be counted for both samples and metadata (provided both were present in the request).

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Thanks @gotjosh for addressing my feedback. LGTM!

@pracucci pracucci merged commit 20d725a into cortexproject:master Apr 8, 2020
@pull-request-size pull-request-size bot added size/L and removed size/M labels Apr 8, 2020
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.

3 participants