Skip to content

Commit

Permalink
Merge branch 'main' into mustgather
Browse files Browse the repository at this point in the history
  • Loading branch information
IshwarKanse authored Oct 24, 2024
2 parents 57eeb5a + 22e8c06 commit 2d2827c
Show file tree
Hide file tree
Showing 27 changed files with 7,024 additions and 923 deletions.
16 changes: 16 additions & 0 deletions .chloggen/3267-custom-instr-vol.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: enhancement

# 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: auto-instrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds VolumeClaimTemplate field to Instrumentation spec to enable user-definable ephemeral volumes for auto-instrumentation.

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

# (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:
16 changes: 16 additions & 0 deletions .chloggen/ta-no-root.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: target allocator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Change docker image to run as non-root

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

# (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:
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@

# AutoInstrumentation owners
# TBD

# Target Allocator owners
cmd/otel-allocator @open-telemetry/operator-ta-maintainers
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,6 @@ Emeritus Approvers:
- [Owais Lone](https://github.com/owais), Splunk
- [Pablo Baeyens](https://github.com/mx-psi), DataDog

Target Allocator Maintainers ([@open-telemetry/operator-ta-maintainers](https://github.com/orgs/open-telemetry/teams/operator-ta-maintainers)):

- [Sebastian Poxhofer](https://github.com/secustor)

Emeritus Target Allocator Maintainers

- [Anthony Mirabella](https://github.com/Aneurysm9), AWS
- [Kristina Pathak](https://github.com/kristinapathak), Lightstep

Maintainers ([@open-telemetry/operator-maintainers](https://github.com/orgs/open-telemetry/teams/operator-maintainers)):

- [Jacob Aronoff](https://github.com/jaronoff97), Lightstep
Expand Down
28 changes: 28 additions & 0 deletions apis/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ type Java struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand Down Expand Up @@ -196,6 +200,10 @@ type NodeJS struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand All @@ -217,6 +225,10 @@ type Python struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand All @@ -238,6 +250,10 @@ type DotNet struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand All @@ -257,6 +273,10 @@ type Go struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand All @@ -278,6 +298,10 @@ type ApacheHttpd struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand Down Expand Up @@ -314,6 +338,10 @@ type Nginx struct {
// +optional
Image string `json:"image,omitempty"`

// VolumeClaimTemplate defines a ephemeral volume used for auto-instrumentation.
// If omitted, an emptyDir is used with size limit VolumeSizeLimit
VolumeClaimTemplate corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplate,omitempty"`

// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
// The default size is 200Mi.
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
Expand Down
38 changes: 38 additions & 0 deletions apis/v1alpha1/instrumentation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package v1alpha1
import (
"context"
"fmt"
"reflect"
"strconv"
"strings"

Expand Down Expand Up @@ -237,6 +238,36 @@ func (w InstrumentationWebhook) validate(r *Instrumentation) (admission.Warnings
return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type)
}

var err error
err = validateInstrVolume(r.Spec.ApacheHttpd.VolumeClaimTemplate, r.Spec.ApacheHttpd.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.apachehttpd.volumeClaimTemplate and spec.apachehttpd.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.DotNet.VolumeClaimTemplate, r.Spec.DotNet.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.dotnet.volumeClaimTemplate and spec.dotnet.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.Go.VolumeClaimTemplate, r.Spec.Go.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.go.volumeClaimTemplate and spec.go.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.Java.VolumeClaimTemplate, r.Spec.Java.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.java.volumeClaimTemplate and spec.java.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.Nginx.VolumeClaimTemplate, r.Spec.Nginx.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.nginx.volumeClaimTemplate and spec.nginx.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.NodeJS.VolumeClaimTemplate, r.Spec.NodeJS.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.nodejs.volumeClaimTemplate and spec.nodejs.volumeSizeLimit cannot both be defined: %w", err)
}
err = validateInstrVolume(r.Spec.Python.VolumeClaimTemplate, r.Spec.Python.VolumeSizeLimit)
if err != nil {
return warnings, fmt.Errorf("spec.python.volumeClaimTemplate and spec.python.volumeSizeLimit cannot both be defined: %w", err)
}

warnings = append(warnings, validateExporter(r.Spec.Exporter)...)

return warnings, nil
Expand Down Expand Up @@ -292,6 +323,13 @@ func validateJaegerRemoteSamplerArgument(argument string) error {
return nil
}

func validateInstrVolume(volumeClaimTemplate corev1.PersistentVolumeClaimTemplate, volumeSizeLimit *resource.Quantity) error {
if !reflect.ValueOf(volumeClaimTemplate).IsZero() && volumeSizeLimit != nil {
return fmt.Errorf("unable to resolve volume size")
}
return nil
}

func NewInstrumentationWebhook(logger logr.Logger, scheme *runtime.Scheme, cfg config.Config) *InstrumentationWebhook {
return &InstrumentationWebhook{
logger: logger,
Expand Down
21 changes: 21 additions & 0 deletions apis/v1alpha1/instrumentation_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ import (
"testing"

"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/open-telemetry/opentelemetry-operator/internal/config"
)

var defaultVolumeSize = resource.MustParse("200Mi")

func TestInstrumentationDefaultingWebhook(t *testing.T) {
inst := &Instrumentation{}
err := InstrumentationWebhook{
Expand Down Expand Up @@ -113,6 +117,23 @@ func TestInstrumentationValidatingWebhook(t *testing.T) {
},
},
},
{
name: "with volume and volumeSizeLimit",
err: "spec.nodejs.volumeClaimTemplate and spec.nodejs.volumeSizeLimit cannot both be defined",
inst: Instrumentation{
Spec: InstrumentationSpec{
NodeJS: NodeJS{
VolumeClaimTemplate: corev1.PersistentVolumeClaimTemplate{
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
},
},
VolumeSizeLimit: &defaultVolumeSize,
},
},
},
warnings: []string{"sampler type not set"},
},
{
name: "exporter: tls cert set but missing key",
inst: Instrumentation{
Expand Down
7 changes: 7 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 2d2827c

Please sign in to comment.