From d41878cb9ec4f6799a86395fc6b5eb1f6dae30d8 Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Tue, 22 Jun 2021 21:39:55 +0530 Subject: [PATCH] ceph: give resource request preference for mds_cache_memory_limit earlier, for mds, when resource limit is not defined it has default limit of `"mds_cache_memory_limit": "4294967296"` even if resouce.request is defined. Now, resource request will be given preference when both request and limit is defined and if only limit is defined it will be applied or otherwise. Closes: https://github.com/rook/rook/issues/8143 Signed-off-by: subhamkrai --- pkg/operator/ceph/file/mds/config.go | 3 +++ pkg/operator/ceph/file/mds/spec.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/operator/ceph/file/mds/config.go b/pkg/operator/ceph/file/mds/config.go index 618976c6d..13cf0a1b7 100644 --- a/pkg/operator/ceph/file/mds/config.go +++ b/pkg/operator/ceph/file/mds/config.go @@ -74,6 +74,9 @@ func (c *Cluster) setDefaultFlagsMonConfigStore(mdsID string) error { if !c.fs.Spec.MetadataServer.Resources.Limits.Memory().IsZero() { mdsCacheMemoryLimit := float64(c.fs.Spec.MetadataServer.Resources.Limits.Memory().Value()) * mdsCacheMemoryLimitFactor configOptions["mds_cache_memory_limit"] = strconv.Itoa(int(mdsCacheMemoryLimit)) + } else if !c.fs.Spec.MetadataServer.Resources.Requests.Memory().IsZero() { + mdsCacheMemoryRequest := float64(c.fs.Spec.MetadataServer.Resources.Requests.Memory().Value()) * mdsCacheMemoryResourceFactor + configOptions["mds_cache_memory_limit"] = strconv.Itoa(int(mdsCacheMemoryRequest)) } // Set mds_join_fs flag to force mds daemon to join a specific fs diff --git a/pkg/operator/ceph/file/mds/spec.go b/pkg/operator/ceph/file/mds/spec.go index 4c3243756..56d146660 100644 --- a/pkg/operator/ceph/file/mds/spec.go +++ b/pkg/operator/ceph/file/mds/spec.go @@ -37,7 +37,8 @@ const ( // MDS cache memory limit should be set to 50-60% of RAM reserved for the MDS container // MDS uses approximately 125% of the value of mds_cache_memory_limit in RAM. // Eventually we will tune this automatically: http://tracker.ceph.com/issues/36663 - mdsCacheMemoryLimitFactor = 0.5 + mdsCacheMemoryLimitFactor = 0.5 + mdsCacheMemoryResourceFactor = 0.8 ) func (c *Cluster) makeDeployment(mdsConfig *mdsConfig, namespace string) (*apps.Deployment, error) {