@@ -3,6 +3,7 @@ package utils
33import (
44 "context"
55
6+ "github.com/alecthomas/units"
67 "github.com/go-logr/logr"
78 corev1 "k8s.io/api/core/v1"
89 "k8s.io/apimachinery/pkg/api/resource"
@@ -46,7 +47,6 @@ func ErrFunc(err error) controllerutil.MutateFn {
4647// IPFSContainerResources Returns the resource requests/requirements for running a single IPFS Container
4748// depending on the storage requested by the user.
4849func IPFSContainerResources (ipfsStorageBytes int64 ) (ipfsResources corev1.ResourceRequirements ) {
49-
5050 // Determine resource constraints from how much we are storing.
5151 // for every TB of storage, Request 1GB of memory and limit if we exceed 2x this amount.
5252 // memory floor is 2G.
@@ -55,17 +55,22 @@ func IPFSContainerResources(ipfsStorageBytes int64) (ipfsResources corev1.Resour
5555 // biggest node we would allocate would request a minimum allocation of 16G of RAM and 12 cores
5656 // and would permit usage up to twice this size
5757
58- ipfsStorageTB := ipfsStorageBytes / 1024 / 1024 / 1024 / 1024
58+ ipfsStorageTB := ipfsStorageBytes / int64 ( units . Tebibyte )
5959 ipfsMilliCoresMin := 250 + (500 * ipfsStorageTB )
6060 ipfsRAMGBMin := ipfsStorageTB
6161 if ipfsRAMGBMin < 2 {
62- ipfsRAMGBMin = 2
62+ ipfsRAMGBMin = 1
6363 }
6464
65+ // // ipfsRAMMinQuantity := resource.NewScaledQuantity(ipfsRAMGBMin, resource.Giga)
66+ // ipfsRAMMaxQuantity := resource.NewScaledQuantity(2*ipfsRAMGBMin, resource.Giga)
67+ // // ipfsCoresMinQuantity := resource.NewScaledQuantity(ipfsMilliCoresMin, resource.Milli)
68+ // ipfsCoresMaxQuantity := resource.NewScaledQuantity(2*ipfsMilliCoresMin, resource.Milli)
69+
6570 // ipfsRAMMinQuantity := resource.NewScaledQuantity(ipfsRAMGBMin, resource.Giga)
66- ipfsRAMMaxQuantity := resource .NewScaledQuantity (2 * ipfsRAMGBMin , resource .Giga )
71+ ipfsRAMMaxQuantity := resource .NewScaledQuantity (ipfsRAMGBMin , resource .Giga )
6772 // ipfsCoresMinQuantity := resource.NewScaledQuantity(ipfsMilliCoresMin, resource.Milli)
68- ipfsCoresMaxQuantity := resource .NewScaledQuantity (2 * ipfsMilliCoresMin , resource .Milli )
73+ ipfsCoresMaxQuantity := resource .NewScaledQuantity (ipfsMilliCoresMin , resource .Milli )
6974
7075 ipfsResources = corev1.ResourceRequirements {
7176 // Requests: corev1.ResourceList{
0 commit comments