Skip to content

Commit

Permalink
Added missing nil check for delSeriesIterator and comment
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Rabenhorst <sebastian.rabenhorst@shopify.com>
  • Loading branch information
rabenhorst committed Nov 18, 2022
1 parent b74f556 commit dbb017e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/compact/downsample/downsample.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func (it *AverageChunkIterator) Next() chunkenc.ValueType {
cok, sok := it.cntIt.Next(), it.sumIt.Next()
if cok != sok {
it.err = errors.New("sum and count iterator not aligned")
return chunkenc.ValFloat
return chunkenc.ValNone
}
if cok == chunkenc.ValNone {
return chunkenc.ValNone
Expand Down
12 changes: 10 additions & 2 deletions pkg/compactv2/modifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ type delSeriesIterator struct {
}

func (p *delSeriesIterator) Next() chunkenc.ValueType {
if valueType := p.curr.Next(); p.curr != nil && valueType != chunkenc.ValNone {
if p.curr == nil {
return chunkenc.ValNone
}

if valueType := p.curr.Next(); valueType != chunkenc.ValNone {
return valueType
}

Expand All @@ -254,7 +258,11 @@ func (p *delSeriesIterator) Next() chunkenc.ValueType {
}

func (p *delSeriesIterator) Seek(t int64) chunkenc.ValueType {
if valueType := p.curr.Seek(t); p.curr != nil && valueType != chunkenc.ValNone {
if p.curr == nil {
return chunkenc.ValNone
}

if valueType := p.curr.Seek(t); valueType != chunkenc.ValNone {
return valueType
}
for p.Next() != chunkenc.ValNone {
Expand Down
5 changes: 3 additions & 2 deletions pkg/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *Server) ListenAndServe() error {

flags := &toolkit_web.FlagConfig{
WebListenAddresses: &([]string{s.opts.listen}),
WebSystemdSocket: OfBool(false),
WebSystemdSocket: ofBool(false),
WebConfigFile: &s.opts.tlsConfigPath,
}

Expand Down Expand Up @@ -139,6 +139,7 @@ func registerProbes(mux *http.ServeMux, p *prober.HTTPProbe, logger log.Logger)
}
}

func OfBool(i bool) *bool {
// Helper for exporter toolkit FlagConfig
func ofBool(i bool) *bool {
return &i
}

0 comments on commit dbb017e

Please sign in to comment.