Skip to content

Commit

Permalink
Merge pull request #2203 from jcantrill/log4597
Browse files Browse the repository at this point in the history
LOG-4597: modify vector buffer and request to have mostly parity with…
  • Loading branch information
openshift-ci[bot] committed Oct 12, 2023
2 parents 60634f1 + 322bab0 commit 5c201a9
Show file tree
Hide file tree
Showing 36 changed files with 620 additions and 108 deletions.
2 changes: 1 addition & 1 deletion apis/logging/v1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ type Http struct {

// Timeout specifies the Http request timeout in seconds. If not set, 10secs is used.
// +optional
Timeout string `json:"timeout,omitempty"`
Timeout int `json:"timeout,omitempty"`

// Method specifies the Http method to be used for sending logs. If not set, 'POST' is used.
// +kubebuilder:validation:Enum:=GET;HEAD;POST;PUT;DELETE;OPTIONS;TRACE;PATCH
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/clusterlogging.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ metadata:
certified: "false"
console.openshift.io/plugins: '["logging-view-plugin"]'
containerImage: quay.io/openshift-logging/cluster-logging-operator:latest
createdAt: "2023-10-11T17:54:55Z"
createdAt: "2023-10-12T13:12:40Z"
description: The Red Hat OpenShift Logging Operator for OCP provides a means for
configuring and managing your aggregated logging stack.
olm.skipRange: '>=5.6.0-0 <5.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ spec:
timeout:
description: Timeout specifies the Http request timeout
in seconds. If not set, 10secs is used.
type: string
type: integer
type: object
kafka:
description: 'Kafka provides optional extra properties for `type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ spec:
timeout:
description: Timeout specifies the Http request timeout
in seconds. If not set, 10secs is used.
type: string
type: integer
type: object
kafka:
description: 'Kafka provides optional extra properties for `type:
Expand Down
6 changes: 3 additions & 3 deletions internal/generator/fluentd/output/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var _ = Describe("Generate fluentd config", func() {
Name: "http-receiver",
URL: "https://my-logstore.com/logs/app-logs",
OutputTypeSpec: v1.OutputTypeSpec{Http: &v1.Http{
Timeout: "50",
Timeout: 50,
Headers: map[string]string{
"k1": "v1",
"k2": "v2",
Expand Down Expand Up @@ -170,7 +170,7 @@ var _ = Describe("Generate fluentd config", func() {
Name: "http-receiver",
URL: "https://my-logstore.com/logs/app-logs",
OutputTypeSpec: v1.OutputTypeSpec{Http: &v1.Http{
Timeout: "50",
Timeout: 50,
Headers: map[string]string{
"k1": "v1",
"k2": "v2",
Expand Down Expand Up @@ -253,7 +253,7 @@ var _ = Describe("Generate fluentd config", func() {
Name: "http-receiver",
URL: "https://my-logstore.com/logs/app-logs",
OutputTypeSpec: v1.OutputTypeSpec{Http: &v1.Http{
Timeout: "50",
Timeout: 50,
Headers: map[string]string{
"Content-Type": "application/json",
"k1": "v1",
Expand Down
29 changes: 29 additions & 0 deletions internal/generator/helpers/optional_pair.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package helpers

import (
"fmt"
"reflect"
)

type OptionalPair struct {
key string
Value interface{}
}

func NewOptionalPair(key string, value interface{}) OptionalPair {
return OptionalPair{
key,
value,
}
}

func (op OptionalPair) String() string {
if op.Value == nil {
return ""
}
format := "%s = %v"
if reflect.TypeOf(op.Value).Kind() == reflect.String {
format = "%s = %q"
}
return fmt.Sprintf(format, op.key, op.Value)
}
34 changes: 34 additions & 0 deletions internal/generator/helpers/optional_pair_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package helpers

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("OptionalPair", func() {
Context("#Template", func() {
var (
pair OptionalPair
)
It("should return an empty template when the value is nil", func() {
pair = NewOptionalPair("abc", nil)
Expect(pair.String()).To(BeEmpty())
})
It("should return a formatted string config when value is a string", func() {
pair = NewOptionalPair("abc", "xyz")
Expect(pair.String()).To(Equal(`abc = "xyz"`))
})
It("should return a formatted numerical config when value is an int", func() {
pair = NewOptionalPair("abc", 123)
Expect(pair.String()).To(Equal(`abc = 123`))
})
It("should return a formatted bool config when value is bool", func() {
pair = NewOptionalPair("abc", true)
Expect(pair.String()).To(Equal(`abc = true`))
})
It("should return a formatted false bool config when value is bool", func() {
pair = NewOptionalPair("abc", false)
Expect(pair.String()).To(Equal(`abc = false`))
})
})
})
13 changes: 13 additions & 0 deletions internal/generator/helpers/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package helpers

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestSuite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "[internal][generator][helpers] Suite")
}
3 changes: 3 additions & 0 deletions internal/generator/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func ToHeaderStr(h map[string]string, formatStr string) string {
if len(h) == 0 {
return ""
}
sortedKeys := make([]string, len(h))
i := 0
for k := range h {
Expand Down
9 changes: 0 additions & 9 deletions internal/generator/vector/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ var _ = Describe("Testing Complete Config Generation", func() {
Options: generator.Options{
generator.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil),
},
CLSpec: logging.CollectionSpec{
Fluentd: &logging.FluentdForwarderSpec{
Buffer: &logging.FluentdBufferSpec{
ChunkLimitSize: "8m",
TotalLimitSize: "800000000",
OverflowAction: "throw_exception",
},
},
},
CLFSpec: logging.ClusterLogForwarderSpec{
Inputs: []logging.InputSpec{
{
Expand Down
3 changes: 3 additions & 0 deletions internal/generator/vector/conf_test/complex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ topic = "topic"
codec = "json"
timestamp_format = "rfc3339"

[sinks.kafka_receiver.buffer]
when_full = "drop_newest"

[sinks.kafka_receiver.tls]
enabled = true
min_tls_version = "VersionTLS12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ topic = "topic"
codec = "json"
timestamp_format = "rfc3339"

[sinks.kafka_receiver.buffer]
when_full = "drop_newest"

[sinks.kafka_receiver.tls]
enabled = true
min_tls_version = "VersionTLS12"
Expand Down
17 changes: 15 additions & 2 deletions internal/generator/vector/conf_test/complex_es_no_ver.toml
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,16 @@ endpoints = ["https://es-1.svc.messaging.cluster.local:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648
id_key = "_id"
api_version = "v6"

[sinks.es_1.buffer]
when_full = "drop_newest"

[sinks.es_1.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.es_1.tls]
min_tls_version = "VersionTLS12"
ciphersuites = "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,DHE-RSA-AES128-GCM-SHA256,DHE-RSA-AES256-GCM-SHA384"
Expand Down Expand Up @@ -535,10 +541,17 @@ endpoints = ["https://es-2.svc.messaging.cluster.local:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648

id_key = "_id"
api_version = "v6"

[sinks.es_2.buffer]
when_full = "drop_newest"

[sinks.es_2.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.es_2.tls]
min_tls_version = "VersionTLS12"
ciphersuites = "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,DHE-RSA-AES128-GCM-SHA256,DHE-RSA-AES256-GCM-SHA384"
Expand Down
24 changes: 21 additions & 3 deletions internal/generator/vector/conf_test/complex_es_v6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,16 @@ endpoints = ["https://elasticsearch:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648
id_key = "_id"
api_version = "v6"

[sinks.default.buffer]
when_full = "drop_newest"

[sinks.default.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.default.tls]
key_file = "/var/run/ocp-collector/secrets/collector/tls.key"
crt_file = "/var/run/ocp-collector/secrets/collector/tls.crt"
Expand Down Expand Up @@ -537,10 +543,16 @@ endpoints = ["https://es-1.svc.messaging.cluster.local:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648
id_key = "_id"
api_version = "v6"

[sinks.es_1.buffer]
when_full = "drop_newest"

[sinks.es_1.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.es_1.tls]
min_tls_version = "VersionTLS12"
ciphersuites = "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,DHE-RSA-AES128-GCM-SHA256,DHE-RSA-AES256-GCM-SHA384"
Expand Down Expand Up @@ -655,10 +667,16 @@ endpoints = ["https://es-2.svc.messaging.cluster.local:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648
id_key = "_id"
api_version = "v8"

[sinks.es_2.buffer]
when_full = "drop_newest"

[sinks.es_2.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.es_2.tls]
min_tls_version = "VersionTLS12"
ciphersuites = "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,DHE-RSA-AES128-GCM-SHA256,DHE-RSA-AES256-GCM-SHA384"
Expand Down
4 changes: 4 additions & 0 deletions internal/generator/vector/conf_test/complex_otel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ method = "post"
[sinks.http_receiver.encoding]
codec = "json"

[sinks.http_receiver.buffer]
when_full = "drop_newest"

[sinks.http_receiver.request]
retry_attempts = 17
timeout_secs = 10
headers = {"h1"="v1","h2"="v2"}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,16 @@ endpoints = ["https://es-1.svc.messaging.cluster.local:9200"]
bulk.index = "{{ write_index }}"
bulk.action = "create"
encoding.except_fields = ["write_index"]
request.timeout_secs = 2147483648
id_key = "_id"
api_version = "v6"

[sinks.es_1.buffer]
when_full = "drop_newest"

[sinks.es_1.request]
retry_attempts = 17
timeout_secs = 2147483648

[sinks.es_1.tls]
min_tls_version = "VersionTLS12"
ciphersuites = "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-CHACHA20-POLY1305,ECDHE-RSA-CHACHA20-POLY1305,DHE-RSA-AES128-GCM-SHA256,DHE-RSA-AES256-GCM-SHA384"
Expand Down
3 changes: 3 additions & 0 deletions internal/generator/vector/elements/keyval.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ func (kv KeyVal) Name() string {
}

func (kv KeyVal) Template() string {
if kv.Val == "" {
return `{{define "` + kv.Name() + `" -}}{{end -}}`
}
return `{{define "` + kv.Name() + `" -}}
{{.Key}} = {{.Val}}
{{end -}}`
Expand Down
24 changes: 24 additions & 0 deletions internal/generator/vector/output/buffer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package output

type Buffer struct {
ComponentID string
WhenFull string
}

func NewBuffer(id string) Buffer {
return Buffer{
ComponentID: id,
WhenFull: "drop_newest",
}
}

func (b Buffer) Name() string {
return "buffer"
}

func (b Buffer) Template() string {
return `{{define "` + b.Name() + `" -}}
[sinks.{{.ComponentID}}.buffer]
when_full = "{{.WhenFull}}"
{{end}}`
}

0 comments on commit 5c201a9

Please sign in to comment.