Skip to content
Merged
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
4 changes: 1 addition & 3 deletions internal/components/extensions/jaeger_query_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ const (
port = 16686
)

var (
_ components.Parser = &components.GenericParser[*JaegerQueryExtensionConfig]{}
)
var _ components.Parser = &components.GenericParser[*JaegerQueryExtensionConfig]{}

type JaegerQueryExtensionConfig struct {
HTTP jaegerHTTPAddress `mapstructure:"http,omitempty" yaml:"http,omitempty"`
Expand Down
4 changes: 1 addition & 3 deletions internal/components/generic_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
)

var (
_ Parser = &GenericParser[SingleEndpointConfig]{}
)
var _ Parser = &GenericParser[SingleEndpointConfig]{}

// GenericParser serves as scaffolding for custom parsing logic by isolating
// functionality to idempotent functions.
Expand Down
4 changes: 1 addition & 3 deletions internal/components/single_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import (

const DefaultRecAddress = "0.0.0.0"

var (
_ Parser = &GenericParser[*SingleEndpointConfig]{}
)
var _ Parser = &GenericParser[*SingleEndpointConfig]{}

// SingleEndpointConfig represents the minimal struct for a given YAML configuration input containing either
// endpoint or listen_address.
Expand Down
38 changes: 17 additions & 21 deletions internal/controllers/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,23 @@ var (
pathTypePrefix = networkingv1.PathTypePrefix
)

var (
opampbridgeSelectorLabels = map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
"app.kubernetes.io/part-of": "opentelemetry",
"app.kubernetes.io/component": "opentelemetry-opamp-bridge",
"app.kubernetes.io/instance": "test.test",
}
)
var opampbridgeSelectorLabels = map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
"app.kubernetes.io/part-of": "opentelemetry",
"app.kubernetes.io/component": "opentelemetry-opamp-bridge",
"app.kubernetes.io/instance": "test.test",
}

var (
taSelectorLabels = map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
"app.kubernetes.io/part-of": "opentelemetry",
"app.kubernetes.io/component": "opentelemetry-targetallocator",
"app.kubernetes.io/instance": "test.test",
"app.kubernetes.io/name": "test-targetallocator",
}
)
var taSelectorLabels = map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
"app.kubernetes.io/part-of": "opentelemetry",
"app.kubernetes.io/component": "opentelemetry-targetallocator",
"app.kubernetes.io/instance": "test.test",
"app.kubernetes.io/name": "test-targetallocator",
}

