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

[Heartbeat] Build elastic agent with synthetics support / offline mode #27052

Merged
merged 15 commits into from
Aug 11, 2021

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Jul 27, 2021

Creates a new offline tagged docker image that includes the dependencies required for synthetics. Building elastic-agent docker images will now create additional -offline tagged images with these extras. We may need to do additional work to ensure that these additional images are incorporated into the release process and onto the public website.

These changes also set the ELASTIC_SYNTHETICS_CAPABLE env flag, as done in heartbeat, to enable synthetics features in the docker environment. This dovetails with the work @dominiqueclarke is doing in elastic/integrations#1064 and elsewhere

Fixes #22932

CC @ruflin @v1v @mostlyjason @drewpost @vigneshshanmugam @dominiqueclarke

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

TODO: Test this with the upcoming synthetics support in integrations (see elastic/integrations#1064)

@andrewvc andrewvc added enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.15.0 labels Jul 27, 2021
@andrewvc andrewvc self-assigned this Jul 27, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime (Team:Uptime)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 27, 2021
@andrewvc andrewvc marked this pull request as draft July 27, 2021 03:10
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 27, 2021

💚 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: 2021-08-10T20:09:47.259+0000

  • Duration: 214 min 21 sec

  • Commit: 3fa0117

Test stats 🧪

Test Results
Failed 0
Passed 52978
Skipped 5318
Total 58296

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 52978
Skipped 5318
Total 58296

@paulb-elastic
Copy link
Contributor

Linking to #26398

@mostlyjason
Copy link

I see a checkbox for documentation. We documented the docker container here elastic/observability-docs#622. Can you add content for the offline mode or at least create an issue to track adding the docs?

@andrewvc andrewvc changed the title [Heartbeat] Build elasttic agent with synthetics support / offline mode [Heartbeat] Build elastic agent with synthetics support / offline mode Jul 27, 2021
@ruflin
Copy link
Member

ruflin commented Jul 28, 2021

As a first step I think the most important part is that it does not affect the current build we have. Would be good to validate this with a package build. I did not test it locally or go into the detail about overall LGTM.

@andrewkroh @blakerouse Could you take a closer look at this as you are more familiar with the agent docker configs and the build system overall and might spot some side effects of this?

@@ -58,6 +59,11 @@ func newDockerBuilder(spec PackageSpec) (*dockerBuilder, error) {
}

func (b *dockerBuilder) Build() error {
variants := []string{""}
if os.Getenv("OFFLINE_DOCKER_IMAGE") == "true" || b.ServiceName == "elastic-agent" {
Copy link
Member

Choose a reason for hiding this comment

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

We should document this somewhere in the Beats repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a place we already document similar things? It's my understanding that we don't have such a place. I'd be glad to document it, my only question is where?

Copy link
Member

Choose a reason for hiding this comment

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

I started to put things into elastic agent readme: https://github.com/elastic/beats/tree/master/x-pack/elastic-agent Lets put it there so we have it and can figure out a better place later.

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've since removed this and replaced it in the package spec, where it has an explanatory comment. I've also added a note to the README you mentioned about the behavior of the package spec.

@paulb-elastic
Copy link
Contributor

I see a checkbox for documentation. We documented the docker container here elastic/observability-docs#622. Can you add content for the offline mode or at least create an issue to track adding the docs?

@mostlyjason we have this captured in elastic/observability-docs#663 (I've added a reference to the existing docs page you mentioned)

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

If there is an "offline" image available I would expect it to include other artifacts that are not currently bundled with Agent like osquerybeat. Do others have this expectation? Should we add that as well?

@@ -58,6 +59,11 @@ func newDockerBuilder(spec PackageSpec) (*dockerBuilder, error) {
}

func (b *dockerBuilder) Build() error {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem like the right place for any project specific build options. IIRC this code path doesn't have knowledge of elastic-agent at all.

If there are new artifacts that the Elastic Agent build should produce those should be defined in a package spec YAML (elastic-agent appears to be adding artifacts to the https://github.com/elastic/beats/blob/master/dev-tools/packaging/packages.yml#L938-L939).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

dev-tools/mage/dockerbuilder.go Outdated Show resolved Hide resolved
@ruflin
Copy link
Member

ruflin commented Aug 4, 2021

@andrewkroh ++ on your proposal that the "offline" image contains "all" of it.

andrewvc and others added 2 commits August 10, 2021 07:20
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
@andrewvc
Copy link
Contributor Author

My latest push removes the assigning of ExtraVars and fixes env var assignment, which was incorrectly before a docker FROM statement.

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -6,6 +6,10 @@
# the final image because of permission changes.
FROM {{ .buildFrom }} AS home

# Contains the elastic agent image variant, an empty string for the standard variant
# or "offline" for the offline one.
ENV ELASTIC_AGENT_IMAGE_VARIANT={{.Variant}}
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about omitting this from the environment when .Variant is empty?

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'm neutral on it. I do kind of like having it empty because it makes it maybe more explicit that this is the "" variant.

Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this particular variable does nothing but reporting the docker image is a variant? If so, maybe the docker metadata attributes could be a better approach?

@andrewvc andrewvc requested a review from a team as a code owner August 10, 2021 20:05
Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Code change LGTM. Only one part I'm not sure how it is related.

I assume you did a full package run to see if things still work as expected? Lets make sure as soon as we get this in we keep an eye on the builds to make sure these still pass.

For the publishing of the images, I assume some additional work in the release manager will be needed?

@@ -122,9 +122,9 @@ func (je *journeyEnricher) enrichSynthEvent(event *beat.Event, se *SynthEvent) e
case "step/screenshot_ref":
fallthrough
case "screenshot/block":
add_data_stream_index.SetEventDataset(event, "browser_screenshot")
add_data_stream_index.SetEventDataset(event, "browser.screenshot")
Copy link
Member

Choose a reason for hiding this comment

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

How is this related?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main purpose of this PR, really, is to enable the integration, which breaks without this. I agree it's a bit unrelated, but I think it makes sense to include because this PR isn't useful without it.

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

LGTM

{{- if (and (eq .Variant "offline") (not (contains .from "ubi-minimal"))) }}
# Setup synthetics env vars
ENV ELASTIC_SYNTHETICS_CAPABLE=true
ENV SUITES_DIR={{ $beatHome }}/suites
Copy link
Member

Choose a reason for hiding this comment

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

Are we using a dedicated folder instead of /tmp for copying suites? I forgot what wat was the real use of this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can probably be nixed. It's not really used for anything.

case "journey/network_info":
add_data_stream_index.SetEventDataset(event, "browser_network")
add_data_stream_index.SetEventDataset(event, "browser.network")
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it break for existing users?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, existing users don't use datasets, only people using the integration do. For existing users it's all under heartbeat-*

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha 👍🏽

@andrewvc andrewvc merged commit 4727470 into elastic:master Aug 11, 2021
@andrewvc andrewvc deleted the envoffline branch August 11, 2021 19:43
@andrewvc
Copy link
Contributor Author

@Mergifyio backport 7.x

mergify bot pushed a commit that referenced this pull request Aug 11, 2021
#27052)

Creates a new offline tagged docker image that includes the dependencies required for synthetics. Building elastic-agent docker images will now create additional -offline tagged images with these extras. We may need to do additional work to ensure that these additional images are incorporated into the release process and onto the public website.

These changes also set the ELASTIC_SYNTHETICS_CAPABLE env flag, as done in heartbeat, to enable synthetics features in the docker environment. This dovetails with the work @dominiqueclarke is doing in elastic/integrations#1064 and elsewhere

Fixes #22932

(cherry picked from commit 4727470)
@mergify
Copy link
Contributor

mergify bot commented Aug 11, 2021

Command backport 7.x: success

Backports have been created

andrewvc added a commit that referenced this pull request Aug 16, 2021
#27052) (#27324)

Creates a new offline tagged docker image that includes the dependencies required for synthetics. Building elastic-agent docker images will now create additional -offline tagged images with these extras. We may need to do additional work to ensure that these additional images are incorporated into the release process and onto the public website.

These changes also set the ELASTIC_SYNTHETICS_CAPABLE env flag, as done in heartbeat, to enable synthetics features in the docker environment. This dovetails with the work @dominiqueclarke is doing in elastic/integrations#1064 and elsewhere

Fixes #22932

(cherry picked from commit 4727470)

Co-authored-by: Andrew Cholakian <andrew@andrewvc.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@andrewvc
Copy link
Contributor Author

@Mergifyio backport 7.15

mergify bot pushed a commit that referenced this pull request Aug 18, 2021
#27052)

Creates a new offline tagged docker image that includes the dependencies required for synthetics. Building elastic-agent docker images will now create additional -offline tagged images with these extras. We may need to do additional work to ensure that these additional images are incorporated into the release process and onto the public website.

These changes also set the ELASTIC_SYNTHETICS_CAPABLE env flag, as done in heartbeat, to enable synthetics features in the docker environment. This dovetails with the work @dominiqueclarke is doing in elastic/integrations#1064 and elsewhere

Fixes #22932

(cherry picked from commit 4727470)

# Conflicts:
#	dev-tools/mage/dockerbuilder.go
@mergify
Copy link
Contributor

mergify bot commented Aug 18, 2021

Command backport 7.15: success

Backports have been created

mergify bot added a commit that referenced this pull request Aug 18, 2021
#27052) (#27324)

Creates a new offline tagged docker image that includes the dependencies required for synthetics. Building elastic-agent docker images will now create additional -offline tagged images with these extras. We may need to do additional work to ensure that these additional images are incorporated into the release process and onto the public website.

These changes also set the ELASTIC_SYNTHETICS_CAPABLE env flag, as done in heartbeat, to enable synthetics features in the docker environment. This dovetails with the work @dominiqueclarke is doing in elastic/integrations#1064 and elsewhere

Fixes #22932

(cherry picked from commit 4727470)

Co-authored-by: Andrew Cholakian <andrew@andrewvc.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit f9b2610)

# Conflicts:
#	dev-tools/mage/dockerbuilder.go
andrewvc pushed a commit that referenced this pull request Aug 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 19, 2021

This pull request does not have a backport label. Could you fix it @andrewvc? 🙏
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 7./d branch. /d is the digit

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

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Heartbeat][Agent] Synthetics deps and Elastic Agent
9 participants