Skip to content

Commit

Permalink
Add .Spec.Agent.Log.OpenFilesLimit
Browse files Browse the repository at this point in the history
This is to match a change to the datadog helm chart [1] adding the same
option. This option sets the maximum number of logs files that the
Datadog Agent will tail up to.

[1] helm/charts#22347
  • Loading branch information
juliogreff committed Jul 9, 2020
1 parent b82a33e commit 22f0154
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deploy/crds/datadoghq.com_datadogagents_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,13 @@ spec:
description: 'Enable this to allow log collection for all containers.
ref: https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/#log-collection-setup'
type: boolean
openFilesLimit:
description: 'Set the maximum number of logs files that the
Datadog Agent will tail up to. Increasing this limit can increase
resource consumption of the Agent. ref: https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/#log-collection-setup
Default to 100'
format: int32
type: integer
podLogsPath:
description: This to allow log collection from pod log path.
Default to `/var/log/pods`
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/datadoghq/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
DDLogsEnabled = "DD_LOGS_ENABLED"
DDLogsConfigContainerCollectAll = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL"
DDLogsContainerCollectUsingFiles = "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE"
DDLogsConfigOpenFilesLimit = "DD_LOGS_CONFIG_OPEN_FILES_LIMIT"
DDDogstatsdOriginDetection = "DD_DOGSTATSD_ORIGIN_DETECTION"
DDDogstatsdPort = "DD_DOGSTATSD_PORT"
DDClusterAgentEnabled = "DD_CLUSTER_AGENT_ENABLED"
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/datadoghq/v1alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
defaultContainerLogsPath string = "/var/lib/docker/containers"
defaultPodLogsPath string = "/var/log/pods"
defaultLogsTempStoragePath string = "/var/lib/datadog-agent/logs"
defaultLogsOpenFilesLimit int32 = 100
defaultProcessEnabled bool = false
defaultMetricsProviderPort int32 = 8443
defaultClusterChecksEnabled bool = false
Expand Down Expand Up @@ -295,6 +296,10 @@ func IsDefaultedDatadogAgentSpecLog(log *LogSpec) bool {
return false
}

if log.OpenFilesLimit == nil {
return false
}

return true
}

Expand Down Expand Up @@ -568,6 +573,10 @@ func DefaultDatadogAgentSpecAgentLog(log *LogSpec) *LogSpec {
log.TempStoragePath = NewStringPointer(defaultLogsTempStoragePath)
}

if log.OpenFilesLimit == nil {
log.OpenFilesLimit = NewInt32Pointer(defaultLogsOpenFilesLimit)
}

return log
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/datadoghq/v1alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ type LogSpec struct {
//
// +optional
TempStoragePath *string `json:"tempStoragePath,omitempty"`

// Set the maximum number of logs files that the Datadog Agent will
// tail up to. Increasing this limit can increase resource consumption
// of the Agent.
// ref: https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/#log-collection-setup
// Default to 100
//
// +optional
OpenFilesLimit *int32 `json:"openFilesLimit,omitempty"`
}

// ProcessSpec contains the Process Agent configuration
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions pkg/apis/datadoghq/v1alpha1/zz_generated.openapi.go

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

4 changes: 4 additions & 0 deletions pkg/controller/datadogagent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func defaultEnvVars() []corev1.EnvVar {
Name: "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE",
Value: "true",
},
{
Name: "DD_LOGS_CONFIG_OPEN_FILES_LIMIT",
Value: "100",
},
{
Name: "DD_DOGSTATSD_ORIGIN_DETECTION",
Value: "false",
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/datadogagent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ func getEnvVarsForAgent(dda *datadoghqv1alpha1.DatadogAgent) ([]corev1.EnvVar, e
Name: datadoghqv1alpha1.DDLogsContainerCollectUsingFiles,
Value: strconv.FormatBool(*spec.Agent.Log.ContainerCollectUsingFiles),
},
{
Name: datadoghqv1alpha1.DDLogsConfigOpenFilesLimit,
Value: strconv.FormatInt(int64(*spec.Agent.Log.OpenFilesLimit), 10),
},
{
Name: datadoghqv1alpha1.DDDogstatsdOriginDetection,
Value: strconv.FormatBool(*spec.Agent.Config.Dogstatsd.DogstatsdOriginDetection),
Expand Down

0 comments on commit 22f0154

Please sign in to comment.