Skip to content

Commit

Permalink
fix(GraphQL): don't update cacheMb if not specified by user (GRAPHQL-…
Browse files Browse the repository at this point in the history
…888) (#7103) (#7106)

Fixes GRAPHQL-888.
Previously, if you ran this request:
```
$ curl -H "Content-Type: application/json" http://localhost:8080/admin -d '{"query": "mutation {config(input: {logRequest: false}){response {code message}}}"}'
```
Alpha logs would also print this:
```
I1205 22:22:51.684693 2681396 middlewares.go:178] GraphQL admin mutation. Name =  config
I1205 22:22:51.684724 2681396 config.go:38] Got config update through GraphQL admin API
I1205 22:22:51.684810 2681396 worker.go:138] Updating cacheMb to 0
```
Indicating that cacheMb was also updated, even it wasn't specified in the request.

This PR fixes this issue.

(cherry picked from commit c03c327)

# Conflicts:
#	graphql/admin/config.go
  • Loading branch information
abhimanyusinghgaur authored Dec 10, 2020
1 parent 466ad9a commit da310c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions graphql/admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

type configInput struct {
LruMB float64
LruMB *float64
// LogRequest is used to update WorkerOptions.LogRequest. true value of LogRequest enables
// logging of all requests coming to alphas. LogRequest type has been kept as *bool instead of
// bool to avoid updating WorkerOptions.LogRequest when it has default value of false.
Expand All @@ -43,8 +43,9 @@ func resolveUpdateConfig(ctx context.Context, m schema.Mutation) (*resolve.Resol
return resolve.EmptyResult(m, err), false
}

if input.LruMB > 0 {
if err = worker.UpdateLruMb(input.LruMB); err != nil {
// update LruMB only when it is specified by user
if input.LruMB != nil {
if err = worker.UpdateLruMb(*input.LruMB); err != nil {
return resolve.EmptyResult(m, err), false
}
}
Expand Down

0 comments on commit da310c1

Please sign in to comment.