faasd does not provide memory limits of functions in Canonicalize format
All the openfaas implementation should return the memory info in the Canonicalize format.
Expected Behaviour
faasd should return memory limits in Canonicalize i.e. 5000000 should be returned as 5M. We follow the same into faas-netes.
Current Behaviour
faasd Provides function memory limit in bytes.
Are you a GitHub Sponsor (Yes/No?)
Check at: https://github.com/sponsors/openfaas
- [ ] Yes
- [x] No
List all Possible Solutions
We can follow the implementation for k8s
https://github.com/openfaas/faas-netes/blob/master/pkg/k8s/function_status.go#L38
https://github.com/openfaas/faas-netes/blob/master/vendor/k8s.io/api/core/v1/resource.go#L34
List the one solution that you would recommend
Steps to Reproduce (for bugs)
- We can use certifier with the current release of faasd as done in the pipeline https://github.com/openfaas/certifier/runs/4542572124?check_suite_focus=true#step:5:138
Could you submit a PR for initial review and testing?
Alex
I will work on this.
Sorry, I think this issue is my bad :sweat: I should have written a test case for the SI conversion aswell.
Anyways @nitishkumar71 this is the problematic line that you looking for: https://github.com/openfaas/faasd/blob/master/pkg/provider/handlers/read.go#L41
There was a conversation about this on the PR aswell, you might find something useful there: https://github.com/openfaas/faasd/pull/206#discussion_r713779617
Since the memory limit itself is working, only the format breaks.
So we put in: 1Mi And get out: 1048576
For this import "k8s.io/apimachinery/pkg/api/resource"
What do these calls generate?
limitBytes:=1048576
resource.NewQuantity(limitBytes, resource.BinarySI)
resource.NewQuantity(limitBytes, resource.DecimalSI)
So just checked below lines in playground
limitBytes1 := int64(1048576)
fmt.Println(resource.NewQuantity(limitBytes1, resource.BinarySI))
fmt.Println(resource.NewQuantity(limitBytes1, resource.DecimalSI))
limitBytes2 := int64(5000000)
fmt.Println(resource.NewQuantity(limitBytes2, resource.BinarySI))
fmt.Println(resource.NewQuantity(limitBytes2, resource.DecimalSI))
and the output we received is
1Mi
1048576
5000000
5M
Is that ordering correct in the output?
Yes.
Including playground link.
https://go.dev/play/p/r7J2X3pOT7g