Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigCheck for aggregators #1747

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,17 @@ spec:
type: object
compressConfigFile:
type: boolean
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckAnnotations:
additionalProperties:
type: string
Expand Down
22 changes: 22 additions & 0 deletions charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4199,6 +4199,17 @@ spec:
type: object
compressConfigFile:
type: boolean
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckAnnotations:
additionalProperties:
type: string
Expand Down Expand Up @@ -12044,6 +12055,17 @@ spec:
type: string
type: object
type: object
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckPod:
properties:
activeDeadlineSeconds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ spec:
type: string
type: object
type: object
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckPod:
properties:
activeDeadlineSeconds:
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_fluentdconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,17 @@ spec:
type: object
compressConfigFile:
type: boolean
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckAnnotations:
additionalProperties:
type: string
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4199,6 +4199,17 @@ spec:
type: object
compressConfigFile:
type: boolean
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckAnnotations:
additionalProperties:
type: string
Expand Down Expand Up @@ -12044,6 +12055,17 @@ spec:
type: string
type: object
type: object
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckPod:
properties:
activeDeadlineSeconds:
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_syslogngconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ spec:
type: string
type: object
type: object
configCheck:
properties:
labels:
additionalProperties:
type: string
type: object
strategy:
type: string
timeoutSeconds:
type: integer
type: object
configCheckPod:
properties:
activeDeadlineSeconds:
Expand Down
7 changes: 3 additions & 4 deletions config/samples/configcheck-timeout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ kind: Logging
metadata:
name: all-to-file
spec:
configCheck:
strategy: StartWithTimeout
timeoutSeconds: 5
fluentd: {}
fluentd:
configCheck:
strategy: StartWithTimeout
controlNamespace: default
---
apiVersion: logging.banzaicloud.io/v1beta1
Expand Down
2 changes: 2 additions & 0 deletions controllers/logging/logging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

fluentdExternal, fluentdSpec := loggingResources.GetFluentd()
if fluentdSpec != nil {
logging.AggregatorLevelConfigCheck(fluentdSpec.ConfigCheck)
fluentdConfig, secretList, err := r.clusterConfigurationFluentd(loggingResources)
if err != nil {
// TODO: move config generation into Fluentd reconciler
Expand All @@ -203,6 +204,7 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

syslogNGExternal, syslogNGSpec := loggingResources.GetSyslogNGSpec()
if syslogNGSpec != nil {
logging.AggregatorLevelConfigCheck(syslogNGSPec.ConfigCheck)
syslogNGConfig, secretList, err := r.clusterConfigurationSyslogNG(loggingResources)
if err != nil {
// TODO: move config generation into Syslog-NG reconciler
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration/crds/v1beta1/fluentd_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ BufferStorageVolume is by default configured as PVC using FluentdPvcSpec [volume
### compressConfigFile (bool, optional) {#fluentdspec-compressconfigfile}


### configCheck (*ConfigCheck, optional) {#fluentdspec-configcheck}

Overrides the default logging level configCheck setup This field is not used directly, just copied over the field in the logging resource if defined


### configCheckAnnotations (map[string]string, optional) {#fluentdspec-configcheckannotations}


Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/crds/v1beta1/logging_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Default: "cluster.local."

### configCheck (ConfigCheck, optional) {#loggingspec-configcheck}

ConfigCheck settings that apply to both fluentd and syslog-ng
ConfigCheck settings that apply to both fluentd or syslog-ng Can be overridden on the fluentd / syslog-ng level


### controlNamespace (string, required) {#loggingspec-controlnamespace}
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration/crds/v1beta1/syslogng_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ SyslogNGSpec defines the desired state of SyslogNG
### bufferVolumeMetricsService (*typeoverride.Service, optional) {#syslogngspec-buffervolumemetricsservice}


### configCheck (*ConfigCheck, optional) {#syslogngspec-configcheck}

Overrides the default logging level configCheck setup This field is not used directly, just copied over the field in the logging resource if defined


### configCheckPod (*typeoverride.PodSpec, optional) {#syslogngspec-configcheckpod}


Expand Down
2 changes: 0 additions & 2 deletions pkg/resources/model/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ func (l LoggingResources) getSyslogNG() *v1beta1.SyslogNGConfig {
}

func (l LoggingResources) GetSyslogNGSpec() (*v1beta1.SyslogNGConfig, *v1beta1.SyslogNGSpec) {

if detachedSyslogNG := l.getSyslogNG(); detachedSyslogNG != nil {
return detachedSyslogNG, &detachedSyslogNG.Spec
}
return nil, l.Logging.Spec.SyslogNGSpec

}

type SyslogNGLoggingResources struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/sdk/logging/api/v1beta1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ type FluentdSpec struct {
// Available in Logging operator version 4.5 and later.
// Configure sidecar container in Fluentd pods, for example: [https://github.com/kube-logging/logging-operator/config/samples/logging_logging_fluentd_sidecars.yaml](https://github.com/kube-logging/logging-operator/config/samples/logging_logging_fluentd_sidecars.yaml).
SidecarContainers []corev1.Container `json:"sidecarContainers,omitempty"`
// Overrides the default logging level configCheck setup
pepov marked this conversation as resolved.
Show resolved Hide resolved
// This field is not used directly, just copied over the field in the logging resource if defined
pepov marked this conversation as resolved.
Show resolved Hide resolved
ConfigCheck *ConfigCheck `json:"configCheck,omitempty"`
}

// +kubebuilder:object:generate=true
Expand Down
20 changes: 16 additions & 4 deletions pkg/sdk/logging/api/v1beta1/logging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ type LoggingSpec struct {
SkipInvalidResources bool `json:"skipInvalidResources,omitempty"`
// Override generated config. This is a *raw* configuration string for troubleshooting purposes.
FlowConfigOverride string `json:"flowConfigOverride,omitempty"`
// ConfigCheck settings that apply to both fluentd and syslog-ng
// ConfigCheck settings that apply to both fluentd or syslog-ng
// Can be overridden on the fluentd / syslog-ng level
pepov marked this conversation as resolved.
Show resolved Hide resolved
ConfigCheck ConfigCheck `json:"configCheck,omitempty"`
// FluentbitAgent daemonset configuration.
// Deprecated, will be removed with next major version
Expand Down Expand Up @@ -198,16 +199,27 @@ func (l *Logging) SetDefaults() error {
return err
}
}
if l.Spec.ConfigCheck.TimeoutSeconds == 0 {
l.Spec.ConfigCheck.TimeoutSeconds = 10
}
l.configCheckDefaults()
if len(l.Status.SyslogNGConfigName) == 0 {
l.Spec.SyslogNGSpec.SetDefaults()
}

return nil
}

func (l *Logging) AggregatorLevelConfigCheck(check *ConfigCheck) {
if check != nil {
l.Spec.ConfigCheck = *check
l.configCheckDefaults()
}
}

func (l *Logging) configCheckDefaults() {
if l.Spec.ConfigCheck.TimeoutSeconds == 0 {
l.Spec.ConfigCheck.TimeoutSeconds = 10
}
}

func (logging *Logging) WatchAllNamespaces() bool {
watchNamespaces := logging.Spec.WatchNamespaces
nsLabelSelector := logging.Spec.WatchNamespaceSelector
Expand Down
4 changes: 3 additions & 1 deletion pkg/sdk/logging/api/v1beta1/syslogng_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ type SyslogNGSpec struct {
// Available in Logging operator version 4.5 and later.
// Create [custom log metrics for sources and outputs]({{< relref "/docs/examples/custom-syslog-ng-metrics.md" >}}).
SourceMetrics []filter.MetricsProbe `json:"sourceMetrics,omitempty"`
// TODO: option to turn on/off buffer volume PVC
// Overrides the default logging level configCheck setup
// This field is not used directly, just copied over the field in the logging resource if defined
pepov marked this conversation as resolved.
Show resolved Hide resolved
ConfigCheck *ConfigCheck `json:"configCheck,omitempty"`
}

//
Expand Down
10 changes: 10 additions & 0 deletions pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go

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

Loading