Skip to content

Commit

Permalink
Merge branch 'main' into feature/3149
Browse files Browse the repository at this point in the history
  • Loading branch information
iblancasa authored Sep 23, 2024
2 parents 8fa48a7 + 8883006 commit 2723852
Show file tree
Hide file tree
Showing 25 changed files with 630 additions and 98 deletions.
16 changes: 0 additions & 16 deletions .chloggen/3218-align-label-filter-flag.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions .chloggen/bug-fix-hpa.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions .chloggen/enhanced-webhook.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
path: bin
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}-${{ steps.setup-go.outputs.go-version }}
- name: Install chainsaw
uses: kyverno/action-install-chainsaw@v0.2.9
uses: kyverno/action-install-chainsaw@v0.2.10
- name: Install tools
run: make install-tools
- name: Prepare e2e tests
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

<!-- next version -->

## 0.109.0

### 🚩 Deprecations 🚩

- `operator`: Deprecated `label` flag and introduced `labels-filter` flag to align the label filtering with the attribute filtering flag name. The `label` flag will be removed when #3236 issue is resolved. (#3218)

### 💡 Enhancements 💡

- `collector`: adds test for memory utilization (#3283)
- `operator`: Added reconciliation errors for webhook events. The webhooks run the manifest generators to check for any errors. (#2399)

### Components

* [OpenTelemetry Collector - v0.109.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.109.0)
* [OpenTelemetry Contrib - v0.109.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.109.0)
* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5)
* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0)
* [Node.JS - v0.52.1](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.52.1)
* [Python - v0.48b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.48b0)
* [Go - v0.14.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.14.0-alpha)
* [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4)
* [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4)

## 0.108.0

### 💡 Enhancements 💡
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range,

| OpenTelemetry Operator | Kubernetes | Cert-Manager | Prometheus-Operator |
|------------------------|----------------| ------------ |---------------------|
| v0.109.0 | v1.23 to v1.31 | v1 | v0.76.0 |
| v0.108.0 | v1.23 to v1.31 | v1 | v0.76.0 |
| v0.107.0 | v1.23 to v1.30 | v1 | v0.75.0 |
| v0.106.0 | v1.23 to v1.30 | v1 | v0.75.0 |
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ The operator should be released within a week after the [OpenTelemetry collector

| Version | Release manager |
|----------|-----------------|
| v0.109.0 | @jaronoff97 |
| v0.110.0 | @swiatekm |
| v0.111.0 | @frzifus |
| v0.112.0 | @yuriolisa |
| v0.113.0 | @pavolloffay |
| v0.114.0 | @TylerHelmuth |
| v0.115.0 | @jaronoff97 |
3 changes: 2 additions & 1 deletion apis/v1alpha1/targetallocator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
)

func init() {
v1beta1.SchemeBuilder.Register(&TargetAllocator{}, &TargetAllocatorList{})
SchemeBuilder.Register(&TargetAllocator{}, &TargetAllocatorList{})
}

//+kubebuilder:object:root=true
//+kubebuilder:storageversion
//+kubebuilder:subresource:status

// TargetAllocator is the Schema for the targetallocators API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-09-05T15:16:50Z"
createdAt: "2024-09-19T17:15:52Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: github.com/open-telemetry/opentelemetry-operator
support: OpenTelemetry Community
name: opentelemetry-operator.v0.108.0
name: opentelemetry-operator.v0.109.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -479,7 +479,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.108.0
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.109.0
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -587,7 +587,7 @@ spec:
minKubeVersion: 1.23.0
provider:
name: OpenTelemetry Community
version: 0.108.0
version: 0.109.0
webhookdefinitions:
- admissionReviewVersions:
- v1alpha1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-09-05T15:16:58Z"
createdAt: "2024-09-19T17:16:12Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: github.com/open-telemetry/opentelemetry-operator
support: OpenTelemetry Community
name: opentelemetry-operator.v0.108.0
name: opentelemetry-operator.v0.109.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -483,7 +483,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.108.0
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.109.0
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -591,7 +591,7 @@ spec:
minKubeVersion: 1.23.0
provider:
name: OpenTelemetry Community
version: 0.108.0
version: 0.109.0
webhookdefinitions:
- admissionReviewVersions:
- v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func BuildCollector(params manifests.Params) ([]client.Object, error) {
Recorder: params.Recorder,
Log: params.Log,
Config: params.Config,
Collector: params.OtelCol,
Collector: &params.OtelCol,
TargetAllocator: *params.TargetAllocator,
}
taResources, err := BuildTargetAllocator(taParams)
Expand Down
4 changes: 4 additions & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func TestMain(m *testing.M) {
fmt.Printf("failed to SetupWebhookWithManager: %v", err)
os.Exit(1)
}
if err = v1alpha1.SetupTargetAllocatorWebhook(mgr, config.New(), reviewer); err != nil {
fmt.Printf("failed to SetupWebhookWithManager: %v", err)
os.Exit(1)
}

