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

LOG-4852: Vector collector Pods no longer picks up the log collector SAs Secret as a fallback #2284

Merged
merged 1 commit into from Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions internal/generator/vector/output/loki/loki.go
Expand Up @@ -2,9 +2,10 @@ package loki

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

"github.com/openshift/cluster-logging-operator/internal/generator/vector/output"

"github.com/openshift/cluster-logging-operator/internal/generator/vector/helpers"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/normalize"

Expand Down Expand Up @@ -206,26 +207,34 @@ func Tenant(l *logging.Loki) Element {
}

func TLSConf(o logging.OutputSpec, secret *corev1.Secret, op Options) []Element {
conf := []Element{}
if isDefaultOutput(o.Name) {
// Set CA from logcollector ServiceAccount for internal Loki
tlsConf := security.TLSConf{
ComponentID: strings.ToLower(vectorhelpers.Replacer.Replace(o.Name)),
CAFilePath: `"/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"`,
}
tlsConf.SetTLSProfileFromOptions(op)
return []Element{
tlsConf,
}
return append(conf, tlsConf)
}

if o.Secret != nil || (o.TLS != nil && o.TLS.InsecureSkipVerify) {

if tlsConf := security.GenerateTLSConf(o, secret, op, false); tlsConf != nil {
tlsConf.NeedsEnabled = false
return []Element{tlsConf}
conf = append(conf, tlsConf)
}
} else if secret != nil {
// Use secret of logcollector service account as backup
tlsConf := security.TLSConf{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic is missing something here because it's not using any of the helper functions.

  • What if my secret defines a CA to use?
  • What if I define a secret ... but I don't get any TLS Profile options here

Following "GenerateTLSConf" leads me to think it still nees to utilize that function... and then check the CA afterwards and set it like this if not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first if statement is looking for output.secret so if a user defines a secret for the output, it will be caught there. Your questions above pertain to that bit.

Line 221

if o.Secret != nil {
...
}

I'm not changing any of the original functionality as this is only using the logcollector secret as a fallback if a user does not define a secret for the output. The secret here isn't the one that is defined for the output. It is the secret automatically populated for the legacy case (constants.LogCollectorToken).

ComponentID: strings.ToLower(vectorhelpers.Replacer.Replace(o.Name)),
CAFilePath: `"/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"`,
}
tlsConf.SetTLSProfileFromOptions(op)
conf = append(conf, tlsConf)
}

return []Element{}
return conf
}

func isDefaultOutput(name string) bool {
Expand Down