Skip to content

Commit

Permalink
LOG-4184: fix config forwarding to default Loki using vector
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
  • Loading branch information
vparfonov committed Jun 2, 2023
1 parent 64bdbfb commit 728a011
Show file tree
Hide file tree
Showing 2 changed files with 479 additions and 275 deletions.
14 changes: 8 additions & 6 deletions internal/generator/vector/output/loki/loki.go
Expand Up @@ -2,6 +2,7 @@ package loki

import (
"fmt"
"github.com/openshift/cluster-logging-operator/internal/generator/url"
"strings"

"github.com/openshift/cluster-logging-operator/internal/generator/vector/helpers"
Expand Down Expand Up @@ -193,20 +194,21 @@ func TLSConf(o logging.OutputSpec, secret *corev1.Secret) []Element {
conf := []Element{}

hasTLS := false
u, _ := url.Parse(o.URL)
conf = append(conf, security.TLSConf{
ComponentID: strings.ToLower(vectorhelpers.Replacer.Replace(o.Name)),
InsecureSkipVerify: o.TLS != nil && o.TLS.InsecureSkipVerify,
})

if o.Name == logging.OutputNameDefault || security.HasTLSCertAndKey(secret) {
if o.Secret != nil && (o.Name == logging.OutputNameDefault || security.HasTLSCertAndKey(secret)) {
hasTLS = true
kc := TLSKeyCert{
CertPath: security.SecretPath(o.Secret.Name, constants.ClientCertKey),
KeyPath: security.SecretPath(o.Secret.Name, constants.ClientPrivateKey),
}
conf = append(conf, kc)
}
if o.Name == logging.OutputNameDefault || security.HasCABundle(secret) {
if o.Secret != nil && (o.Name == logging.OutputNameDefault || security.HasCABundle(secret)) {
hasTLS = true
ca := CAFile{
CAFilePath: security.SecretPath(o.Secret.Name, constants.TrustedCABundleKey),
Expand All @@ -216,10 +218,7 @@ func TLSConf(o logging.OutputSpec, secret *corev1.Secret) []Element {
if o.TLS != nil && o.TLS.InsecureSkipVerify {
hasTLS = true
}
if !hasTLS {
return []Element{}
}
if o.Secret == nil && secret != nil {
if o.Secret == nil && secret != nil && url.IsTLSScheme(u.Scheme) {
// Set CA from logcollector ServiceAccount for internal Loki
return []Element{
security.TLSConf{
Expand All @@ -230,6 +229,9 @@ func TLSConf(o logging.OutputSpec, secret *corev1.Secret) []Element {
},
}
}
if !hasTLS {
return []Element{}
}
return conf
}

Expand Down

0 comments on commit 728a011

Please sign in to comment.