if err = v1alpha1.SetupOpAMPBridgeWebhook(mgr, config.New()); err != nil {
fmt.Printf("failed to SetupWebhookWithManager: %v", err)
Expand Down
152 changes: 152 additions & 0 deletions controllers/targetallocator_controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package controllers contains the main controller, where the reconciliation starts.
package controllers

import (
"context"

"github.com/go-logr/logr"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
policyV1 "k8s.io/api/policy/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator"
taStatus "github.com/open-telemetry/opentelemetry-operator/internal/status/targetallocator"
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
)

// TargetAllocatorReconciler reconciles a TargetAllocator object.
type TargetAllocatorReconciler struct {
client.Client
recorder record.EventRecorder
scheme *runtime.Scheme
log logr.Logger
config config.Config
}

// TargetAllocatorReconcilerParams is the set of options to build a new TargetAllocatorReconciler.
type TargetAllocatorReconcilerParams struct {
client.Client
Recorder record.EventRecorder
Scheme *runtime.Scheme
Log logr.Logger
Config config.Config
}

func (r *TargetAllocatorReconciler) getParams(instance v1alpha1.TargetAllocator) targetallocator.Params {
p := targetallocator.Params{
Config: r.config,
Client: r.Client,
Log: r.log,
Scheme: r.scheme,
Recorder: r.recorder,
TargetAllocator: instance,
}

return p
}

// NewTargetAllocatorReconciler creates a new reconciler for TargetAllocator objects.
func NewTargetAllocatorReconciler(
client client.Client,
scheme *runtime.Scheme,
recorder record.EventRecorder,
config config.Config,
logger logr.Logger,
) *TargetAllocatorReconciler {
return &TargetAllocatorReconciler{
Client: client,
log: logger,
scheme: scheme,
config: config,
recorder: recorder,
}
}

// TODO: Uncomment the lines below after enabling the TA controller in main.go
// // +kubebuilder:rbac:groups="",resources=pods;configmaps;services;serviceaccounts;persistentvolumeclaims;persistentvolumes,verbs=get;list;watch;create;update;patch;delete
// // +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
// // +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// // +kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=get;list;watch;create;update;patch;delete
// // +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors;podmonitors,verbs=get;list;watch;create;update;patch;delete
// // +kubebuilder:rbac:groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=get;list;watch;update;patch
// // +kubebuilder:rbac:groups=opentelemetry.io,resources=targetallocators,verbs=get;list;watch;update;patch
// // +kubebuilder:rbac:groups=opentelemetry.io,resources=targetallocators/status,verbs=get;update;patch

// Reconcile the current state of a TargetAllocator resource with the desired state.
func (r *TargetAllocatorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.log.WithValues("targetallocator", req.NamespacedName)

var instance v1alpha1.TargetAllocator
if err := r.Client.Get(ctx, req.NamespacedName, &instance); err != nil {
if !apierrors.IsNotFound(err) {
log.Error(err, "unable to fetch TargetAllocator")
}

// we'll ignore not-found errors, since they can't be fixed by an immediate
// requeue (we'll need to wait for a new notification), and we can get them
// on deleted requests.
return ctrl.Result{}, client.IgnoreNotFound(err)
}
// We have a deletion, short circuit and let the deletion happen
if deletionTimestamp := instance.GetDeletionTimestamp(); deletionTimestamp != nil {
return ctrl.Result{}, nil
}

if instance.Spec.ManagementState == v1beta1.ManagementStateUnmanaged {
log.Info("Skipping reconciliation for unmanaged TargetAllocator resource", "name", req.String())
// Stop requeueing for unmanaged TargetAllocator custom resources
return ctrl.Result{}, nil
}

params := r.getParams(instance)
desiredObjects, buildErr := BuildTargetAllocator(params)
if buildErr != nil {
return ctrl.Result{}, buildErr
}

err := reconcileDesiredObjects(ctx, r.Client, log, &params.TargetAllocator, params.Scheme, desiredObjects, nil)
return taStatus.HandleReconcileStatus(ctx, log, params, err)
}

// SetupWithManager tells the manager what our controller is interested in.
func (r *TargetAllocatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
builder := ctrl.NewControllerManagedBy(mgr).
For(&v1alpha1.TargetAllocator{}).
Owns(&corev1.ConfigMap{}).
Owns(&corev1.ServiceAccount{}).
Owns(&corev1.Service{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.PersistentVolume{}).
Owns(&corev1.PersistentVolumeClaim{}).
Owns(&policyV1.PodDisruptionBudget{})

if featuregate.PrometheusOperatorIsAvailable.IsEnabled() {
builder.Owns(&monitoringv1.ServiceMonitor{})
builder.Owns(&monitoringv1.PodMonitor{})
}

return builder.Complete(r)
}
Loading

0 comments on commit 2723852

Please sign in to comment.