Skip to content

Improve reporting of some chunk errors #1789

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

Merged
merged 1 commit into from
Nov 11, 2019
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
2 changes: 1 addition & 1 deletion pkg/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (c *Chunk) Decode(decodeContext *DecodeContext, input []byte) error {
metadataRead := len(input) - r.Len()
// Older versions of Cortex included the initial length word; newer versions do not.
if !(metadataRead == int(metadataLen) || metadataRead == int(metadataLen)+4) {
return ErrMetadataLength
return errors.Wrapf(ErrMetadataLength, "expected %d, got %d", metadataLen, metadataRead)
}

// Next, confirm the chunks matches what we expected. Easiest way to do this
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func parseRangeValueType(rangeValue []byte) (int, error) {
return SeriesRangeValue, nil

default:
return 0, fmt.Errorf("unrecognised range value type. version: '%v'", string(components[3]))
return 0, fmt.Errorf("unrecognised range value type. version: %q", string(components[3]))
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/chunk/schema_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func parseMetricNameRangeValue(rangeValue []byte, value []byte) (model.LabelValu
return model.LabelValue(value), nil

default:
return "", fmt.Errorf("unrecognised metricNameRangeKey version: '%v'", string(components[3]))
return "", fmt.Errorf("unrecognised metricNameRangeKey version: %q", string(components[3]))
}
}

Expand All @@ -160,7 +160,7 @@ func parseSeriesRangeValue(rangeValue []byte, value []byte) (model.Metric, error
return series, nil

default:
return nil, fmt.Errorf("unrecognised seriesRangeKey version: '%v'", string(components[3]))
return nil, fmt.Errorf("unrecognised seriesRangeKey version: %q", string(components[3]))
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (
return

default:
err = fmt.Errorf("unrecognised chunkTimeRangeKey version: '%v'", string(components[3]))
err = fmt.Errorf("unrecognised chunkTimeRangeKey version: %q", string(components[3]))
return
}
}