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

fix for initialisation of the kubernetes provider #4097

Closed
wants to merge 1 commit into from

Conversation

gizas
Copy link
Contributor

@gizas gizas commented Jan 18, 2024

  • Bug

What does this PR do?

The bug was identified here: #3346 (comment)
It addresses the correct initialisation of kubernetes provider when user in elastic-agent configures the
Sample of elastic-agent standalone configuraton manifest:

data:
  agent.yml: |-
    id: bea46550-8652-49e5-bfa2-7016cb60816c
    outputs:
      default:
        type: elasticsearch
        hosts:
          - 'https://elasticsearch:9200'
        username: '${ES_USERNAME}'
        password: '${ES_PASSWORD}'
    providers.kubernetes:
      node: ${NODE_NAME}
      add_resource_metadata:
        node: 
          enabled: false
        namespace:
          use_regex_include: true
          include_labels: ["pas"]

Why is it important?

It is important because this affects the correct initialisation of Kubernetes provider and finally affects the correct metadata enrichment of logs

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/fragments using the changelog tool
  • I have added an integration test or an E2E test

How to test this PR locally

  1. Clone code
  2. Build elastic-agent image according to https://github.com/elastic/elastic-agent#testing-elastic-agent-on-kubernetes
  3. Apply label in specific namespace: kubectl label namespace default pas2=pas
  4. Apply standalone elastic-agent with:
providers.kubernetes:
      node: ${NODE_NAME}
      add_resource_metadata:
        node: 
          enabled: false
        namespace:
          use_regex_include: true
          include_labels: ["pas"]
  1. Produce logs and verify that only namespace labels are present

Related issues

Screenshots

Screenshot 2024-01-18 at 4 37 38 PM

@gizas gizas self-assigned this Jan 18, 2024
Copy link
Contributor

mergify bot commented Jan 18, 2024

This pull request does not have a backport label. Could you fix it @gizas? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

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

NOTE: backport-skip has been added to this pull request.

@gizas
Copy link
Contributor Author

gizas commented Jan 18, 2024

We noticed that the *config.Config pointer of https://github.com/elastic/elastic-agent/blob/main/internal/pkg/composable/providers/kubernetes/kubernetes.go#L49 is not initialised correctly based on the add_resource_metadata configuration that users provide in their manifest

The unpack method should had trigger the InitDefaults() according to PR but the initialisation does not work

Copy link

Quality Gate failed Quality Gate failed

Failed conditions

0.0% 0.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@gizas
Copy link
Contributor Author

gizas commented Jan 22, 2024

Closing as tests confirmed that it is not a bug!!!!!!
Everything is working correct in versions >= 8.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant