Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Saswata Mukherjee <[email protected]>
  • Loading branch information
saswatamcode committed Dec 12, 2023
1 parent 84e0dd8 commit dfaf9a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ func newRuleSpec(mco *mcov1beta2.MultiClusterObservability, scSelected string) o
ruleSpec.ServiceMonitor = true
if !mcoconfig.WithoutResourcesRequests(mco.GetAnnotations()) {
ruleSpec.Resources = mcoconfig.GetResources(mcoconfig.ThanosRule, mcoconfig.TShirtSize(mco.Spec.ReadTShirtSize), mco.Spec.AdvancedConfig)
if mco.Spec.ReadTShirtSize == "" {
mco.Spec.ReadTShirtSize = "small"
}
ruleSpec.ReloaderResources = v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceCPU): resource.MustParse(mcoconfig.ThanosRuleReloaderCPURequest[mcoconfig.TShirtSize(mco.Spec.ReadTShirtSize)]),
Expand Down Expand Up @@ -779,6 +782,9 @@ func newReceiverControllerSpec(mco *mcov1beta2.MultiClusterObservability) obsv1a
receiveControllerSpec.ServiceMonitor = true
receiveControllerSpec.Version = mcoconfig.ThanosReceiveControllerImgTag
if !mcoconfig.WithoutResourcesRequests(mco.GetAnnotations()) {
if mco.Spec.WriteTShirtSize == "" {
mco.Spec.WriteTShirtSize = "small"
}
receiveControllerSpec.Resources = v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceCPU): resource.MustParse(
Expand Down
12 changes: 12 additions & 0 deletions operators/multiclusterobservability/pkg/config/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ func getAdvancedConfigResourceOverride(component string, tshirtSize TShirtSize,
// GetResources returns the pre-set resource requirements for a particular o11y workload.
// Always default unless configured via advancedConfig, in which case it is overridden.
func GetResources(component string, tshirtSize TShirtSize, advanced *observabilityv1beta2.AdvancedConfig) corev1.ResourceRequirements {
if tshirtSize == "" {
tshirtSize = Small
}

resourceReq := getDefaultResourceRequirements(component, tshirtSize)
if advanced != nil {
resourceReq = getAdvancedConfigResourceOverride(component, tshirtSize, advanced)
Expand All @@ -236,6 +240,10 @@ func GetResources(component string, tshirtSize TShirtSize, advanced *observabili

// GetOBAResources returns the pre-set resource requirements for metrics collector.
func GetOBAResources(oba *mcoshared.ObservabilityAddonSpec, tshirtSize TShirtSize) *corev1.ResourceRequirements {
if tshirtSize == "" {
tshirtSize = Small
}

cpuRequests := MetricsCollectorCPURequest[tshirtSize]
cpuLimits := MetricsCollectorCPULimits
memoryRequests := MetricsCollectorMemoryRequest[tshirtSize]
Expand Down Expand Up @@ -283,6 +291,10 @@ func GetOBAResources(oba *mcoshared.ObservabilityAddonSpec, tshirtSize TShirtSiz

// GetReplicas returns the default replicas for a particular o11y workload.
func GetReplicas(component string, tshirtSize TShirtSize, advanced *observabilityv1beta2.AdvancedConfig) *int32 {
if tshirtSize == "" {
tshirtSize = Small
}

if advanced == nil {
return Replicas[component][tshirtSize]
}
Expand Down

0 comments on commit dfaf9a1

Please sign in to comment.