Skip to content

Conversation

@emilioalvap
Copy link
Contributor

@emilioalvap emilioalvap commented Aug 4, 2023

What does this PR do?

Closes elastic/fleet-server#1754. Add environment variable to agent complete image and add it to agent metada.

Why is it important?

We need a mechanism to detect if the agent enrolled is a -complete image in Synthetics to show early warnings which the spec does not provide.

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. Build agent docker images locally.
  2. Enroll both an elastic-agent and elastic-agent-complete containers on a policy.
  3. Check both agents metadata for complete flag:
//complete
 "local_metadata": {
    "elastic": {
        ...,
        "complete": true,
      }
    },
}
//vs non-complete
 "local_metadata": {
    "elastic": {
      "agent": {
        ...,
        "complete": false,
      }
    },
}

@emilioalvap emilioalvap added enhancement New feature or request Team:Uptime Label for the Uptime team labels Aug 4, 2023
@emilioalvap emilioalvap requested a review from cmacknz August 4, 2023 09:22
@emilioalvap emilioalvap requested a review from a team as a code owner August 4, 2023 09:22
@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2023

This pull request does not have a backport label. Could you fix it @emilioalvap? 🙏
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.

@mergify mergify bot added the backport-skip label Aug 4, 2023
@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 4, 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-08-08T14:17:44.694+0000

  • Duration: 63 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 6209
Skipped 31
Total 6240

💚 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.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

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

@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2023

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b agent-complete-local-metadata upstream/agent-complete-local-metadata
git merge upstream/main
git push upstream agent-complete-local-metadata

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 4, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.734% (78/79) 👍
Files 66.549% (189/284) 👍
Classes 65.399% (344/526) 👍
Methods 52.233% (1076/2060) 👎 -0.025
Lines 38.346% (12321/32131) 👎 -0.005
Conditionals 100.0% (0/0) 💚

@emilioalvap
Copy link
Contributor Author

/test

@emilioalvap
Copy link
Contributor Author

/test

@cmacknz cmacknz requested a review from blakerouse August 4, 2023 20:18
kind: enhancement

# Change summary; a 80ish characters long description of the change.
summary: Add complete image to agent metadata.
Copy link
Contributor

Choose a reason for hiding this comment

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

When a customer reads the changelog what does this mean to them? Maybe some more information on why this is done would be better.

}

// VersionInfo is structure used by `version --yaml`.
type VersionInfo struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this information be added to the VersionInfo? That is the information that is exposed from the elastic-agent version command line. Is that information important to know there? Being that we want to let fleet know seems like its important. That information would then be provided in diagnostics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it would make sense to include it from the synthetics pov. For us, this is telling us that a given agent is running inside Docker with synthetics deps bundled. For us having ELASTIC_AGENT_COMPLETE: "true" on the diagnostics file is a direct correlation so no need to display it on the version. But I can add it if you think it'll add value

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that it is only for synthetics and inside of a container. How will the information that its a complete image get into the diagnostics zip archive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diagnostics includes the agent environment:

env:
    BEAT_SETUID_AS: elastic-agent
    ELASTIC_AGENT_COMPLETE: "true"

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, sounds good.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Please update the changelog before merging, otherwise looks good!

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

Labels

backport-skip enhancement New feature or request Team:Uptime Label for the Uptime team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend local_meta information for elastic agent

3 participants