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

[Fleet] Add support for forcing stack aligned versions on bundled packages #139567

Conversation

kpollich
Copy link
Member

@kpollich kpollich commented Aug 26, 2022

Summary

Ref #138257

  • Adds a forceAlignStackVersion option to fleet_packages.json
  • Implement logic to forcibly rewrite the version of a bundled package to be equal to the current Kibana build version (including -SNAPSHOT suffix if needed) when opted in via forceAlignStackVersion
  • Opt apm package into new versioning logic

image

To test

  1. Comment out every task except the "bundle fleet packages" task in build_distributables.ts
  2. Run yarn build --epr-registry=production to fetch bundled packages from the production registry (simulates an older APM version in registry)
  3. Copy the build/kibana/x-pack/plugins/fleet/target/bundled_packages directory outputted by the build to x-pack/plugins/fleet/target/bundled_packages to resolve bundled packages in dev
  4. Add a mock cloud policy to your kibana.dev.yml, e.g.
# Force use of the production registry so we don't resolve `apm-8.5.0` which is technically a greater semver than `8.5.0-SNAPSHOT` by spec
xpack.fleet.registryUrl: https://epr.elastic.co

xpack.fleet.packages:
  - name: apm
    version: latest
  - name: fleet_server
    version: latest
xpack.fleet.agentPolicies:
  # Cloud Agent policy
  - name: Elastic Cloud agent policy
    description: Default agent policy for agents hosted on Elastic Cloud
    id: policy-elastic-agent-on-cloud

    is_default: false
    is_managed: true
    is_default_fleet_server: false

    namespace: default
    monitoring_enabled: []
    unenroll_timeout: 86400 # 1 day TTL

    package_policies:
      - name: Fleet Server
        id: elastic-cloud-fleet-server
        package:
          name: fleet_server
        inputs:
          - type: fleet-server
            keep_enabled: true

            vars:
              - name: host
                value: 0.0.0.0
                frozen: true
              - name: port
                value: 8220
                frozen: true
              - name: custom
                value: |
                  server.runtime:
                    gc_percent: 20          # Force the GC to execute more frequently: see https://golang.org/pkg/runtime/debug/#SetGCPercent
      - name: Elastic APM
        id: elastic-cloud-apm
        package:
          name: apm
        inputs:
          - type: apm
            keep_enabled: true
            vars:
              - name: api_key_enabled
                value: true
              - name: host
                value: '0.0.0.0:8200'
                frozen: true
              - name: secret_token
                value: 'secret'
              - name: tls_enabled
                value: true
                frozen: true
              - name: tls_certificate
                value: /app/config/certs/node.crt
                frozen: true
              - name: tls_key
                value: /app/config/certs/node.key
                frozen: true
              - name: url
                value: 'https://example.com'
                frozen: true
  1. Start up Kibana
  2. Note that APM 8.4.0 is resolved from the registry, but its version is rewritten to 8.5.0-SNAPSHOT in its manifest and when presented in the UI

Dependency alert

I needed a way to manipulate and generate .zip files on the fly here, and https://github.com/thejoshwolfe/yazl seemed like the obvious choice. We already make use of its companion library https://github.com/thejoshwolfe/yauzl elsewhere in Kibana, so I opted to install yazl and @types/yazl to fulfill our needs here.

@kpollich kpollich added release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team labels Aug 26, 2022
@kpollich kpollich requested a review from axw August 26, 2022 16:46
@kpollich kpollich self-assigned this Aug 26, 2022
@kpollich kpollich requested review from a team as code owners August 26, 2022 16:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Looks good @kpollich! Just one question about the package that is fetched from EPR.

src/dev/build/tasks/bundle_fleet_packages.ts Outdated Show resolved Hide resolved
@kpollich
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@kpollich
Copy link
Member Author

@elasticmachine merge upstream

@kpollich
Copy link
Member Author

@elasticmachine merge upstream

);
}

const archivePath = `${fleetPackage.name}-${versionToWrite}.zip`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we can support 2 endpoints temporarily. The job I'm building here will use indices behind https://epr-v2.ea-web.elastic.dev/, which are different from https://epr-snapshot.elastic.co/ at the moment.

We have 3 options:

  1. We will enable the job once we switch to Package Storage v2.
  2. build_fleet_packages.ts will check also the v2 endpoint.
  3. The job can update the fleet_packages.json with direct links to packages (and signatures).

Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer to keep Kibana somewhat unaware of a separate package storage v2 endpoint if possible.

What is your thinking behind checking v1 and v2? Just trying to catch cases where a package hasn't been upload to both places yet when a build occurs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it's more tangled.

APM pipeline is integrated only with v2, so you will never see this package in v1: https://epr-v2.ea-web.elastic.dev/search?prerelease=true&package=apm (8.5.0-preview-1661950351).

That's why I was thinking about setting download_urls in fleet_packages.json... or we will enable the job once we switch to v2 (epr-snapshot will point to https://epr-v2.ea-web.elastic.dev/).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm in favor of enabling the job once we switch to v2 to keep Kibana's assumption around EPR endpoints accurate before and after the release of package storage v2.

@nchaulet
Copy link
Member

@kpollich can it cause some issue with the integration list page, I think we are using the search endpoint from EPR here so the version could mismatch somehow no?

@kpollich kpollich added the ci:cloud-deploy Create or update a Cloud deployment label Aug 31, 2022
@kpollich
Copy link
Member Author

@elasticmachine merge upstream

@kpollich
Copy link
Member Author

can it cause some issue with the integration list page, I think we are using the search endpoint from EPR here so the version could mismatch somehow no?

I don't think so, because bundled packages aren't included on the integrations grid. I'm kicking off a cloud deploy here just to verify in an environment where we have both bundled packages + EPR packages.

@kpollich
Copy link
Member Author

Cloud deploy failed and I'm not sure why. Seems like a transient issue.

@kpollich kpollich added the ci:cloud-redeploy Always create a new Cloud deployment label Aug 31, 2022
@kpollich
Copy link
Member Author

@elasticmachine merge upstream

@kpollich
Copy link
Member Author

kpollich commented Sep 1, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 1, 2022

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @kpollich

@kpollich
Copy link
Member Author

kpollich commented Sep 1, 2022

Cloud deploy looks good in terms of browse and installed integrations grid. Everything seems to be working as expected. cc @nchaulet

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

🚀

@kpollich kpollich merged commit 29b1428 into elastic:main Sep 1, 2022
@kpollich kpollich deleted the 137759-support-stack-aligned-bundled-package-versions branch September 1, 2022 13:30
@kibanamachine kibanamachine added v8.5.0 backport:skip This commit does not require backporting labels Sep 1, 2022
Mpdreamz pushed a commit to Mpdreamz/kibana that referenced this pull request Sep 6, 2022
…kages (elastic#139567)

* Add support for forcing stack aligned versions on bundled packages

* Revert build_distributables

* Add missing module

* Enforce version in config even when stack aligned

* Throw error on failure to download bundled package

* Update comment

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants