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

[add_cloud_metadata processor] add cloud.region field to GCE cloud provider #35300

Merged

Conversation

tetianakravchenko
Copy link
Contributor

What does this PR do?

Add cloud.region field to GCE cloud provider

Why is it important?

To align with other cloud providers

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Before:
Screenshot 2023-05-03 at 12 08 43

After:
Screenshot 2023-05-03 at 12 16 08

Logs

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
@tetianakravchenko tetianakravchenko requested a review from a team as a code owner May 3, 2023 10:21
@tetianakravchenko tetianakravchenko requested review from faec and leehinman and removed request for a team May 3, 2023 10:21
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 3, 2023
@botelastic
Copy link

botelastic bot commented May 3, 2023

This pull request doesn't have a Team:<team> label.

@mergify
Copy link
Contributor

mergify bot commented May 3, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @tetianakravchenko? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@@ -82,6 +94,10 @@ var gceMetadataFetcher = provider{
}.ApplyTo(cloud, instance)
trimLeadingPath("machine.type")
trimLeadingPath("availability_zone")

if zone := getValue("availability_zone"); len(zone) >= 2 {
Copy link
Member

Choose a reason for hiding this comment

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

May you clarify what 2 means in this context? My understanding is that zone is a string, there is no region information available and we are extracting the region from the zone by removing the last 2 characters.

This works as zones in GCP are <region>-<zone> (docs) but to my knowledge <zone> is not guaranteed to be a single character.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@endorama you are right, I assumed it from the list of available regions/zones, but I couldn't find naming convention for that.
I've updated implementation - cd04fee

Copy link
Member

Choose a reason for hiding this comment

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

awesome 😃

@elasticmachine
Copy link
Collaborator

elasticmachine commented May 3, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-05-03T13:03:29.393+0000

  • Duration: 67 min 41 sec

Test stats 🧪

Test Results
Failed 0
Passed 26297
Skipped 1975
Total 28272

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

…ter '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
@tetianakravchenko tetianakravchenko added backport-7.17 Automated backport to the 7.17 branch with mergify backport-v8.7.0 Automated backport with mergify backport-v8.8.0 Automated backport with mergify labels May 5, 2023
@tetianakravchenko tetianakravchenko merged commit 42ca469 into elastic:main May 5, 2023
@tetianakravchenko tetianakravchenko deleted the add_cloud_metadata-processor branch May 5, 2023 11:12
mergify bot pushed a commit that referenced this pull request May 5, 2023
…ovider (#35300)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)
mergify bot pushed a commit that referenced this pull request May 5, 2023
…ovider (#35300)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)
mergify bot pushed a commit that referenced this pull request May 5, 2023
…ovider (#35300)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)

# Conflicts:
#	libbeat/processors/add_cloud_metadata/provider_google_gce_test.go
tetianakravchenko added a commit that referenced this pull request May 5, 2023
…ovider (#35300) (#35346)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)

Co-authored-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
tetianakravchenko added a commit that referenced this pull request May 5, 2023
…ovider (#35300) (#35347)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)

Co-authored-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
tetianakravchenko added a commit that referenced this pull request May 5, 2023
…on field to GCE cloud provider (#35345)

* [add_cloud_metadata processor] add cloud.region field to GCE cloud provider (#35300)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 42ca469)

# Conflicts:
#	libbeat/processors/add_cloud_metadata/provider_google_gce_test.go

* Update CHANGELOG.next.asciidoc

* Update provider_google_gce_test.go

---------

Co-authored-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
…ovider (#35300)

* add cloud.region field for GCE cloud provider

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

* instead of relyin on assumed length of <zone>, remove last element after '-' separators

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>

---------

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
@reakaleek reakaleek mentioned this pull request Jul 19, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.17 Automated backport to the 7.17 branch with mergify backport-v8.7.0 Automated backport with mergify backport-v8.8.0 Automated backport with mergify needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants