From 8ac45f5379cc911e9e5e373b057cd6330f1785ca Mon Sep 17 00:00:00 2001 From: Nitishkumar Singh Date: Sun, 9 Jan 2022 22:57:40 +0530 Subject: [PATCH] Avoid providing memory limit if not set explicitly Signed-off-by: Nitishkumar Singh --- pkg/provider/handlers/read.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/provider/handlers/read.go b/pkg/provider/handlers/read.go index 0421b5c2..8eda1d0f 100644 --- a/pkg/provider/handlers/read.go +++ b/pkg/provider/handlers/read.go @@ -40,7 +40,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h annotations := &fn.annotations labels := &fn.labels memory := resource.NewQuantity(fn.memoryLimit, resource.BinarySI) - res = append(res, types.FunctionStatus{ + status := types.FunctionStatus{ Name: fn.name, Image: fn.image, Replicas: uint64(fn.replicas), @@ -50,9 +50,17 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h Secrets: fn.secrets, EnvVars: fn.envVars, EnvProcess: fn.envProcess, - Limits: &types.FunctionResources{Memory: memory.String()}, CreatedAt: fn.createdAt, - }) + } + + // Do not remove below memory check for 0 + // Memory limit should not be included in status until set explicitly + limit := &types.FunctionResources{Memory: memory.String()} + if limit.Memory != "0" { + status.Limits = limit + } + + res = append(res, status) } body, _ := json.Marshal(res)