diff --git a/.chloggen/change-default-strategies.yaml b/.chloggen/change-default-strategies.yaml new file mode 100755 index 0000000000..325188eb22 --- /dev/null +++ b/.chloggen/change-default-strategies.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) +component: target allocator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change default allocation and filtering strategy + +# One or more tracking issues related to the change +issues: [2477] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: \ No newline at end of file diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index b9e3f3ebba..c8f19daf5a 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -297,8 +297,9 @@ type OpenTelemetryTargetAllocator struct { // +optional Resources v1.ResourceRequirements `json:"resources,omitempty"` // AllocationStrategy determines which strategy the target allocator should use for allocation. - // The current options are least-weighted and consistent-hashing. The default option is least-weighted + // The current options are least-weighted and consistent-hashing. The default option is consistent-hashing // +optional + // +kubebuilder:default:=consistent-hashing AllocationStrategy OpenTelemetryTargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"` // FilterStrategy determines how to filter targets before allocating them among the collectors. // The only current option is relabel-config (drops targets based on prom relabel_config). diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml index f3af66fd18..9592e98c3b 100644 --- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -5024,10 +5024,11 @@ spec: type: object type: object allocationStrategy: + default: consistent-hashing description: AllocationStrategy determines which strategy the target allocator should use for allocation. The current options are least-weighted and consistent-hashing. The default option - is least-weighted + is consistent-hashing enum: - least-weighted - consistent-hashing diff --git a/cmd/otel-allocator/config/config.go b/cmd/otel-allocator/config/config.go index d7aea48d35..fbab10d20a 100644 --- a/cmd/otel-allocator/config/config.go +++ b/cmd/otel-allocator/config/config.go @@ -62,14 +62,14 @@ func (c Config) GetAllocationStrategy() string { if c.AllocationStrategy != nil { return *c.AllocationStrategy } - return "least-weighted" + return "consistent-hashing" } func (c Config) GetTargetsFilterStrategy() string { if c.FilterStrategy != nil { return *c.FilterStrategy } - return "" + return "relabel-config" } func LoadFromFile(file string, target *Config) error { diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 4229e41cec..2153f723ee 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -5021,10 +5021,11 @@ spec: type: object type: object allocationStrategy: + default: consistent-hashing description: AllocationStrategy determines which strategy the target allocator should use for allocation. The current options are least-weighted and consistent-hashing. The default option - is least-weighted + is consistent-hashing enum: - least-weighted - consistent-hashing diff --git a/controllers/builder_test.go b/controllers/builder_test.go index 807d0f9d05..e0f8ae461d 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -1316,7 +1316,7 @@ service: Annotations: nil, }, Data: map[string]string{ - "targetallocator.yaml": `allocation_strategy: least-weighted + "targetallocator.yaml": `allocation_strategy: consistent-hashing collector_selector: matchlabels: app.kubernetes.io/component: opentelemetry-collector @@ -1377,7 +1377,7 @@ label_selector: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "20c09760c240d08287ff05bd2375985220b577d938e82efd85467e17174690e0", + "opentelemetry-targetallocator-config/hash": "9126d0bb3bde858f655580a9ae6d4557c69ee430b4ab9f72e08c66334efe7989", }, }, Spec: corev1.PodSpec{ @@ -1705,7 +1705,7 @@ label_selector: Annotations: nil, }, Data: map[string]string{ - "targetallocator.yaml": `allocation_strategy: least-weighted + "targetallocator.yaml": `allocation_strategy: consistent-hashing collector_selector: matchlabels: app.kubernetes.io/component: opentelemetry-collector @@ -1766,7 +1766,7 @@ label_selector: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "20c09760c240d08287ff05bd2375985220b577d938e82efd85467e17174690e0", + "opentelemetry-targetallocator-config/hash": "9126d0bb3bde858f655580a9ae6d4557c69ee430b4ab9f72e08c66334efe7989", }, }, Spec: corev1.PodSpec{ diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index 817da2eab1..982a48e32f 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -458,7 +458,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { "app.kubernetes.io/part-of": "opentelemetry", } taConfig["config"] = promConfig["config"] - taConfig["allocation_strategy"] = "least-weighted" + taConfig["allocation_strategy"] = "consistent-hashing" taConfig["prometheus_cr"] = map[string]string{ "scrape_interval": "30s", } diff --git a/docs/api.md b/docs/api.md index 427c278331..53f4cd4383 100644 --- a/docs/api.md +++ b/docs/api.md @@ -18466,9 +18466,10 @@ TargetAllocator indicates a value which determines whether to spawn a target all allocationStrategy enum - AllocationStrategy determines which strategy the target allocator should use for allocation. The current options are least-weighted and consistent-hashing. The default option is least-weighted
+ AllocationStrategy determines which strategy the target allocator should use for allocation. The current options are least-weighted and consistent-hashing. The default option is consistent-hashing

Enum: least-weighted, consistent-hashing
+ Default: consistent-hashing
false diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index 8f5fc76617..def642da0c 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -59,7 +59,7 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) { if len(params.OtelCol.Spec.TargetAllocator.AllocationStrategy) > 0 { taConfig["allocation_strategy"] = params.OtelCol.Spec.TargetAllocator.AllocationStrategy } else { - taConfig["allocation_strategy"] = v1alpha1.OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted + taConfig["allocation_strategy"] = v1alpha1.OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing } if len(params.OtelCol.Spec.TargetAllocator.FilterStrategy) > 0 { diff --git a/internal/manifests/targetallocator/configmap_test.go b/internal/manifests/targetallocator/configmap_test.go index a73f9c17d9..3550c74b1e 100644 --- a/internal/manifests/targetallocator/configmap_test.go +++ b/internal/manifests/targetallocator/configmap_test.go @@ -39,7 +39,7 @@ func TestDesiredConfigMap(t *testing.T) { expectedLables["app.kubernetes.io/name"] = "my-instance-targetallocator" expectedData := map[string]string{ - "targetallocator.yaml": `allocation_strategy: least-weighted + "targetallocator.yaml": `allocation_strategy: consistent-hashing collector_selector: matchlabels: app.kubernetes.io/component: opentelemetry-collector @@ -81,7 +81,7 @@ label_selector: expectedLables["app.kubernetes.io/name"] = "my-instance-targetallocator" expectedData := map[string]string{ - "targetallocator.yaml": `allocation_strategy: least-weighted + "targetallocator.yaml": `allocation_strategy: consistent-hashing collector_selector: matchlabels: app.kubernetes.io/component: opentelemetry-collector @@ -133,7 +133,7 @@ service_monitor_selector: expectedLables["app.kubernetes.io/name"] = "my-instance-targetallocator" expectedData := map[string]string{ - "targetallocator.yaml": `allocation_strategy: least-weighted + "targetallocator.yaml": `allocation_strategy: consistent-hashing collector_selector: matchlabels: app.kubernetes.io/component: opentelemetry-collector