Skip to content

Commit

Permalink
CR: updated nodesToReplicasRation to int32
Browse files Browse the repository at this point in the history
  • Loading branch information
davidf146 committed May 29, 2023
1 parent 7cc197c commit e7f45ad
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion api/v1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type CBContainersRuntimeResolverSpec struct {
// +kubebuilder:default:="info"
LogLevel string `json:"logLevel,omitempty"`
// +kubebuilder:default:=5
NodesToReplicasRatio *int32 `json:"nodesToReplicasRatio,omitempty"`
NodesToReplicasRatio int32 `json:"nodesToReplicasRatio,omitempty"`
}

type CBContainersRuntimeSensorSpec struct {
Expand Down
5 changes: 0 additions & 5 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cbcontainers/state/components/runtime_resolver_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (obj *ResolverDeploymentK8sObject) mutateVolumesMounts(container *coreV1.Co
commonState.MutateVolumeMountToIncludeRootCAsVolumeMount(container)
}

func (obj *ResolverDeploymentK8sObject) getDynamicReplicasCount(nodesToReplicasRatio *int32) (*int32, error) {
func (obj *ResolverDeploymentK8sObject) getDynamicReplicasCount(nodesToReplicasRatio int32) (*int32, error) {
// Get the in-cluster config
config, err := rest.InClusterConfig()
if err != nil {
Expand All @@ -252,7 +252,7 @@ func (obj *ResolverDeploymentK8sObject) getDynamicReplicasCount(nodesToReplicasR
return nil, fmt.Errorf("error getting list of nodes: %v", err)
}

nodesCount := int32(math.Ceil(float64(len(nodes.Items)) / float64(*nodesToReplicasRatio)))
nodesCount := int32(math.Ceil(float64(len(nodes.Items)) / float64(nodesToReplicasRatio)))

return &nodesCount, nil
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: cbcontainersagents.operator.containers.carbonblack.io
spec:
Expand Down Expand Up @@ -6022,9 +6021,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
5 changes: 2 additions & 3 deletions controllers/runtime_components_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ func (r *CBContainersAgentController) setRuntimeResolverDefaults(runtimeResolver
runtimeResolver.Env = make(map[string]string)
}

if runtimeResolver.NodesToReplicasRatio == nil {
defaultNodesToReplicasRatio := int32(5)
runtimeResolver.NodesToReplicasRatio = &defaultNodesToReplicasRatio
if runtimeResolver.NodesToReplicasRatio == 0 {
runtimeResolver.NodesToReplicasRatio = 5
}

setDefaultPrometheus(&runtimeResolver.Prometheus)
Expand Down

0 comments on commit e7f45ad

Please sign in to comment.