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

fix(carbonserver): find - cache http404 responses, as render handler does #528

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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