From f2b3605e1a3b1d33baf5ebdd2e2ab953d70cd58f Mon Sep 17 00:00:00 2001 From: Abhimanyu Singh Gaur <12651351+abhimanyusinghgaur@users.noreply.github.com> Date: Thu, 10 Dec 2020 16:27:23 +0530 Subject: [PATCH] fix(GraphQL): don't update cacheMb if not specified by user (GRAPHQL-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. (cherry picked from commit c03c32766f460d20a219e97711bb7ea84e54d965) # Conflicts: # graphql/admin/config.go --- graphql/admin/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/graphql/admin/config.go b/graphql/admin/config.go index d570f98cb4d..e72abbe6a5b 100644 --- a/graphql/admin/config.go +++ b/graphql/admin/config.go @@ -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. @@ -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 } }