func TestBuildCollector(t *testing.T) {
var goodConfigYaml = `receivers:
goodConfigYaml := `receivers:
examplereceiver:
endpoint: "0.0.0.0:12345"
exporters:
Expand Down Expand Up @@ -1054,7 +1050,6 @@ func TestBuildAll_OpAMPBridge(t *testing.T) {
wantErr bool
}{
{

name: "base case",
args: args{
instance: v1alpha1.OpAMPBridge{
Expand Down Expand Up @@ -1219,7 +1214,8 @@ componentsAllowed:
receivers:
- otlp
endpoint: ws://opamp-server:4320/v1/opamp
`},
`,
},
},
&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1291,7 +1287,7 @@ endpoint: ws://opamp-server:4320/v1/opamp
}

func TestBuildCollectorTargetAllocatorCR(t *testing.T) {
var goodConfigYaml = `
goodConfigYaml := `
receivers:
prometheus:
config:
Expand Down
2 changes: 0 additions & 2 deletions internal/controllers/clusterobservability_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ func (r *ClusterObservabilityReconciler) reconcileOpenTelemetryResource(ctx cont

return r.Update(ctx, latest)
})

if err != nil {
return fmt.Errorf("failed to update OpenTelemetryCollector %s: %w", key, err)
}
Expand Down Expand Up @@ -272,7 +271,6 @@ func (r *ClusterObservabilityReconciler) reconcileOpenTelemetryResource(ctx cont

return r.Update(ctx, latest)
})

if err != nil {
return fmt.Errorf("failed to update Instrumentation %s: %w", key, err)
}
Expand Down
26 changes: 14 additions & 12 deletions internal/controllers/opampbridge_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ import (
"github.com/open-telemetry/opentelemetry-operator/internal/controllers"
)

var opampBridgeLogger = logf.Log.WithName("opamp-bridge-controller-unit-tests")
var opampBridgeMockAutoDetector = &mockAutoDetect{
OpenShiftRoutesAvailabilityFunc: func() (openshift.RoutesAvailability, error) {
return openshift.RoutesAvailable, nil
},
PrometheusCRsAvailabilityFunc: func() (prometheus.Availability, error) {
return prometheus.Available, nil
},
RBACPermissionsFunc: func(context.Context) (rbac.Availability, error) {
return rbac.Available, nil
},
}
var (
opampBridgeLogger = logf.Log.WithName("opamp-bridge-controller-unit-tests")
opampBridgeMockAutoDetector = &mockAutoDetect{
OpenShiftRoutesAvailabilityFunc: func() (openshift.RoutesAvailability, error) {
return openshift.RoutesAvailable, nil
},
PrometheusCRsAvailabilityFunc: func() (prometheus.Availability, error) {
return prometheus.Available, nil
},
RBACPermissionsFunc: func(context.Context) (rbac.Availability, error) {
return rbac.Available, nil
},
}
)

func TestNewObjectsOnReconciliation_OpAMPBridge(t *testing.T) {
// prepare
Expand Down
10 changes: 4 additions & 6 deletions internal/controllers/opentelemetrycollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ import (

const resourceOwnerKey = ".metadata.owner"

var (
ownedClusterObjectTypes = []client.Object{
&rbacv1.ClusterRole{},
&rbacv1.ClusterRoleBinding{},
}
)
var ownedClusterObjectTypes = []client.Object{
&rbacv1.ClusterRole{},
&rbacv1.ClusterRoleBinding{},
}

// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object.
type OpenTelemetryCollectorReconciler struct {
Expand Down
20 changes: 9 additions & 11 deletions internal/controllers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,14 @@ const (
annotationVal = "true"
)

var (
extraPorts = v1beta1.PortsSpec{
ServicePort: v1.ServicePort{
Name: "port-web",
Protocol: "TCP",
Port: 8080,
TargetPort: intstr.FromInt32(8080),
},
}
)
var extraPorts = v1beta1.PortsSpec{
ServicePort: v1.ServicePort{
Name: "port-web",
Protocol: "TCP",
Port: 8080,
TargetPort: intstr.FromInt32(8080),
},
}

type check[T any] func(t *testing.T, params T)

Expand Down Expand Up @@ -1481,7 +1479,7 @@ func TestUpgrade(t *testing.T) {
}
}

func namespacedObjectName(name string, namespace string) types.NamespacedName {
func namespacedObjectName(name, namespace string) types.NamespacedName {
return types.NamespacedName{
Namespace: namespace,
Name: name,
Expand Down
16 changes: 10 additions & 6 deletions internal/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ func testCollectorWithModeAndReplicas(t *testing.T, name string, mode v1beta1.Mo
IntVal: 80,
},
NodePort: 0,
}}},
},
}},
Replicas: &replicas,
},
Config: otelConfig,
Expand All @@ -327,7 +328,7 @@ func testCollectorWithModeAndReplicas(t *testing.T, name string, mode v1beta1.Mo
}
}

func testCollectorAssertNoErr(t *testing.T, name string, taContainerImage string, file string) v1beta1.OpenTelemetryCollector {
func testCollectorAssertNoErr(t *testing.T, name, taContainerImage, file string) v1beta1.OpenTelemetryCollector {
p, err := testCollectorWithConfigFile(name, taContainerImage, file)
assert.NoError(t, err)
if len(taContainerImage) == 0 {
Expand All @@ -336,7 +337,7 @@ func testCollectorAssertNoErr(t *testing.T, name string, taContainerImage string
return p
}

func testCollectorWithConfigFile(name string, taContainerImage string, file string) (v1beta1.OpenTelemetryCollector, error) {
func testCollectorWithConfigFile(name, taContainerImage, file string) (v1beta1.OpenTelemetryCollector, error) {
replicas := int32(1)
var configYAML []byte
var err error
Expand Down Expand Up @@ -375,7 +376,8 @@ func testCollectorWithConfigFile(name string, taContainerImage string, file stri
IntVal: 80,
},
NodePort: 0,
}}},
},
}},
Replicas: &replicas,
},
Mode: v1beta1.ModeStatefulSet,
Expand Down Expand Up @@ -419,7 +421,8 @@ func testCollectorWithHPA(t *testing.T, minReps, maxReps int32) v1beta1.OpenTele
IntVal: 80,
},
NodePort: 0,
}}},
},
}},
},

Config: otelConfig,
Expand Down Expand Up @@ -484,7 +487,8 @@ func testCollectorWithPDB(t *testing.T, minAvailable, maxUnavailable int32) v1be
IntVal: 80,
},
NodePort: 0,
}}},
},
}},
PodDisruptionBudget: pdb,
},

Expand Down
4 changes: 2 additions & 2 deletions internal/fips/fipscheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type FIPSCheck interface {
// DisabledComponents checks if a submitted components are denied or not.
DisabledComponents(receivers map[string]any, exporters map[string]any, processors map[string]any, extensions map[string]any) []string
DisabledComponents(receivers, exporters, processors, extensions map[string]any) []string
}

// FipsCheck holds configuration for FIPS deny list.
Expand Down Expand Up @@ -38,7 +38,7 @@ func listToMap(list []string) map[string]bool {
return m
}

func (fips fipsCheck) DisabledComponents(receivers map[string]any, exporters map[string]any, processors map[string]any, extensions map[string]any) []string {
func (fips fipsCheck) DisabledComponents(receivers, exporters, processors, extensions map[string]any) []string {
var disabled []string
if comp := isDisabled(fips.receivers, receivers); comp != "" {
disabled = append(disabled, comp)
Expand Down
6 changes: 4 additions & 2 deletions internal/instrumentation/apachehttpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod
EmptyDir: &corev1.EmptyDirVolumeSource{
SizeLimit: volumeSize(apacheSpec.VolumeSizeLimit),
},
}})
},
})

apacheConfDir := getApacheConfDir(apacheSpec.ConfigPath)

Expand Down Expand Up @@ -139,7 +140,8 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod
Name: apacheAttributesEnvVar,
Value: getApacheOtelConfig(pod, useLabelsForResourceAttributes, apacheSpec, container, otlpEndpoint, resourceMap),
},
{Name: apacheServiceInstanceIdEnvVar,
{
Name: apacheServiceInstanceIdEnvVar,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
Expand Down
6 changes: 4 additions & 2 deletions internal/instrumentation/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func configureExporter(exporter v1alpha1.Exporter, pod *corev1.Pod, container *c
Secret: &corev1.SecretVolumeSource{
SecretName: exporter.TLS.SecretName,
},
}})
},
})
}
addVolumeMount := true
for _, vol := range container.VolumeMounts {
Expand Down Expand Up @@ -112,7 +113,8 @@ func configureExporter(exporter v1alpha1.Exporter, pod *corev1.Pod, container *c
Name: exporter.TLS.ConfigMapName,
},
},
}})
},
})
}
addVolumeMount := true
for _, vol := range container.VolumeMounts {
Expand Down
5 changes: 3 additions & 2 deletions internal/instrumentation/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func instrVolume(volumeClaimTemplate corev1.PersistentVolumeClaimTemplate, name
EmptyDir: &corev1.EmptyDirVolumeSource{
SizeLimit: volumeSize(quantity),
},
}}
},
}
}

func volumeSize(quantity *resource.Quantity) *resource.Quantity {
Expand All @@ -158,7 +159,7 @@ func isValidContainersAnnotation(containersAnnotation string) error {
}

// setContainersFromAnnotation sets the containers associated to one intrumentation based on the content of the provided annotation.
func setContainersFromAnnotation(inst *instrumentationWithContainers, annotation string, ns metav1.ObjectMeta, pod metav1.ObjectMeta) error {
func setContainersFromAnnotation(inst *instrumentationWithContainers, annotation string, ns, pod metav1.ObjectMeta) error {
annotationValue := annotationValue(ns, pod, annotation)
if annotationValue == "" {
return nil
Expand Down
12 changes: 8 additions & 4 deletions internal/instrumentation/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ func TestInstrVolume(t *testing.T) {
},
},
},
}},
},
},
},
{
name: "With volume size limit",
Expand All @@ -218,7 +219,8 @@ func TestInstrVolume(t *testing.T) {
EmptyDir: &corev1.EmptyDirVolumeSource{
SizeLimit: &defaultVolumeLimitSize,
},
}},
},
},
},
{
name: "No volume or size limit",
Expand All @@ -231,7 +233,8 @@ func TestInstrVolume(t *testing.T) {
EmptyDir: &corev1.EmptyDirVolumeSource{
SizeLimit: &defaultSize,
},
}},
},
},
},
{
name: "With volume and size limit",
Expand All @@ -252,7 +255,8 @@ func TestInstrVolume(t *testing.T) {
},
},
},
}},
},
},
},
}

Expand Down
Loading
Loading