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)

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.
  • Loading branch information
abhimanyusinghgaur authored Dec 10, 2020
1 parent 5042370 commit c03c327
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions graphql/admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

type configInput struct {
CacheMb float64
CacheMb *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 @@ -42,8 +42,11 @@ func resolveUpdateConfig(ctx context.Context, m schema.Mutation) (*resolve.Resol
return resolve.EmptyResult(m, err), false
}

if err = worker.UpdateCacheMb(int64(input.CacheMb)); err != nil {
return resolve.EmptyResult(m, err), false
// update cacheMB only when it is specified by user
if input.CacheMb != nil {
if err = worker.UpdateCacheMb(int64(*input.CacheMb)); err != nil {
return resolve.EmptyResult(m, err), false
}
}

// input.LogRequest will be nil, when it is not specified explicitly in config request.
Expand Down

0 comments on commit c03c327

Please sign in to comment.