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

Bypass FQDN resolution in darwin tests #1296

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion pkg/extension/sumologicextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,13 @@ func addClientCredentials(req *http.Request, credentials accessCredentials) {
req.Header.Add("Authorization", authHeaderValue)
}

// TODO(ck): hostname allows the darwin tests to bypass fqdn.
var hostname = fqdn.FqdnHostname

// getHostname returns the host name consistently with the resource detection processor's defaults
// TODO: try to dynamically extract this from the resource processor in the pipeline
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to do what this comment says? i.e extract the hostname from the resource processor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I'd be surprised if extensions had a way to get processor state like that. I also doubt that'd be a productive way to go at least as far as tests are concerned. (i.e. setting up an entire pipeline with the resource detection processor configured to not use os instead of dns.)

Side note, I wager that processor has the same issue (when configured with dns)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that solution would assume that we'd be using the resource processor in the pipeline like below.

service:
  extensions:
    - sumologic
  pipelines:
    logs:
      receivers: 
        - tcplog
      processors:
        - resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rnishtala-sumo you okay with kicking this can down the road? Maybe noting that option in #1295

Copy link
Contributor

Choose a reason for hiding this comment

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

yes thats fine

func getHostname(logger *zap.Logger) (string, error) {
fqdnHostname, err := fqdn.FqdnHostname()
fqdnHostname, err := hostname()
if err == nil {
return fqdnHostname, nil
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/extension/sumologicextension/extension_darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package sumologicextension

import "os"

func init() {
// fqdn seems to hang running in github actions on darwin amd64. This
// bypasses it.
// https://github.com/SumoLogic/sumologic-otel-collector/issues/1295
hostname = os.Hostname
}