Skip to content

Commit

Permalink
Merge pull request #113 from kube-logging/feat/make-commonfields-avai…
Browse files Browse the repository at this point in the history
…lable

feat: make commonfields available
  • Loading branch information
pepov authored Dec 6, 2024
2 parents 910ae7a + 2a99856 commit 99620c6
Show file tree
Hide file tree
Showing 11 changed files with 13,799 additions and 15,681 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Dockerfile.cross

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.html

# Kubernetes Generated files - skip generated files, except for vendored files

Expand Down
2 changes: 2 additions & 0 deletions api/telemetry/v1alpha1/bridge_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type BridgeSpec struct {
// The target tenant to which telemetry will be forwarded.
TargetTenant string `json:"targetTenant"`

// +kubebuilder:validation:Required

// The condition which must be satisfied in order to forward telemetry
// from the source tenant to the target tenant.
Condition string `json:"condition"`
Expand Down
20 changes: 12 additions & 8 deletions api/telemetry/v1alpha1/collector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1alpha1
import (
"time"

"github.com/cisco-open/operator-tools/pkg/typeoverride"
otelv1beta1 "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -49,8 +49,10 @@ type MemoryLimiter struct {

// CollectorSpec defines the desired state of Collector
type CollectorSpec struct {
// +kubebuilder:validation:Required

// TenantSelector is used to select tenants for which the collector should collect data.
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
TenantSelector metav1.LabelSelector `json:"tenantSelector"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable, please recreate the resource"
Expand All @@ -64,8 +66,8 @@ type CollectorSpec struct {
// Setting memory limits for the Collector using the memory limiter processor.
MemoryLimiter *MemoryLimiter `json:"memoryLimiter,omitempty"`

// DaemonSetOverrides is used to override the default DaemonSet configuration.
DaemonSetOverrides *typeoverride.DaemonSet `json:"daemonSet,omitempty"`
// OtelcommonFields is used to override the default DaemonSet's common fields.
OtelCommonFields *otelv1beta1.OpenTelemetryCommonFields `json:"otelCommonFields,omitempty"`
}

func (c *CollectorSpec) SetDefaults() {
Expand All @@ -76,14 +78,16 @@ func (c *CollectorSpec) SetDefaults() {
MemorySpikeLimitMiB: 25,
}
}
if c.OtelCommonFields == nil {
c.OtelCommonFields = &otelv1beta1.OpenTelemetryCommonFields{}
}
}

func (c CollectorSpec) GetMemoryLimit() *resource.Quantity {
if c.DaemonSetOverrides != nil && len(c.DaemonSetOverrides.Spec.Template.Spec.Containers) > 0 {
if memoryLimit := c.DaemonSetOverrides.Spec.Template.Spec.Containers[0].Resources.Limits.Memory(); !memoryLimit.IsZero() {
return memoryLimit
}
if c.OtelCommonFields.Resources.Requests != nil && c.OtelCommonFields.Resources.Limits != nil {
return c.OtelCommonFields.Resources.Limits.Memory()
}

return nil
}

Expand Down
11 changes: 11 additions & 0 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ type TimeoutSettings struct {
type QueueSettings struct {
// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
Enabled bool `json:"enabled,omitempty"`

// NumConsumers is the number of consumers from the queue.
NumConsumers int `json:"num_consumers,omitempty"`

// QueueSize is the maximum number of batches allowed in queue at a given time.
QueueSize int `json:"queue_size,omitempty"`

// StorageID if not empty, enables the persistent storage and uses the component specified
// as a storage extension for the persistent queue
StorageID string `json:"storage,omitempty"` //TODO this is *component.ID at Otel
Expand All @@ -45,16 +48,21 @@ type QueueSettings struct {
type BackOffConfig struct {
// Enabled indicates whether to not retry sending batches in case of export failure.
Enabled bool `json:"enabled,omitempty"`

// InitialInterval the time to wait after the first failure before retrying.
InitialInterval time.Duration `json:"initial_interval,omitempty"`

// RandomizationFactor is a random factor used to calculate next backoffs
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
RandomizationFactor string `json:"randomization_factor,omitempty"`

// Multiplier is the value multiplied by the backoff interval bounds
Multiplier string `json:"multiplier,omitempty"`

// MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between
// consecutive retries will always be `MaxInterval`.
MaxInterval time.Duration `json:"max_interval,omitempty"`

// MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch.
// Once this value is reached, the data is discarded. If set to 0, the retries are never stopped.
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty"`
Expand Down Expand Up @@ -129,8 +137,10 @@ type TLSClientSetting struct {
// https://godoc.org/crypto/tls#Config for more information.
// (optional, default false)
Insecure bool `json:"insecure,omitempty"`

// InsecureSkipVerify will enable TLS but not verify the certificate.
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`

// ServerName requested by client for virtual hosting.
// This sets the ServerName in the TLSConfig. Please refer to
// https://godoc.org/crypto/tls#Config for more information. (optional)
Expand Down Expand Up @@ -241,6 +251,7 @@ type HTTPClientConfig struct {
// HTTP2ReadIdleTimeout if the connection has been idle for the configured value send a ping frame for health check
// 0s means no health check will be performed.
HTTP2ReadIdleTimeout *time.Duration `json:"http2_read_idle_timeout,omitempty"`

// HTTP2PingTimeout if there's no response to the ping within the configured value, the connection will be closed.
// If not set or set to 0, it defaults to 15s.
HTTP2PingTimeout *time.Duration `json:"http2_ping_timeout,omitempty"`
Expand Down
7 changes: 3 additions & 4 deletions api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ type Fluentforward struct {
// DefaultLabelsEnabled is a map of default attributes to be added to each log record.
DefaultLabelsEnabled *map[string]bool `json:"default_labels_enabled,omitempty"`

QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`

Kubernetes *KubernetesMetadata `json:"kubernetes_metadata,omitempty"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
Kubernetes *KubernetesMetadata `json:"kubernetes_metadata,omitempty"`
}

type KubernetesMetadata struct {
Expand Down
8 changes: 4 additions & 4 deletions api/telemetry/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 99620c6

Please sign in to comment.