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

[8.16](backport #41636) [libbeat] fix: aws & openstack metadata conflict in add_cloud_metadata processor #41814

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 27, 2024

Proposed commit message

This PR fixes incorrect recognition of EC2/AWS cloud provider as Openstack. The root cause was the common metadata endpoints used by both AWS SDK & Openstack logic. And this happened when IMDSv2 is disabled in AWS.

I attempted to migrate Openstack logic to another metadata implementation. However, I did not manage to create a fully functioning setup to validate the implementation. Hence, this PR focuses on a priority-based solution where priority is given for SDK-backed metadata fetching over HTTP endpoints.

Current priory providers are - aws/ec2 & azure

Note - I have done a minor refactoring to rename Local struct property to DefaultEnabled to make intention clearer

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.

How to test this PR locally

You need a local copy and an EC2 instance to validate the fix.

  • Enable metadata service in EC2 instance and make IMDSv2 optional
  • Build a beats (ex:- metricbeat) module based on this libbeat change
  • Copy the beats module to EC2 instance and start the module with add_cloud_metadata processor enabled & logs set to debug for more in-depth logs & no provider enforced
  • Observe logs and see data (ex:- system monitoring) through Kibana to validate cloud provider detection

Related issues

Screenshots

-IMDSv2 disabled

Screenshot 2024-11-13 at 11 45 38 AM

  • Processor enabled but no provider enforced

Screenshot 2024-11-13 at 11 50 24 AM

  • Debug logs on multi-result and priority based selection

Screenshot 2024-11-13 at 11 44 47 AM

  • Cloud provider detected correctly,

Screenshot 2024-11-13 at 11 45 13 AM


This is an automatic backport of pull request #41636 done by [Mergify](https://mergify.com).

@mergify mergify bot added the backport label Nov 27, 2024
@mergify mergify bot requested a review from a team as a code owner November 27, 2024 15:31
@mergify mergify bot added the conflicts There is a conflict in the backported pull request label Nov 27, 2024
Copy link
Contributor Author

mergify bot commented Nov 27, 2024

Cherry-pick of 6d4e641 has failed:

On branch mergify/bp/8.16/pr-41636
Your branch is up to date with 'origin/8.16'.

You are currently cherry-picking commit 6d4e64159b.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   CHANGELOG.next.asciidoc
	modified:   libbeat/processors/add_cloud_metadata/docs/add_cloud_metadata.asciidoc
	modified:   libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go
	modified:   libbeat/processors/add_cloud_metadata/provider_aws_ec2.go
	modified:   libbeat/processors/add_cloud_metadata/provider_azure_vm.go
	modified:   libbeat/processors/add_cloud_metadata/provider_digital_ocean.go
	modified:   libbeat/processors/add_cloud_metadata/provider_google_gce.go
	modified:   libbeat/processors/add_cloud_metadata/provider_hetzner_cloud.go
	modified:   libbeat/processors/add_cloud_metadata/provider_openstack_nova.go
	modified:   libbeat/processors/add_cloud_metadata/provider_tencent_cloud.go
	modified:   libbeat/processors/add_cloud_metadata/providers_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   libbeat/processors/add_cloud_metadata/providers.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 27, 2024
…a processor (#41636)

* rename misleading variable

Signed-off-by: Kavindu Dodanduwa <[email protected]>

* introduce provider priority

Signed-off-by: Kavindu Dodanduwa <[email protected]>

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

* isolate priority logic and add testing

Signed-off-by: Kavindu Dodanduwa <[email protected]>

* documentation

Signed-off-by: Kavindu Dodanduwa <[email protected]>

* review changes

Signed-off-by: Kavindu Dodanduwa <[email protected]>

---------

Signed-off-by: Kavindu Dodanduwa <[email protected]>
(cherry picked from commit 6d4e641)

# Conflicts:
#	libbeat/processors/add_cloud_metadata/providers.go
@Kavindu-Dodan Kavindu-Dodan force-pushed the mergify/bp/8.16/pr-41636 branch from c865b3d to 17ec059 Compare November 27, 2024 15:44
@Kavindu-Dodan Kavindu-Dodan enabled auto-merge (squash) November 27, 2024 16:03
@Kavindu-Dodan Kavindu-Dodan added Team:obs-ds-hosted-services Label for the Observability Hosted Services team and removed needs_team Indicates that the issue/PR needs a Team:* label conflicts There is a conflict in the backported pull request labels Nov 27, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@Kavindu-Dodan Kavindu-Dodan merged commit 840aa34 into 8.16 Nov 27, 2024
142 checks passed
@Kavindu-Dodan Kavindu-Dodan deleted the mergify/bp/8.16/pr-41636 branch November 27, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants