Skip to content

Commit

Permalink
Merge pull request #528 from go-graphite/atimofieiev/find-cache-not-f…
Browse files Browse the repository at this point in the history
…ound

fix(carbonserver): find - cache http404 responses, as render handler does
  • Loading branch information
timtofan committed Feb 13, 2023
2 parents 0fb928d + a43ab6c commit 2cb449c
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions carbonserver/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ func (listener *CarbonserverListener) findMetrics(ctx context.Context, logger *z
return nil, err
}

if len(multiResponse.Metrics) == 0 {
return nil, errorNotFound{}
}

return &result, err

case protoV2Format:
result.contentType = httpHeaders.ContentTypeProtobuf
var err error
Expand All @@ -299,12 +294,7 @@ func (listener *CarbonserverListener) findMetrics(ctx context.Context, logger *z
return nil, err
}

if len(response.Matches) == 0 {
return nil, errorNotFound{}
}

return &result, err

case pickleFormat:
// [{'metric_path': 'metric', 'intervals': [(x,y)], 'isLeaf': True},]
var metrics []map[string]interface{}
Expand Down Expand Up @@ -483,9 +473,6 @@ func (listener *CarbonserverListener) Find(ctx context.Context, req *protov2.Glo
func() (interface{}, error) {
finalRes = getProtoV2FindResponse(expandedGlobs[0], query)
lookups = expandedGlobs[0].Lookups
if len(finalRes.Matches) == 0 {
return nil, errorNotFound{}
}
return finalRes, nil
})
if err == nil {
Expand All @@ -496,16 +483,14 @@ func (listener *CarbonserverListener) Find(ctx context.Context, req *protov2.Glo
atomic.AddUint64(&listener.metrics.FindCacheMiss, 1)
}
finalRes = result.(*protov2.GlobResponse)
if len(finalRes.Matches) == 0 {
err = errorNotFound{}
}
}
} else if err == nil {
finalRes = getProtoV2FindResponse(expandedGlobs[0], query)
lookups = expandedGlobs[0].Lookups
if len(finalRes.Matches) == 0 {
finalRes, err = nil, errorNotFound{}
}
}

if len(finalRes.Matches) == 0 {
finalRes, err = nil, errorNotFound{}
}

if err != nil || finalRes == nil {
Expand Down

0 comments on commit 2cb449c

Please sign in to comment.