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

Creating a 'cloudproviders' package #9738

Merged
merged 4 commits into from
Nov 10, 2021
Merged

Conversation

hush-hush
Copy link
Member

@hush-hush hush-hush commented Nov 3, 2021

What does this PR do?

The logic around cloudproviders is spread out all over the util package. This PR create a dedicated cloudproviders package.

Motivation

Make it easier to add new cloudproviders.

Additional Notes

Describe how to test your changes

Install the agent on different cloudproviders and test that tags and hostname are still well reported.

Ensure that cluster name detection is working, too.

Also test that the metadata payload (printed in the logs in debug log level) is the same.

Checklist

  • A release note has been added or the changelog/no-changelog label has been applied.
  • The need-change/operator and need-change/helm labels has been applied if applicable.
  • The appropriate team/.. label has been applied, if known.
  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • The config template has been updated if applicable.

Note: Adding GitHub labels is only possible for contributors with write access.

@hush-hush hush-hush added [deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead.. changelog/no-changelog labels Nov 3, 2021
@hush-hush hush-hush added this to the 7.33.0 milestone Nov 3, 2021
@hush-hush hush-hush requested review from a team as code owners November 3, 2021 10:03
@hush-hush hush-hush requested a review from a team November 3, 2021 10:03
@hush-hush hush-hush force-pushed the maxime/cloudproviders-package branch 3 times, most recently from 7d4de55 to 659bb42 Compare November 3, 2021 11:15
pkg/util/cloudproviders/cloudproviders.go Outdated Show resolved Hide resolved
pkg/otlp/model/attributes/azure/azure.go Outdated Show resolved Hide resolved
@@ -179,7 +179,7 @@ func GetHostnameData(ctx context.Context) (HostnameData, error) {
configHostnameFilepath := config.Datadog.GetString("hostname_file")
if configHostnameFilepath != "" {
log.Debug("GetHostname trying `hostname_file` config option...")
if fileHostnameProvider, found := hostname.ProviderCatalog["file"]; found {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to move this file to pkg/util/hostname?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would very much so. I started looking into it and the change was massive. I'll open another PR dedicated to this.

pkg/util/hostname/providers.go Outdated Show resolved Hide resolved
pkg/util/hostname/providers_test.go Outdated Show resolved Hide resolved
@hush-hush hush-hush force-pushed the maxime/cloudproviders-package branch from 659bb42 to 7538b9a Compare November 3, 2021 17:24
Copy link
Contributor

@sgnn7 sgnn7 left a comment

Choose a reason for hiding this comment

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

@hush-hush 2 tiny nits but LGTM. Great improvements all around!

pkg/util/hostname/providers.go Outdated Show resolved Hide resolved
pkg/util/hostname/providers.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ahmed-mez ahmed-mez left a comment

Choose a reason for hiding this comment

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

Mind adding a note in Describe how to test your changes about testing cluster name detection as well? thanks!

This includes for now Azure, Tencent and Alibaba providers. The goal is
to encapsulate all the cloud provider logic spread out in the util package.
@hush-hush hush-hush force-pushed the maxime/cloudproviders-package branch from 7538b9a to d1ee9ac Compare November 4, 2021 12:53
@djmitche
Copy link
Contributor

I'll rebase this shortly. The conflict is with one of my PRs (and Maxime is away).

@djmitche
Copy link
Contributor

It looks like the integration_tests failure is just an intermittent:

    cards_test.go:54: post: trace-agent not running

@djmitche djmitche merged commit b68228d into main Nov 10, 2021
@djmitche djmitche deleted the maxime/cloudproviders-package branch November 10, 2021 19:56
zandrewitte pushed a commit to StackVista/stackstate-agent that referenced this pull request Nov 17, 2022
The goal is to encapsulate all the cloud provider logic spread out in the util package.

Co-authored-by: Dustin J. Mitchell <dustin.mitchell@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog [deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead.. team/containers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants