Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/check_ta_availability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: manager

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Check the TargetAllocator CRD availability as part of the collector controller setup

# One or more tracking issues related to the change
issues: [4282]

# (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:
6 changes: 4 additions & 2 deletions internal/controllers/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager"
autodetectta "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector"
Expand Down Expand Up @@ -955,7 +956,7 @@ service:
Config: cfg,
OtelCol: tt.args.instance,
}
got, err := BuildCollector(params)
got, err := BuildCollector(autodetectta.Available, params)
if (err != nil) != tt.wantErr {
t.Errorf("BuildAll() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down Expand Up @@ -1737,6 +1738,7 @@ service:
TargetAllocatorImage: "default-ta-allocator",
CollectorConfigMapEntry: "collector.yaml",
TargetAllocatorConfigMapEntry: "targetallocator.yaml",
TargetAllocatorAvailability: autodetectta.Available,
}
params := manifests.Params{
Log: logr.Discard(),
Expand All @@ -1761,7 +1763,7 @@ service:
require.NoError(t, setErr)
})
}
got, err := BuildCollector(params)
got, err := BuildCollector(autodetectta.Available, params)
if (err != nil) != tt.wantErr {
t.Errorf("BuildAll() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down
5 changes: 3 additions & 2 deletions internal/controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

autodetectta "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/opampbridge"
Expand All @@ -37,7 +38,7 @@ func isNamespaceScoped(obj client.Object) bool {
}

// BuildCollector returns the generation and collected errors of all manifests for a given instance.
func BuildCollector(params manifests.Params) ([]client.Object, error) {
func BuildCollector(availability autodetectta.Availability, params manifests.Params) ([]client.Object, error) {
builders := []manifests.Builder[manifests.Params]{
collector.Build,
}
Expand All @@ -52,7 +53,7 @@ func BuildCollector(params manifests.Params) ([]client.Object, error) {
// If we're not building a TargetAllocator CRD, then we need to separately invoke its builder
// to directly build the manifests. This is what used to happen before the TargetAllocator CRD
// was introduced.
if !featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
if availability != autodetectta.Available || !featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
if params.TargetAllocator != nil {
taParams := targetallocator.Params{
Client: params.Client,
Expand Down
5 changes: 3 additions & 2 deletions internal/controllers/opentelemetrycollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/rbac"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector"
Expand Down Expand Up @@ -296,7 +297,7 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(ctx context.Context, req ct
}
}

desiredObjects, buildErr := BuildCollector(params)
desiredObjects, buildErr := BuildCollector(r.config.TargetAllocatorAvailability, params)
if buildErr != nil {
return ctrl.Result{}, buildErr
}
Expand Down Expand Up @@ -379,7 +380,7 @@ func (r *OpenTelemetryCollectorReconciler) GetOwnedResourceTypes() []client.Obje
ownedResources = append(ownedResources, &routev1.Route{})
}

if featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
if r.config.TargetAllocatorAvailability == targetallocator.Available && featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
ownedResources = append(ownedResources, &v1alpha1.TargetAllocator{})
}

Expand Down
3 changes: 3 additions & 0 deletions internal/controllers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus"
autoRBAC "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/rbac"
autodetectta "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/controllers"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
Expand Down Expand Up @@ -620,6 +621,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
PrometheusCRAvailability: prometheus.Available,
TargetAllocatorConfigMapEntry: "remoteconfiguration.yaml",
CollectorConfigMapEntry: "collector.yaml",
TargetAllocatorAvailability: autodetectta.Available,
}
reconciler := createTestReconciler(t, testCtx, cfg)

Expand Down Expand Up @@ -789,6 +791,7 @@ func TestOpenTelemetryCollectorReconciler_RemoveDisabled(t *testing.T) {
TargetAllocatorImage: "default-ta-allocator",
OpenShiftRoutesAvailability: openshift.RoutesAvailable,
PrometheusCRAvailability: prometheus.Available,
TargetAllocatorAvailability: autodetectta.Available,
}
reconciler := createTestReconciler(t, testCtx, cfg)

Expand Down
3 changes: 2 additions & 1 deletion internal/manifests/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/rbac"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
)
Expand Down Expand Up @@ -46,7 +47,7 @@ func Build(params manifests.Params) ([]client.Object, error) {
manifests.Factory(Ingress),
}...)

if featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
if params.Config.TargetAllocatorAvailability == targetallocator.Available && featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() {
manifestFactories = append(manifestFactories, manifests.Factory(TargetAllocator))
}

Expand Down
Loading