From bfcb71d68ea603abf051492ec11815b76420e35e Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Wed, 9 Nov 2022 11:41:35 -0500 Subject: [PATCH] [v2] Merge v2 feature branch into main (#2064) * Support for Elastic Agent V2 status (#1747) * Support for Elastic Agent V2 status * Make 'make check-ci' happy * Add a check that 'components' is valid array * Rename variable to better reflect it's meaning * [v2] Switch to Elastic Agent v2 control protocol (#1751) * Switch to new client.V2 for communication with Elastic Agent. * Fix tests. * Fix integration tests. * Update go.sum. * Fix some lint issues. * Fix panic with agentInfo. * Fix panic in logger reconfigure. * Fixes for switching units. * updated version (#2014) * Update the elastic-agent-client to latest version. (#2061) * [v2] Merge main as of Nov 7 (#2062) * [Automation] Update elastic stack version to 8.5.0-6b9f92c0 for testing (#1756) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-0616acda for testing (#1760) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-dd6f2bb0 for testing (#1765) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-feb644de for testing (#1768) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-7783a03c for testing (#1776) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-17b8a62d for testing (#1780) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-9aed3b11 for testing (#1784) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-440e0896 for testing (#1788) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-fedc3e60 for testing (#1791) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-b5001a6d for testing (#1795) Co-authored-by: apmmachine * ci: move to fleet-ci (#1199) * Fic path to the packaging (#1806) * Fix gcs credentials for packaging (#1807) * [Automation] Update elastic stack version to 8.5.0-de69302b for testing (#1822) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-1bd77fc1 for testing (#1826) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-167dfc80 for testing (#1831) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-6b7dda2d for testing (#1835) Co-authored-by: apmmachine * Allow multiple ES outputs as long as they are the same ES (#1684) * add 'outputs' field to the ES agent schema to store the API key data and permission hash for each ES output * add output name to API key metadata * add v8.5 migration to migration.go * add migration docs and improve logging * group migration functions per version * [Automation] Update elastic stack version to 8.5.0-4140365c for testing (#1837) Co-authored-by: apmmachine * updating upgrade_status: completed (#1833) * updating upgrade_status: completed * updated schema.json and regenerated schema.go * updated license headers * Fix v8.5.0 migration painless script (#1839) * fix v8.5.0 migration painless script * [Automation] Update elastic stack version to 8.5.0-8e906f9f for testing (#1843) Co-authored-by: apmmachine * ci: rename dra staging for release dra release staging (#1840) * Remove events from agent checkin body. (#1842) Remove the events attribute from the agent checkin body. Note that removal of the attribute will not stop the server from issuing a 400 if the response body is too long. The removal is so that the checkin code on the fleet-server and agent remain comparable. Co-authored-by: Blake Rouse * [Automation] Update elastic stack version to 8.5.0-589a4a10 for testing (#1852) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-37418cf3 for testing (#1855) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-fcf3d4c2 for testing (#1862) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.5.0-c7913db3 for testing (#1868) Co-authored-by: apmmachine * Add error detail to catch-all HTTP response (#1854) * Make authc log debug and add cache hit field (#1870) * Document Go 1.18 certificate change in changelog. (#1871) * Revert "Fix v8.5.0 migration painless script" (#1878) * Revert "Fix v8.5.0 migration painless script (#1839)" This reverts commit de5d74bbb244baf93761eb375af8e7f48e531013. * Revert "Allow multiple ES outputs as long as they are the same ES (#1684)" This reverts commit 63fdcbf6fd730b2f9dc5c84443c07c7bd9a859da. * [Automation] Update elastic stack version to 8.5.0-56d2c52d for testing (#1880) Co-authored-by: apmmachine * Bulk API Keys update (#1779) Bulk API Keys update (#1779) * Fix and reintroduce "Allow multiple ES outputs as long as they are the same ES" (#1879) * Revert "Revert "Fix v8.5.0 migration painless script" (#1878)" This reverts commit ef9ca2bd78641e48e8ac2356989dfbfeebc4efa6. * Revert "Revert "Allow multiple ES outputs as long as they are the same ES (#1684)"" This reverts commit bb696ac0be53b6ef4a9143eff12a5a3263400585. * avoid new API keys being marked for invalidation Co-authored-by: Michal Pristas He fixed the merge conflicts after Bulk API Keys update (#1779), commit 46ac14bafa6a52366ca2ef528b2bef18636fc43d, got merged * [Automation] Update elastic stack version to 8.5.0-7dc445a0 for testing (#1888) Co-authored-by: apmmachine * Update pre-sets limits to avoid overlap. (#1891) Update file max limits and env_defaults_test.go running make defaults to generate the new one * [Release] add-backport-next (#1892) * Bump version to 8.6.0 (#1895) * Catch error in waitBulkAction. Add bulk.WithRetryOnConflict(3) in multiple places. (#1896) * Catch error in waitBulkAction. Add bulk.WithRetryOnConflict(3) in multiple places. * Add changelog entry. * Update CHANGELOG.next.asciidoc Co-authored-by: Craig MacKenzie Co-authored-by: Craig MacKenzie * Update apikey.cache_hit log field name to match convention (#1900) * [Automation] Update elastic stack version to 8.6.0-21651da3 for testing (#1908) Co-authored-by: apmmachine * LoadLimits does not override existing values (#1912) Fleet-server will use any specified cache or server limit values over whatever is returned by the default/agent number loader. For example, if A max body size is specifically set to a value such as 5MB, and the default returned by the LoadLimits is 1MB, the 5MB value is used. * [Automation] Update elastic stack version to 8.6.0-326f84b0 for testing (#1916) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-df00693f for testing (#1925) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-a2f4f140 for testing (#1928) Co-authored-by: apmmachine * Revert "updating upgrade_status: completed (#1833)" (#1920) * Revert "updating upgrade_status: completed (#1833)" This reverts commit 23be42ad5da92250a4f62e762b4971c357e7ae15. * Leaving in upgrade_status field for retry functionality * Storing checkin message in last_checkin_message (#1932) * Storing checkin message in last_checkin_message * added changelog * fixed tests * Unique limiters for each API listener (#1904) * Unique limiters for each API listener Refactor the limit.Limiter so it can wrap the separate API httprouter endpoints. Limiter.WrapX() calls take the handler and stats incrementer for metrics/error counting. api.Run() replaced with Router.Run(), which will generate an httprouter for each listener in order to be able to associate the httprouter with a unique Limiter. * Add listener address labeled logs to limiter * Review feedback * Apply suggestions from code review Co-authored-by: Anderson Queiroz * review feedback * fix import * Fix test Co-authored-by: Anderson Queiroz * Cleanup cmd/fleet/main.go (#1886) * Replace cache.Config with config.Cache * Move server setup from cmd/fleet to new pkg/server * Move constants * Fix imports and integration tests * fix linter * [Automation] Update elastic stack version to 8.6.0-158a13db for testing (#1938) Co-authored-by: apmmachine * [8.6](forwardport) Add extra protection against accessing null fields to 8.5 migration (#1921) (#1926) * [Automation] Update elastic stack version to 8.6.0-aea1c645 for testing (#1942) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-0fca2953 for testing (#1948) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-e4c15f15 for testing (#1954) Co-authored-by: apmmachine * Conditional log level for api key read (#1946) Conditional log level for api key read (#1946) * Updated migration query to match items with deprecated field present (#1959) Co-authored-by: Anderson Queiroz * Fix fleet.migration.total log key overlap (#1951) Co-authored-by: Anderson Queiroz * [Automation] Update elastic stack version to 8.6.0-d939cfde for testing (#1964) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-7c9f25a9 for testing (#1969) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-c49fac70 for testing (#1976) Co-authored-by: apmmachine * Update to Go 1.18.7. (#1978) * [Automation] Update elastic stack version to 8.6.0-5a8d757d for testing (#1981) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-40086bc7 for testing (#1987) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-233dc5d4 for testing (#1990) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-54a302f0 for testing (#1995) Co-authored-by: apmmachine * Don't send POLICY_CHANGE actions retrieved from index to agent. (#1963) * Don't send POLICY_CHANGE actions retrieved from index to agent. The fleet-server should not send any policy change actions that are written to the actions index to an agent on checkin. The server will remove these actions in the convert method and emit a warning message. The ack token that is used is not altered in this case. Policy change actions are dynamically generated by the fleet-server when it detects that the agent is not running an up to date version of the policy. * move filtering to its own method * Fix linter, tests, fix file name * [Automation] Update elastic stack version to 8.6.0-cae815eb for testing (#2000) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-6545f2df for testing (#2005) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-055acc83 for testing (#2011) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-baf193e8 for testing (#2016) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-22d60ec9 for testing (#2020) Co-authored-by: apmmachine * Allow upgrade action to signal retry (#1887) * Allow upgrade action to signal retry Allow the ack of an upgrade action to set the upgrade status to retrying. * fix tests set failed state * Fix broken test * nil upgrade status by default * Set agent to healthy in case of upgrade failure * fix upgrade fields * Fix tests * [Automation] Update elastic stack version to 8.6.0-b8b35931 for testing (#2024) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-a892f234 for testing (#2030) Co-authored-by: apmmachine * [Automation] Add GH action to add issues to ingest board Issues in this repo labeled with `Team:Fleet` will be added to the ingest board automatically w/ the `Fleet Server` area. * Update add-issues-to-ingest-board.yml * [Automation] Update elastic stack version to 8.6.0-89d224d2 for testing (#2034) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-949a38d2 for testing (#2039) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-26dc1164 for testing (#2045) Co-authored-by: apmmachine * Add active filter for enrollment key queries. (#2044) * Add active filter for enrollment key queries. Add an active: true filter to enrollment key queries. This allows fleet-server to handle cases where there may be 10+ inactive keys associated with a policy. * review feedback * fix linter * fix tests * Fix test cases * [Automation] Update elastic stack version to 8.6.0-4765d2b0 for testing (#2048) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-8a615646 for testing (#2050) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-3f5f98b7 for testing (#2051) Co-authored-by: apmmachine * [Automation] Update elastic stack version to 8.6.0-f20b7179 for testing (#2056) Co-authored-by: apmmachine * Run mod tidy. * Run make notice. * Fix intergration tests. * Run go mod tidy and make notice. * Fix path to fleet-server.yml in integration test. * Fix race condition. * Fix try 2. * Fix race. * Fix race try 2. Co-authored-by: apmmachine <58790750+apmmachine@users.noreply.github.com> Co-authored-by: apmmachine Co-authored-by: Victor Martinez Co-authored-by: Anderson Queiroz Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com> Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com> Co-authored-by: Craig MacKenzie Co-authored-by: Michal Pristas Co-authored-by: Julien Lind Co-authored-by: Elastic Machine Co-authored-by: Anderson Queiroz Co-authored-by: Kyle Pollich Co-authored-by: Aleksandr Maus Co-authored-by: Michal Pristas Co-authored-by: apmmachine <58790750+apmmachine@users.noreply.github.com> Co-authored-by: apmmachine Co-authored-by: Victor Martinez Co-authored-by: Anderson Queiroz Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com> Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com> Co-authored-by: Craig MacKenzie Co-authored-by: Julien Lind Co-authored-by: Elastic Machine Co-authored-by: Anderson Queiroz Co-authored-by: Kyle Pollich --- NOTICE.txt | 1122 ++++++----------- cmd/fleet/main.go | 24 +- cmd/fleet/main_integration_test.go | 233 ---- go.mod | 48 +- go.sum | 77 +- internal/pkg/api/handleCheckin.go | 64 +- internal/pkg/api/handleStatus.go | 15 +- internal/pkg/api/handleStatus_test.go | 17 +- internal/pkg/api/schema.go | 9 +- internal/pkg/checkin/bulk.go | 23 +- internal/pkg/checkin/bulk_test.go | 27 +- internal/pkg/dl/constants.go | 1 + internal/pkg/logger/logger.go | 2 +- internal/pkg/model/schema.go | 7 + internal/pkg/policy/self.go | 80 +- internal/pkg/policy/self_test.go | 84 +- internal/pkg/server/agent.go | 436 ++++--- internal/pkg/server/agent_integration_test.go | 402 ++++++ internal/pkg/server/fleet.go | 68 +- .../pkg/server/fleet_integration_test.go | 47 +- internal/pkg/server/server.go | 15 - internal/pkg/state/reporter.go | 51 + internal/pkg/status/reporter.go | 53 - model/schema.json | 9 + 24 files changed, 1477 insertions(+), 1437 deletions(-) delete mode 100644 cmd/fleet/main_integration_test.go create mode 100644 internal/pkg/server/agent_integration_test.go rename cmd/fleet/server_integration_test.go => internal/pkg/server/fleet_integration_test.go (88%) delete mode 100644 internal/pkg/server/server.go create mode 100644 internal/pkg/state/reporter.go delete mode 100644 internal/pkg/status/reporter.go diff --git a/NOTICE.txt b/NOTICE.txt index 823aca275..58b0d9d69 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -227,11 +227,11 @@ Contents of probable licence file $GOMODCACHE/github.com/dgraph-io/ristretto@v0. -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent -Version: v0.0.0-20220510120738-63b682fefc61 +Version: v0.0.0-20221107053805-657f66dad4bd Licence type (autodetected): Elastic -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent@v0.0.0-20220510120738-63b682fefc61/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent@v0.0.0-20221107053805-657f66dad4bd/LICENSE.txt: Elastic License 2.0 @@ -330,11 +330,11 @@ these terms. -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-client/v7 -Version: v7.0.0-20210922110810-e6f1f402a9ed +Version: v7.0.0-20221102171927-bc376a4e0f9f Licence type (autodetected): Elastic -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.0.0-20210922110810-e6f1f402a9ed/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.0.0-20221102171927-bc376a4e0f9f/LICENSE.txt: ELASTIC LICENSE AGREEMENT @@ -563,11 +563,11 @@ SOFTWARE -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-libs -Version: v0.2.3 +Version: v0.2.14 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.2.3/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.2.14/LICENSE: Apache License Version 2.0, January 2004 @@ -2772,11 +2772,11 @@ THE SOFTWARE. -------------------------------------------------------------------------------- Dependency : github.com/rs/zerolog -Version: v1.26.1 +Version: v1.27.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/rs/zerolog@v1.26.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/rs/zerolog@v1.27.0/LICENSE: MIT License @@ -3964,6 +3964,255 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------------------- +Dependency : google.golang.org/grpc +Version: v1.46.0 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.46.0/LICENSE: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------------------------------------------------------------------- +Dependency : google.golang.org/protobuf +Version: v1.28.0 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.28.0/LICENSE: + +Copyright (c) 2018 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ================================================================================ @@ -5983,14 +6232,45 @@ Version: v0.1.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/bgentry/speakeasy@v0.1.0/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/bgentry/speakeasy@v0.1.0/LICENSE: + +MIT License + +Copyright (c) 2017 Blake Gentry + +This license applies to the non-Windows portions of this library. The Windows +portion maintains its own Apache 2.0 license. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +-------------------------------------------------------------------------------- +Dependency : github.com/billgraziano/dpapi +Version: v0.4.0 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/billgraziano/dpapi@v0.4.0/LICENSE: MIT License -Copyright (c) 2017 Blake Gentry - -This license applies to the non-Windows portions of this library. The Windows -portion maintains its own Apache 2.0 license. +Copyright (c) 2019 Bill Graziano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -7014,11 +7294,11 @@ Contents of probable licence file $GOMODCACHE/github.com/cncf/xds/go@v0.0.0-2021 -------------------------------------------------------------------------------- Dependency : github.com/containerd/containerd -Version: v1.5.10 +Version: v1.5.13 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/containerd/containerd@v1.5.10/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/containerd/containerd@v1.5.13/LICENSE: Apache License @@ -7628,11 +7908,11 @@ third-party archives. -------------------------------------------------------------------------------- Dependency : github.com/coreos/go-systemd/v22 -Version: v22.3.2 +Version: v22.3.3-0.20220203105225-a9a7ef127534 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/coreos/go-systemd/v22@v22.3.2/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/coreos/go-systemd/v22@v22.3.3-0.20220203105225-a9a7ef127534/LICENSE: Apache License Version 2.0, January 2004 @@ -8853,11 +9133,11 @@ you may not use this file except in compliance with the Elastic License. -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-autodiscover -Version: v0.0.0-20220404145827-89887023c1ab +Version: v0.2.1 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-autodiscover@v0.0.0-20220404145827-89887023c1ab/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-autodiscover@v0.2.1/LICENSE: Apache License Version 2.0, January 2004 @@ -9276,11 +9556,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0. -------------------------------------------------------------------------------- Dependency : github.com/elastic/go-structform -Version: v0.0.9 +Version: v0.0.10 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v0.0.9/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v0.0.10/LICENSE: Apache License Version 2.0, January 2004 @@ -10122,11 +10402,11 @@ limitations under the License. -------------------------------------------------------------------------------- Dependency : github.com/envoyproxy/go-control-plane -Version: v0.10.1 +Version: v0.10.2-0.20220325020618-49ff273808a1 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/envoyproxy/go-control-plane@v0.10.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/envoyproxy/go-control-plane@v0.10.2-0.20220325020618-49ff273808a1/LICENSE: Apache License Version 2.0, January 2004 @@ -13701,263 +13981,13 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - --------------------------------------------------------------------------------- -Dependency : github.com/googleapis/gnostic -Version: v0.5.5 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/googleapis/gnostic@v0.5.5/LICENSE: - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - --------------------------------------------------------------------------------- -Dependency : github.com/gorilla/mux -Version: v1.8.0 -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/gorilla/mux@v1.8.0/LICENSE: - -Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -13975,14 +14005,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- -Dependency : github.com/grpc-ecosystem/go-grpc-middleware -Version: v1.3.0 +Dependency : github.com/googleapis/gnostic +Version: v0.5.5 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/googleapis/gnostic@v0.5.5/LICENSE: + - Apache License + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -14184,6 +14215,45 @@ Contents of probable licence file $GOMODCACHE/github.com/grpc-ecosystem/go-grpc- See the License for the specific language governing permissions and limitations under the License. + + +-------------------------------------------------------------------------------- +Dependency : github.com/gorilla/mux +Version: v1.8.0 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/gorilla/mux@v1.8.0/LICENSE: + +Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + -------------------------------------------------------------------------------- Dependency : github.com/grpc-ecosystem/grpc-gateway Version: v1.16.0 @@ -20440,11 +20510,11 @@ Contents of probable licence file $GOMODCACHE/github.com/lyft/protoc-gen-star@v0 -------------------------------------------------------------------------------- Dependency : github.com/magefile/mage -Version: v1.13.0 +Version: v1.14.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/magefile/mage@v1.13.0/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/magefile/mage@v1.14.0/LICENSE: Apache License Version 2.0, January 2004 @@ -21868,11 +21938,11 @@ THE SOFTWARE. -------------------------------------------------------------------------------- Dependency : github.com/mitchellh/mapstructure -Version: v1.4.3 +Version: v1.5.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/mitchellh/mapstructure@v1.4.3/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/mitchellh/mapstructure@v1.5.0/LICENSE: The MIT License (MIT) @@ -23368,220 +23438,9 @@ Contents of probable licence file $GOMODCACHE/github.com/opencontainers/image-sp incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS - - Copyright 2016 The Linux Foundation. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - --------------------------------------------------------------------------------- -Dependency : github.com/opentracing/opentracing-go -Version: v1.1.0 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/opentracing/opentracing-go@v1.1.0/LICENSE: - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. + END OF TERMS AND CONDITIONS - Copyright 2016 The OpenTracing Authors + Copyright 2016 The Linux Foundation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28756,11 +28615,11 @@ THE SOFTWARE. -------------------------------------------------------------------------------- Dependency : golang.org/x/crypto -Version: v0.0.0-20211215165025-cf75a172585e +Version: v0.0.0-20210817164053-32db794688a5 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.0.0-20211215165025-cf75a172585e/LICENSE: +Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.0.0-20210817164053-32db794688a5/LICENSE: Copyright (c) 2009 The Go Authors. All rights reserved. @@ -28978,11 +28837,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Dependency : golang.org/x/net -Version: v0.0.0-20220225172249-27dd8689420f +Version: v0.0.0-20220425223048-2871e0cb64e4 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/golang.org/x/net@v0.0.0-20220225172249-27dd8689420f/LICENSE: +Contents of probable licence file $GOMODCACHE/golang.org/x/net@v0.0.0-20220425223048-2871e0cb64e4/LICENSE: Copyright (c) 2009 The Go Authors. All rights reserved. @@ -29052,11 +28911,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Dependency : golang.org/x/sys -Version: v0.0.0-20220405052023-b1e9470b6e64 +Version: v0.0.0-20220422013727-9388b58f7150 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/golang.org/x/sys@v0.0.0-20220405052023-b1e9470b6e64/LICENSE: +Contents of probable licence file $GOMODCACHE/golang.org/x/sys@v0.0.0-20220422013727-9388b58f7150/LICENSE: Copyright (c) 2009 The Go Authors. All rights reserved. @@ -29486,223 +29345,11 @@ Contents of probable licence file $GOMODCACHE/google.golang.org/appengine@v1.6.7 -------------------------------------------------------------------------------- Dependency : google.golang.org/genproto -Version: v0.0.0-20211208223120-3a66f561d7aa -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/google.golang.org/genproto@v0.0.0-20211208223120-3a66f561d7aa/LICENSE: - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - --------------------------------------------------------------------------------- -Dependency : google.golang.org/grpc -Version: v1.43.0 +Version: v0.0.0-20220426171045-31bebdecfb46 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.43.0/LICENSE: +Contents of probable licence file $GOMODCACHE/google.golang.org/genproto@v0.0.0-20220426171045-31bebdecfb46/LICENSE: Apache License @@ -30332,43 +29979,6 @@ Contents of probable licence file $GOMODCACHE/google.golang.org/grpc/examples@v0 limitations under the License. --------------------------------------------------------------------------------- -Dependency : google.golang.org/protobuf -Version: v1.27.1 -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.27.1/LICENSE: - -Copyright (c) 2018 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -------------------------------------------------------------------------------- Dependency : gopkg.in/alecthomas/kingpin.v2 Version: v2.2.6 @@ -31150,11 +30760,11 @@ Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v2@v2.4.0/LICENSE: -------------------------------------------------------------------------------- Dependency : gopkg.in/yaml.v3 -Version: v3.0.0-20210107192922-496545a6307b +Version: v3.0.1 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b/LICENSE: +Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v3@v3.0.1/LICENSE: This project is covered by two different licenses: MIT and Apache. diff --git a/cmd/fleet/main.go b/cmd/fleet/main.go index 014dea531..1588112f7 100644 --- a/cmd/fleet/main.go +++ b/cmd/fleet/main.go @@ -19,7 +19,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/logger" "github.com/elastic/fleet-server/v7/internal/pkg/server" "github.com/elastic/fleet-server/v7/internal/pkg/signal" - "github.com/elastic/fleet-server/v7/internal/pkg/status" + "github.com/elastic/fleet-server/v7/internal/pkg/state" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -69,7 +69,6 @@ func getRunCommand(bi build.Info) func(cmd *cobra.Command, args []string) error } var l *logger.Logger - var srv server.Server if agentMode { cfg, err := config.FromConfig(cliCfg) if err != nil { @@ -80,10 +79,16 @@ func getRunCommand(bi build.Info) func(cmd *cobra.Command, args []string) error return err } - srv, err = server.NewAgent(cliCfg, os.Stdin, bi, l) + srv, err := server.NewAgent(cliCfg, os.Stdin, bi, l) if err != nil { return err } + + if err := srv.Run(installSignalHandler()); err != nil && !errors.Is(err, context.Canceled) { + log.Error().Err(err).Msg("Exiting") + l.Sync() + return err + } } else { cfgPath, err := cmd.Flags().GetString("config") if err != nil { @@ -107,17 +112,18 @@ func getRunCommand(bi build.Info) func(cmd *cobra.Command, args []string) error return err } - srv, err = server.NewFleet(cfg, bi, status.NewLog()) + srv, err := server.NewFleet(bi, state.NewLog()) if err != nil { return err } - } - if err := srv.Run(installSignalHandler()); err != nil && !errors.Is(err, context.Canceled) { - log.Error().Err(err).Msg("Exiting") - l.Sync() - return err + if err := srv.Run(installSignalHandler(), cfg); err != nil && !errors.Is(err, context.Canceled) { + log.Error().Err(err).Msg("Exiting") + l.Sync() + return err + } } + l.Sync() return nil } diff --git a/cmd/fleet/main_integration_test.go b/cmd/fleet/main_integration_test.go deleted file mode 100644 index 914dfb27b..000000000 --- a/cmd/fleet/main_integration_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -//go:build integration -// +build integration - -//nolint:unused // some unused code may be added to more tests -package fleet - -import ( - "context" - "fmt" - "io" - "sync" - "testing" - "time" - - "github.com/gofrs/uuid" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/elastic/elastic-agent-client/v7/pkg/proto" - "github.com/elastic/elastic-agent-libs/logp" - "github.com/elastic/elastic-agent/pkg/core/logger" - "github.com/elastic/elastic-agent/pkg/core/server" - "github.com/elastic/go-ucfg" - - "github.com/elastic/fleet-server/v7/internal/pkg/build" - "github.com/elastic/fleet-server/v7/internal/pkg/dl" - "github.com/elastic/fleet-server/v7/internal/pkg/model" - fserver "github.com/elastic/fleet-server/v7/internal/pkg/server" - ftesting "github.com/elastic/fleet-server/v7/internal/pkg/testing" - "github.com/elastic/fleet-server/v7/internal/pkg/testing/suite" -) - -var biInfo = build.Info{ - Version: "1.0.0", - Commit: "integration", -} - -var policyData = []byte(` -{ - "inputs": [ - { - "type": "fleet-server" - } - ] -} -`) - -var initialCfgData = ` -output: - elasticsearch: - hosts: '${ELASTICSEARCH_HOSTS:localhost:9200}' - service_token: '${ELASTICSEARCH_SERVICE_TOKEN}' -` - -var agentIDCfgData = ` -output: - elasticsearch: - hosts: '${ELASTICSEARCH_HOSTS:localhost:9200}' - service_token: '${ELASTICSEARCH_SERVICE_TOKEN}' -fleet: - agent: - id: 1e4954ce-af37-4731-9f4a-407b08e69e42 -` - -var badCfgData = ` -output: - elasticsearch: - hosts: 'localhost:63542' - service_token: '${ELASTICSEARCH_SERVICE_TOKEN}' -fleet: - agent: - id: 1e4954ce-af37-4731-9f4a-407b08e69e42 -` - -type agentSuite struct { - suite.RunningSuite -} - -func (s *agentSuite) TestAgentMode(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - bulker := ftesting.SetupBulk(ctx, t) - - // add a real default fleet server policy - policyID := uuid.Must(uuid.NewV4()).String() - _, err := dl.CreatePolicy(ctx, bulker, model.Policy{ - PolicyID: policyID, - RevisionIdx: 1, - DefaultFleetServer: true, - Data: policyData, - }) - require.NoError(t, err) - - // add entry for enrollment key (doesn't have to be a real key) - _, err = dl.CreateEnrollmentAPIKey(ctx, bulker, model.EnrollmentAPIKey{ - Name: "Default", - APIKey: "keyvalue", - APIKeyID: "keyid", - PolicyID: policyID, - Active: true, - }) - require.NoError(t, err) - - app := &StubApp{} - control := createAndStartControlServer(t, app) - defer control.Stop() - appState, err := control.Register(app, initialCfgData) - require.NoError(t, err) - - r, w := io.Pipe() - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - agent, err := fserver.NewAgent(ucfg.New(), r, biInfo) - require.NoError(t, err) - err = agent.Run(ctx) - assert.NoError(t, err) - }() - - err = appState.WriteConnInfo(w) - require.NoError(t, err) - - // wait for fleet-server to report as degraded (starting mode without agent.id) - ftesting.Retry(t, ctx, func(ctx context.Context) error { - status := app.Status() - if status != proto.StateObserved_DEGRADED { - return fmt.Errorf("should be reported as degraded; instead its %s", status) - } - return nil - }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) - - // reconfigure with agent ID set - err = appState.UpdateConfig(agentIDCfgData) - require.NoError(t, err) - - // wait for fleet-server to report as healthy - ftesting.Retry(t, ctx, func(ctx context.Context) error { - status := app.Status() - if status != proto.StateObserved_HEALTHY { - return fmt.Errorf("should be reported as healthy; instead its %s", status) - } - return nil - }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) - - // trigger update with bad configuration - err = appState.UpdateConfig(badCfgData) - require.NoError(t, err) - - // wait for fleet-server to report as failed - ftesting.Retry(t, ctx, func(ctx context.Context) error { - status := app.Status() - if status != proto.StateObserved_FAILED { - return fmt.Errorf("should be reported as failed; instead its %s", status) - } - return nil - }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) - - // reconfigure to good config - err = appState.UpdateConfig(agentIDCfgData) - require.NoError(t, err) - - // wait for fleet-server to report as healthy - ftesting.Retry(t, ctx, func(ctx context.Context) error { - status := app.Status() - if status != proto.StateObserved_HEALTHY { - return fmt.Errorf("should be reported as healthy; instead its %s", status) - } - return nil - }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) - - // trigger stop - err = appState.Stop(10 * time.Second) - assert.NoError(t, err) - - // wait for go routine to exit - wg.Wait() -} - -func newDebugLogger(t *testing.T) *logger.Logger { - t.Helper() - - loggerCfg := logger.DefaultLoggingConfig() - loggerCfg.Level = logp.DebugLevel - - log, err := logger.NewFromConfig("", loggerCfg, false) - require.NoError(t, err) - return log -} - -func createAndStartControlServer(t *testing.T, handler server.Handler, extraConfigs ...func(*server.Server)) *server.Server { - t.Helper() - srv, err := server.New(newDebugLogger(t), "localhost:0", handler, nil) - require.NoError(t, err) - for _, extra := range extraConfigs { - extra(srv) - } - require.NoError(t, srv.Start()) - return srv -} - -type StubApp struct { - lock sync.RWMutex - status proto.StateObserved_Status - message string - payload map[string]interface{} -} - -func (a *StubApp) Status() proto.StateObserved_Status { - a.lock.RLock() - defer a.lock.RUnlock() - return a.status -} - -func (a *StubApp) Message() string { - a.lock.RLock() - defer a.lock.RUnlock() - return a.message -} - -func (a *StubApp) OnStatusChange(_ *server.ApplicationState, status proto.StateObserved_Status, message string, payload map[string]interface{}) { - a.lock.Lock() - defer a.lock.Unlock() - a.status = status - a.message = message - a.payload = payload -} diff --git a/go.mod b/go.mod index e5e6d48ce..a1ff9ad48 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.17 require ( github.com/Pallinder/go-randomdata v1.2.0 github.com/dgraph-io/ristretto v0.1.0 - github.com/elastic/elastic-agent-client/v7 v7.0.0-20210922110810-e6f1f402a9ed - github.com/elastic/elastic-agent-libs v0.2.3 + github.com/elastic/elastic-agent-client/v7 v7.0.0-20221102171927-bc376a4e0f9f + github.com/elastic/elastic-agent-libs v0.2.14 github.com/elastic/elastic-agent-system-metrics v0.3.0 github.com/elastic/go-elasticsearch/v7 v7.16.0 github.com/elastic/go-ucfg v0.8.5 @@ -21,7 +21,7 @@ require ( github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pkg/errors v0.9.1 github.com/rs/xid v1.3.0 - github.com/rs/zerolog v1.26.1 + github.com/rs/zerolog v1.27.0 github.com/spf13/cobra v1.3.0 github.com/stretchr/testify v1.7.0 go.elastic.co/apm v1.15.0 @@ -30,6 +30,8 @@ require ( go.uber.org/zap v1.21.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac + google.golang.org/grpc v1.46.0 + google.golang.org/protobuf v1.28.0 ) require ( @@ -39,57 +41,51 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/elastic/go-licenser v0.4.0 // indirect - github.com/elastic/go-structform v0.0.9 // indirect + github.com/elastic/go-structform v0.0.10 // indirect github.com/elastic/go-sysinfo v1.7.1 // indirect github.com/elastic/go-windows v1.0.1 // indirect github.com/elastic/gosigar v0.14.2 // indirect - github.com/gofrs/flock v0.8.1 // indirect + github.com/fatih/color v1.13.0 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kr/pretty v0.2.1 // indirect - github.com/magefile/mage v1.13.0 // indirect + github.com/magefile/mage v1.14.0 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/procfs v0.7.3 // indirect github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.2.0 // indirect - go.elastic.co/apm/module/apmgrpc v1.15.0 // indirect go.elastic.co/apm/module/apmhttp v1.15.0 // indirect go.elastic.co/apm/module/apmhttp/v2 v2.0.0 // indirect go.elastic.co/apm/v2 v2.0.0 // indirect + go.elastic.co/ecszap v1.0.1 // indirect go.elastic.co/fastjson v1.1.0 // indirect - go.uber.org/goleak v1.1.12 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.8.0 // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/mod v0.5.1 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect golang.org/x/text v0.3.7 // indirect + golang.org/x/tools v0.1.9 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/protobuf v1.27.1 // indirect + google.golang.org/genproto v0.0.0-20220426171045-31bebdecfb46 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + howett.net/plist v1.0.0 // indirect ) require ( - github.com/elastic/elastic-agent v0.0.0-20220510120738-63b682fefc61 - github.com/fatih/color v1.13.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/elastic/elastic-agent v0.0.0-20221107053805-657f66dad4bd github.com/jcchavezs/porto v0.4.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/prometheus/procfs v0.7.3 // indirect go.elastic.co/apm/module/apmhttprouter v1.14.0 - go.elastic.co/ecszap v1.0.1 // indirect - go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.8.0 // indirect - golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect - golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 // indirect - golang.org/x/tools v0.1.9 // indirect - google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect - google.golang.org/grpc v1.43.0 // indirect - howett.net/plist v1.0.0 // indirect ) replace ( diff --git a/go.sum b/go.sum index 46eee0fb8..1c4474890 100644 --- a/go.sum +++ b/go.sum @@ -110,7 +110,7 @@ github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2 github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00= github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600= github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= -github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg= +github.com/Microsoft/hcsshim v0.8.24/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg= github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -177,6 +177,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/billgraziano/dpapi v0.4.0 h1:t39THI1Ld1hkkLVrhkOX6u5TUxwzRddOffq4jcwh2AE= +github.com/billgraziano/dpapi v0.4.0/go.mod h1:gi1Lin0jvovT53j0EXITkY6UPb3hTfI92POaZgj9JBA= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= @@ -261,6 +263,7 @@ github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340/go.mod h1:s5q4S github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo= github.com/containerd/cgroups v0.0.0-20210114181951-8a68de567b68/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU= +github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8= github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE= @@ -282,8 +285,8 @@ github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoT github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= github.com/containerd/containerd v1.5.2/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= -github.com/containerd/containerd v1.5.10 h1:3cQ2uRVCkJVcx5VombsE7105Gl9Wrl7ORAO3+4+ogf4= -github.com/containerd/containerd v1.5.10/go.mod h1:fvQqCfadDGga5HZyn3j4+dx56qj2I9YwBrlSdalvJYQ= +github.com/containerd/containerd v1.5.13 h1:XqvKw9i4P7/mFrC3TSM7yV5cwFZ9avXe6M3YANKnzEE= +github.com/containerd/containerd v1.5.13/go.mod h1:3AlCrzKROjIuP3JALsY14n8YtntaUDBu7vek+rPN5Vc= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= @@ -349,8 +352,9 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 h1:rtAn27wIbmOGUs7RIbVgPEjb31ehTVniDwPGXyMxm5U= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -420,19 +424,22 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elastic/e2e-testing v1.99.2-0.20220117192005-d3365c99b9c4 h1:uYT+Krd8dsvnhnLK9pe/JHZkYtXEGPfbV4Wt1JPPol0= github.com/elastic/e2e-testing v1.99.2-0.20220117192005-d3365c99b9c4/go.mod h1:UcNuf4pX/qDVNQr0zybm1NL2YoWik+jKBaINZqQCA40= -github.com/elastic/elastic-agent v0.0.0-20220510120738-63b682fefc61 h1:S4aHsDv4UvI8mPPegErXfiLNIbfgrb+dmJlZhMG1t5s= -github.com/elastic/elastic-agent v0.0.0-20220510120738-63b682fefc61/go.mod h1:xvYyMEL3sw1Q7cI3Q6ZObcellEm0p3fls/YacPFZdBw= -github.com/elastic/elastic-agent-autodiscover v0.0.0-20220404145827-89887023c1ab h1:Jk6Mfk5BF8gtfE7X0bNCiDGBtwJVxRI79b4wLCAsP+A= +github.com/elastic/elastic-agent v0.0.0-20220831162706-5f1e54f40d3e/go.mod h1:sE+a99VTBCfrgogKL2j0n9Jf0NocEOi32GNP1OtdnG4= +github.com/elastic/elastic-agent v0.0.0-20221107053805-657f66dad4bd h1:4Vo4x8bMyIy09L6tNANIaWoVxnmBnxmc6Z9EYGq9y2o= +github.com/elastic/elastic-agent v0.0.0-20221107053805-657f66dad4bd/go.mod h1:ZlpbMaxcRpuN2BGe78Qp/QylMU+j897Cfyc888caLsk= github.com/elastic/elastic-agent-autodiscover v0.0.0-20220404145827-89887023c1ab/go.mod h1:Gg1fsQI+rVms9FJ2DefBSojfPIzgkV8xlyG8fPG0DE8= +github.com/elastic/elastic-agent-autodiscover v0.2.1 h1:Nbeayh3vq2FNm6xaFo34mhUdOu0EVlpj53CqCsbU0E4= +github.com/elastic/elastic-agent-autodiscover v0.2.1/go.mod h1:gPnzzfdYNdgznAb+iG9eyyXaQXBbAMHa+Y6Z8hXfcGY= github.com/elastic/elastic-agent-client/v7 v7.0.0-20210727140539-f0905d9377f6/go.mod h1:uh/Gj9a0XEbYoM4NYz4LvaBVARz3QXLmlNjsrKY9fTc= -github.com/elastic/elastic-agent-client/v7 v7.0.0-20210922110810-e6f1f402a9ed h1:H5si6Yglir/pIyYQur/Es/ByTkQAoNDqidI8gBB2IGs= -github.com/elastic/elastic-agent-client/v7 v7.0.0-20210922110810-e6f1f402a9ed/go.mod h1:uh/Gj9a0XEbYoM4NYz4LvaBVARz3QXLmlNjsrKY9fTc= +github.com/elastic/elastic-agent-client/v7 v7.0.0-20220804181728-b0328d2fe484/go.mod h1:fkvyUfFwyAG5OnMF0h+FV9sC0Xn9YLITwQpSuwungQs= +github.com/elastic/elastic-agent-client/v7 v7.0.0-20221102171927-bc376a4e0f9f h1:hZv3vpGoAIvt/r6iPgKdfTCKgI8Eyk5Bb8HHP2FtzTY= +github.com/elastic/elastic-agent-client/v7 v7.0.0-20221102171927-bc376a4e0f9f/go.mod h1:FEXUbFMfaV62S0CtJgD+FFHGY7+4o4fXkDicyONPSH8= github.com/elastic/elastic-agent-libs v0.0.0-20220303160015-5b4e674da3dd/go.mod h1://82M1l73IHx0wDbS2Tzkq6Fx9fkmytS1KgkIyzvNTM= -github.com/elastic/elastic-agent-libs v0.1.3-0.20220413130536-4b45f2742994/go.mod h1:1xDLBhIqBIjhJ7lr2s+xRFFkQHpitSp8q2zzv1Dqg+s= github.com/elastic/elastic-agent-libs v0.2.2/go.mod h1:1xDLBhIqBIjhJ7lr2s+xRFFkQHpitSp8q2zzv1Dqg+s= -github.com/elastic/elastic-agent-libs v0.2.3 h1:GY8M0fxOs/GBY2nIB+JOB91aoD72S87iEcm2qVGFUqI= -github.com/elastic/elastic-agent-libs v0.2.3/go.mod h1:1xDLBhIqBIjhJ7lr2s+xRFFkQHpitSp8q2zzv1Dqg+s= -github.com/elastic/elastic-agent-system-metrics v0.1.0/go.mod h1:YUsjilmJSuMGt1iG0fSF/5uJPWsl+qf+8gndtPEsWEA= +github.com/elastic/elastic-agent-libs v0.2.5/go.mod h1:chO3rtcLyGlKi9S0iGVZhYCzDfdDsAQYBc+ui588AFE= +github.com/elastic/elastic-agent-libs v0.2.6/go.mod h1:chO3rtcLyGlKi9S0iGVZhYCzDfdDsAQYBc+ui588AFE= +github.com/elastic/elastic-agent-libs v0.2.14 h1:o1agY/37TKl5kjhv3ur5M9d127wzQPRxwA4Xoh0jUEo= +github.com/elastic/elastic-agent-libs v0.2.14/go.mod h1:0J9lzJh+BjttIiVjYDLncKYCEWUUHiiqnuI64y6C6ss= github.com/elastic/elastic-agent-system-metrics v0.3.0 h1:W8L0E8lWJmdguH+oIR7OzuFgopvw8ucZAE9w6iqVlpE= github.com/elastic/elastic-agent-system-metrics v0.3.0/go.mod h1:RIYhJOS7mUeyIthfOSqmmbEILYSzaDWLi5zQ70bQo+o= github.com/elastic/elastic-package v0.32.1/go.mod h1:l1fEnF52XRBL6a5h6uAemtdViz2bjtjUtgdQcuRhEAY= @@ -442,8 +449,9 @@ github.com/elastic/go-elasticsearch/v8 v8.0.0-20210317102009-a9d74cec0186/go.mod github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ= github.com/elastic/go-licenser v0.4.0 h1:jLq6A5SilDS/Iz1ABRkO6BHy91B9jBora8FwGRsDqUI= github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU= -github.com/elastic/go-structform v0.0.9 h1:HpcS7xljL4kSyUfDJ8cXTJC6rU5ChL1wYb6cx3HLD+o= github.com/elastic/go-structform v0.0.9/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= +github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gnCJPDo1w= +github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO+s0= github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= @@ -468,8 +476,9 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1 h1:cgDRLG7bs59Zd+apAWuzLQL95obVYAymNJek76W3mgw= github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 h1:xvqufLtNVwAhN8NMyWklVgxnWohi+wtMGQMhtxexlm0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.2 h1:JiO+kJTpmYGjEodY7O1Zk8oZcNz1+f30UtwtXoFUPzE= github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= @@ -589,7 +598,6 @@ github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU= @@ -725,7 +733,6 @@ github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16 github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -914,8 +921,9 @@ github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc8 github.com/magefile/mage v1.9.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magefile/mage v1.12.1/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= -github.com/magefile/mage v1.13.0 h1:XtLJl8bcCM7EFoO8FyH8XK3t7G5hQAeK+i4tq+veT9M= github.com/magefile/mage v1.13.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= +github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= @@ -994,8 +1002,9 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -1078,7 +1087,6 @@ github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mo github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqiriPsEqVhc+svHE= github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= -github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= @@ -1171,8 +1179,8 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.22.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM= -github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= -github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= +github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs= +github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U= github.com/rubenv/sql-migrate v0.0.0-20210614095031-55d5740dbbcc/go.mod h1:HFLT6i9iR4QBOF5rdCyjddC9t59ArqWJV2xx+jwcCMo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1450,9 +1458,8 @@ golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e h1:1SzTfNOXwIS2oWiMF+6qu0OUDKb0dauo6MoDUQyu+yU= -golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1558,8 +1565,9 @@ golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1664,6 +1672,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200828161417-c663848e9a16/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1715,8 +1724,10 @@ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 h1:D1v9ucDTYBtbz5vNuBbAhIMAGhQhJ6Ym5ah3maMVNX4= golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1937,8 +1948,9 @@ google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220426171045-31bebdecfb46 h1:G1IeWbjrqEq9ChWxEuRPJu6laA67+XgTFHVSAvepr38= +google.golang.org/genproto v0.0.0-20220426171045-31bebdecfb46/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1971,8 +1983,9 @@ google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM= -google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 h1:r16FSFCMhn7+LU8CzbtAIKppYeU6NUPJVdvXeIqVIq8= @@ -1989,8 +2002,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -2041,8 +2055,9 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/gotestsum v1.7.0 h1:RwpqwwFKBAa2h+F6pMEGpE707Edld0etUD3GhqqhDNc= diff --git a/internal/pkg/api/handleCheckin.go b/internal/pkg/api/handleCheckin.go index 6a8901b72..6bbbbb8af 100644 --- a/internal/pkg/api/handleCheckin.go +++ b/internal/pkg/api/handleCheckin.go @@ -165,6 +165,12 @@ func (ct *CheckinT) processRequest(zlog zerolog.Logger, w http.ResponseWriter, r return err } + // Compare agent_components content and update if different + rawComponents, err := parseComponents(zlog, agent, &req) + if err != nil { + return err + } + // Resolve AckToken from request, fallback on the agent record seqno, err := ct.resolveSeqNo(ctx, zlog, req, agent) if err != nil { @@ -209,7 +215,7 @@ func (ct *CheckinT) processRequest(zlog zerolog.Logger, w http.ResponseWriter, r defer longPoll.Stop() // Initial update on checkin, and any user fields that might have changed - err = ct.bc.CheckIn(agent.Id, req.Status, req.Message, rawMeta, seqno, ver) + err = ct.bc.CheckIn(agent.Id, req.Status, req.Message, rawMeta, rawComponents, seqno, ver) if err != nil { zlog.Error().Err(err).Str("agent_id", agent.Id).Msg("checkin failed") } @@ -251,7 +257,7 @@ func (ct *CheckinT) processRequest(zlog zerolog.Logger, w http.ResponseWriter, r zlog.Trace().Msg("fire long poll") break LOOP case <-tick.C: - err := ct.bc.CheckIn(agent.Id, req.Status, req.Message, nil, nil, ver) + err := ct.bc.CheckIn(agent.Id, req.Status, req.Message, nil, rawComponents, nil, ver) if err != nil { zlog.Error().Err(err).Str("agent_id", agent.Id).Msg("checkin failed") } @@ -544,6 +550,60 @@ func parseMeta(zlog zerolog.Logger, agent *model.Agent, req *CheckinRequest) ([] return outMeta, nil } +func parseComponents(zlog zerolog.Logger, agent *model.Agent, req *CheckinRequest) ([]byte, error) { + + // Quick comparison first; compare the JSON payloads. + // If the data is not consistently normalized, this short-circuit will not work. + if bytes.Equal(req.Components, agent.Components) { + zlog.Trace().Msg("quick comparing agent components data is equal") + return nil, nil + } + + // Deserialize the request components data + var reqComponents interface{} + if len(req.Components) > 0 { + if err := json.Unmarshal(req.Components, &reqComponents); err != nil { + return nil, errors.Wrap(err, "parseComponents request") + } + // Validate that components is an array + if _, ok := reqComponents.([]interface{}); !ok { + return nil, errors.Wrap(errors.New("components property is not array"), "parseComponents request") + } + } + + // If empty, don't step on existing data + if reqComponents == nil { + return nil, nil + } + + // Deserialize the agent's components copy + var agentComponents interface{} + if len(agent.Components) > 0 { + if err := json.Unmarshal(agent.Components, &agentComponents); err != nil { + return nil, errors.Wrap(err, "parseComponents local") + } + } + + var outComponents []byte + + // Compare the deserialized meta structures and return the bytes to update if different + if !reflect.DeepEqual(reqComponents, agentComponents) { + + zlog.Trace(). + RawJSON("oldComponents", agent.Components). + RawJSON("newComponents", req.Components). + Msg("local components data is not equal") + + zlog.Info(). + RawJSON("req.Components", req.Components). + Msg("applying new components data") + + outComponents = req.Components + } + + return outComponents, nil +} + func calcPollDuration(zlog zerolog.Logger, cfg *config.Server, setupDuration time.Duration) (time.Duration, time.Duration) { pollDuration := cfg.Timeouts.CheckinLongPoll diff --git a/internal/pkg/api/handleStatus.go b/internal/pkg/api/handleStatus.go index ff9dce021..922a8251a 100644 --- a/internal/pkg/api/handleStatus.go +++ b/internal/pkg/api/handleStatus.go @@ -11,6 +11,7 @@ import ( "net/http" "time" + "github.com/elastic/elastic-agent-client/v7/pkg/client" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" "github.com/elastic/fleet-server/v7/internal/pkg/build" "github.com/elastic/fleet-server/v7/internal/pkg/bulk" @@ -19,7 +20,6 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/logger" "github.com/julienschmidt/httprouter" - "github.com/elastic/elastic-agent-client/v7/pkg/proto" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) @@ -61,17 +61,17 @@ func (st StatusT) authenticate(r *http.Request) (*apikey.APIKey, error) { return authAPIKey(r, st.bulk, st.cache) } -func (st StatusT) handleStatus(_ *zerolog.Logger, r *http.Request, rt *Router) (resp StatusResponse, status proto.StateObserved_Status) { +func (st StatusT) handleStatus(_ *zerolog.Logger, r *http.Request, rt *Router) (resp StatusResponse, state client.UnitState) { authed := true if _, aerr := st.authfn(r); aerr != nil { log.Debug().Err(aerr).Msg("unauthenticated status request, return short status response only") authed = false } - status = rt.sm.Status() + state = rt.sm.State() resp = StatusResponse{ Name: build.ServiceName, - Status: status.String(), + Status: state.String(), } if authed { @@ -82,8 +82,7 @@ func (st StatusT) handleStatus(_ *zerolog.Logger, r *http.Request, rt *Router) ( } } - return resp, status - + return resp, state } func (rt *Router) handleStatus(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { @@ -95,7 +94,7 @@ func (rt *Router) handleStatus(w http.ResponseWriter, r *http.Request, _ httprou Str("mod", kStatusMod). Logger() - resp, status := rt.st.handleStatus(&zlog, r, rt) + resp, state := rt.st.handleStatus(&zlog, r, rt) data, err := json.Marshal(&resp) if err != nil { @@ -107,7 +106,7 @@ func (rt *Router) handleStatus(w http.ResponseWriter, r *http.Request, _ httprou } code := http.StatusServiceUnavailable - if status == proto.StateObserved_DEGRADED || status == proto.StateObserved_HEALTHY { + if state == client.UnitStateDegraded || state == client.UnitStateHealthy { code = http.StatusOK } w.WriteHeader(code) diff --git a/internal/pkg/api/handleStatus_test.go b/internal/pkg/api/handleStatus_test.go index f3d184b82..fd58cb824 100644 --- a/internal/pkg/api/handleStatus_test.go +++ b/internal/pkg/api/handleStatus_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/elastic/elastic-agent-client/v7/pkg/client" "github.com/elastic/elastic-agent-client/v7/pkg/proto" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" fbuild "github.com/elastic/fleet-server/v7/internal/pkg/build" @@ -35,15 +36,15 @@ func withAuthFunc(authfn AuthFunc) OptFunc { } type mockPolicyMonitor struct { - status proto.StateObserved_Status + state client.UnitState } func (pm *mockPolicyMonitor) Run(ctx context.Context) error { return nil } -func (pm *mockPolicyMonitor) Status() proto.StateObserved_Status { - return pm.status +func (pm *mockPolicyMonitor) State() client.UnitState { + return pm.state } func TestHandleStatus(t *testing.T) { @@ -80,13 +81,13 @@ func TestHandleStatus(t *testing.T) { // Test table, with inner loop on all available statuses for _, tc := range tests { t.Run(tc.Name, func(t *testing.T) { - for k, v := range proto.StateObserved_Status_name { + for k, v := range proto.State_name { t.Run(v, func(t *testing.T) { - status := proto.StateObserved_Status(k) + state := client.UnitState(k) r := Router{ ctx: ctx, st: NewStatusT(cfg, nil, c, withAuthFunc(tc.AuthFn)), - sm: &mockPolicyMonitor{status}, + sm: &mockPolicyMonitor{state}, bi: fbuild.Info{ Version: "8.1.0", Commit: "4eff928", @@ -102,7 +103,7 @@ func TestHandleStatus(t *testing.T) { hr.ServeHTTP(w, req) expectedCode := http.StatusServiceUnavailable - if status == proto.StateObserved_DEGRADED || status == proto.StateObserved_HEALTHY { + if state == client.UnitStateDegraded || state == client.UnitStateHealthy { expectedCode = http.StatusOK } @@ -119,7 +120,7 @@ func TestHandleStatus(t *testing.T) { t.Error(diff) } - if diff := cmp.Diff(res.Status, status.String()); diff != "" { + if diff := cmp.Diff(res.Status, state.String()); diff != "" { t.Error(diff) } diff --git a/internal/pkg/api/schema.go b/internal/pkg/api/schema.go index fdca0648a..03d65966c 100644 --- a/internal/pkg/api/schema.go +++ b/internal/pkg/api/schema.go @@ -78,10 +78,11 @@ type EnrollResponse struct { } type CheckinRequest struct { - Status string `json:"status"` - Message string `json:"message"` - AckToken string `json:"ack_token,omitempty"` - LocalMeta json.RawMessage `json:"local_metadata"` + Status string `json:"status"` + Message string `json:"message"` + AckToken string `json:"ack_token,omitempty"` + LocalMeta json.RawMessage `json:"local_metadata"` + Components json.RawMessage `json:"components,omitempty"` } type CheckinResponse struct { diff --git a/internal/pkg/checkin/bulk.go b/internal/pkg/checkin/bulk.go index 7d80123e2..8eb67cba7 100644 --- a/internal/pkg/checkin/bulk.go +++ b/internal/pkg/checkin/bulk.go @@ -33,9 +33,10 @@ func WithFlushInterval(d time.Duration) Opt { } type extraT struct { - meta []byte - seqNo sqn.SeqNo - ver string + meta []byte + seqNo sqn.SeqNo + ver string + components []byte } // Minimize the size of this structure. @@ -99,16 +100,17 @@ func (bc *Bulk) timestamp() string { // CheckIn will add the agent (identified by id) to the pending set. // The pending agents are sent to elasticsearch as a bulk update at each flush interval. // WARNING: Bulk will take ownership of fields, so do not use after passing in. -func (bc *Bulk) CheckIn(id string, status string, message string, meta []byte, seqno sqn.SeqNo, newVer string) error { +func (bc *Bulk) CheckIn(id string, status string, message string, meta []byte, components []byte, seqno sqn.SeqNo, newVer string) error { // Separate out the extra data to minimize // the memory footprint of the 90% case of just // updating the timestamp. var extra *extraT - if meta != nil || seqno.IsSet() || newVer != "" { + if meta != nil || seqno.IsSet() || newVer != "" || components != nil { extra = &extraT{ - meta: meta, - seqNo: seqno, - ver: newVer, + meta: meta, + seqNo: seqno, + ver: newVer, + components: components, } } @@ -217,6 +219,11 @@ func (bc *Bulk) flush(ctx context.Context) error { fields[dl.FieldLocalMetadata] = json.RawMessage(pendingData.extra.meta) } + // Update components if provided + if pendingData.extra.components != nil { + fields[dl.FieldComponents] = json.RawMessage(pendingData.extra.components) + } + // If seqNo changed, set the field appropriately if pendingData.extra.seqNo.IsSet() { fields[dl.FieldActionSeqNo] = pendingData.extra.seqNo diff --git a/internal/pkg/checkin/bulk_test.go b/internal/pkg/checkin/bulk_test.go index 0ba931996..8ca60c137 100644 --- a/internal/pkg/checkin/bulk_test.go +++ b/internal/pkg/checkin/bulk_test.go @@ -79,13 +79,14 @@ func matchOp(tb testing.TB, c bulkcase, ts time.Time) func(ops []bulk.MultiOp) b } type bulkcase struct { - desc string - id string - status string - message string - meta []byte - seqno sqn.SeqNo - ver string + desc string + id string + status string + message string + meta []byte + components []byte + seqno sqn.SeqNo + ver string } func TestBulkSimple(t *testing.T) { @@ -100,6 +101,7 @@ func TestBulkSimple(t *testing.T) { "message", nil, nil, + nil, "", }, { @@ -108,6 +110,7 @@ func TestBulkSimple(t *testing.T) { "online", "message", []byte(`{"hey":"now"}`), + []byte(`[{"id":"winlog-default"}]`), nil, "", }, @@ -117,6 +120,7 @@ func TestBulkSimple(t *testing.T) { "online", "message", []byte(`{"hey":"now","brown":"cow"}`), + []byte(`[{"id":"winlog-default","type":"winlog"}]`), nil, ver, }, @@ -126,6 +130,7 @@ func TestBulkSimple(t *testing.T) { "online", "message", []byte(`{"hey":"now","wee":{"little":"doggie"}}`), + []byte(`[{"id":"winlog-default","type":"winlog"}]`), nil, "", }, @@ -135,6 +140,7 @@ func TestBulkSimple(t *testing.T) { "online", "message", nil, + nil, sqn.SeqNo{1, 2, 3, 4}, ver, }, @@ -144,6 +150,7 @@ func TestBulkSimple(t *testing.T) { "online", "message", []byte(`{"uncle":"fester"}`), + []byte(`[{"id":"log-default"}]`), sqn.SeqNo{5, 6, 7, 8}, ver, }, @@ -154,6 +161,7 @@ func TestBulkSimple(t *testing.T) { "message", nil, nil, + nil, "", }, { @@ -163,6 +171,7 @@ func TestBulkSimple(t *testing.T) { "message", nil, nil, + nil, "", }, } @@ -174,7 +183,7 @@ func TestBulkSimple(t *testing.T) { mockBulk.On("MUpdate", mock.Anything, mock.MatchedBy(matchOp(t, c, start)), mock.Anything).Return([]bulk.BulkIndexerResponseItem{}, nil).Once() bc := NewBulk(mockBulk) - if err := bc.CheckIn(c.id, c.status, c.message, c.meta, c.seqno, c.ver); err != nil { + if err := bc.CheckIn(c.id, c.status, c.message, c.meta, c.components, c.seqno, c.ver); err != nil { t.Fatal(err) } @@ -212,7 +221,7 @@ func benchmarkBulk(n int, flush bool, b *testing.B) { for i := 0; i < b.N; i++ { for _, id := range ids { - err := bc.CheckIn(id, "", "", nil, nil, "") + err := bc.CheckIn(id, "", "", nil, nil, nil, "") if err != nil { b.Fatal(err) } diff --git a/internal/pkg/dl/constants.go b/internal/pkg/dl/constants.go index f55bb7123..7d1f90555 100644 --- a/internal/pkg/dl/constants.go +++ b/internal/pkg/dl/constants.go @@ -35,6 +35,7 @@ const ( FieldLastCheckinStatus = "last_checkin_status" FieldLastCheckinMessage = "last_checkin_message" FieldLocalMetadata = "local_metadata" + FieldComponents = "components" FieldPolicyCoordinatorIdx = "policy_coordinator_idx" FieldPolicyID = "policy_id" FieldPolicyOutputAPIKey = "api_key" diff --git a/internal/pkg/logger/logger.go b/internal/pkg/logger/logger.go index c3b87e14b..9f6d79caa 100644 --- a/internal/pkg/logger/logger.go +++ b/internal/pkg/logger/logger.go @@ -99,7 +99,7 @@ func changed(a *config.Config, b *config.Config) bool { if al != bl { return true } - if (aFiles == nil && bFiles != nil) || (aFiles != nil && bFiles == nil) || (*aFiles != *bFiles) { + if (aFiles == nil && bFiles != nil) || (aFiles != nil && bFiles == nil) || ((aFiles != nil && bFiles != nil) && *aFiles != *bFiles) { return true } return false diff --git a/internal/pkg/model/schema.go b/internal/pkg/model/schema.go index 0dc0ac947..ae45c1c0a 100644 --- a/internal/pkg/model/schema.go +++ b/internal/pkg/model/schema.go @@ -124,6 +124,9 @@ type Agent struct { Active bool `json:"active"` Agent *AgentMetadata `json:"agent,omitempty"` + // Elastic Agent components detailed status information + Components json.RawMessage `json:"components,omitempty"` + // Deprecated. Use Outputs instead. API key the Elastic Agent uses to authenticate with elasticsearch DefaultAPIKey string `json:"default_api_key,omitempty"` @@ -252,6 +255,10 @@ type Artifact struct { type Body struct { } +// Components Elastic Agent components detailed status information +type Components struct { +} + // Data The opaque payload. type Data struct { } diff --git a/internal/pkg/policy/self.go b/internal/pkg/policy/self.go index d0ef942f9..da1c40887 100644 --- a/internal/pkg/policy/self.go +++ b/internal/pkg/policy/self.go @@ -9,10 +9,10 @@ import ( "encoding/json" "errors" "fmt" + "github.com/elastic/elastic-agent-client/v7/pkg/client" "sync" "time" - "github.com/elastic/elastic-agent-client/v7/pkg/proto" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -22,7 +22,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/model" "github.com/elastic/fleet-server/v7/internal/pkg/monitor" - "github.com/elastic/fleet-server/v7/internal/pkg/status" + "github.com/elastic/fleet-server/v7/internal/pkg/state" ) // DefaultCheckTime is the default interval for self to check for its policy. @@ -33,8 +33,8 @@ type enrollmentTokenFetcher func(ctx context.Context, bulker bulk.Bulk, policyID type SelfMonitor interface { // Run runs the monitor. Run(ctx context.Context) error - // Status gets current status of monitor. - Status() proto.StateObserved_Status + // State gets current state of monitor. + State() client.UnitState } type selfMonitorT struct { @@ -46,8 +46,8 @@ type selfMonitorT struct { monitor monitor.Monitor policyID string - status proto.StateObserved_Status - reporter status.Reporter + state client.UnitState + reporter state.Reporter policy *model.Policy @@ -63,14 +63,14 @@ type selfMonitorT struct { // // Ensures that the policy that this Fleet Server attached to exists and that it // has a Fleet Server input defined. -func NewSelfMonitor(fleet config.Fleet, bulker bulk.Bulk, monitor monitor.Monitor, policyID string, reporter status.Reporter) SelfMonitor { +func NewSelfMonitor(fleet config.Fleet, bulker bulk.Bulk, monitor monitor.Monitor, policyID string, reporter state.Reporter) SelfMonitor { return &selfMonitorT{ log: log.With().Str("ctx", "policy self monitor").Logger(), fleet: fleet, bulker: bulker, monitor: monitor, policyID: policyID, - status: proto.StateObserved_STARTING, + state: client.UnitStateStarting, reporter: reporter, policyF: dl.QueryLatestPolicies, policiesIndex: dl.FleetPolicies, @@ -101,12 +101,12 @@ LOOP: case <-ctx.Done(): break LOOP case <-cT.C: - status, err := m.process(ctx) + state, err := m.process(ctx) if err != nil { return err } cT.Reset(m.checkTime) - if status == proto.StateObserved_HEALTHY { + if state == client.UnitStateHealthy { // running; can stop break LOOP } @@ -118,11 +118,11 @@ LOOP: return err } } - status, err := m.processPolicies(ctx, policies) + state, err := m.processPolicies(ctx, policies) if err != nil { return err } - if status == proto.StateObserved_HEALTHY { + if state == client.UnitStateHealthy { // running; can stop break LOOP } @@ -132,10 +132,10 @@ LOOP: return nil } -func (m *selfMonitorT) Status() proto.StateObserved_Status { +func (m *selfMonitorT) State() client.UnitState { m.mut.Lock() defer m.mut.Unlock() - return m.status + return m.state } func (m *selfMonitorT) waitStart(ctx context.Context) error { //nolint:unused // not sure if this is used in tests @@ -147,24 +147,24 @@ func (m *selfMonitorT) waitStart(ctx context.Context) error { //nolint:unused // return nil } -func (m *selfMonitorT) process(ctx context.Context) (proto.StateObserved_Status, error) { +func (m *selfMonitorT) process(ctx context.Context) (client.UnitState, error) { policies, err := m.policyF(ctx, m.bulker, dl.WithIndexName(m.policiesIndex)) if err != nil { if !errors.Is(err, es.ErrIndexNotFound) { - return proto.StateObserved_FAILED, nil + return client.UnitStateFailed, nil } m.log.Debug().Str("index", m.policiesIndex).Msg(es.ErrIndexNotFound.Error()) } if len(policies) == 0 { - return m.updateStatus(ctx) + return m.updateState(ctx) } return m.processPolicies(ctx, policies) } -func (m *selfMonitorT) processPolicies(ctx context.Context, policies []model.Policy) (proto.StateObserved_Status, error) { +func (m *selfMonitorT) processPolicies(ctx context.Context, policies []model.Policy) (client.UnitState, error) { if len(policies) == 0 { // nothing to do - return proto.StateObserved_STARTING, nil + return client.UnitStateStarting, nil } latest := m.groupByLatest(policies) for i := range latest { @@ -177,77 +177,77 @@ func (m *selfMonitorT) processPolicies(ctx context.Context, policies []model.Pol break } } - return m.updateStatus(ctx) + return m.updateState(ctx) } func (m *selfMonitorT) groupByLatest(policies []model.Policy) map[string]model.Policy { return groupByLatest(policies) } -func (m *selfMonitorT) updateStatus(ctx context.Context) (proto.StateObserved_Status, error) { +func (m *selfMonitorT) updateState(ctx context.Context) (client.UnitState, error) { m.mut.Lock() defer m.mut.Unlock() if m.policy == nil { // no policy found - m.status = proto.StateObserved_STARTING + m.state = client.UnitStateStarting if m.policyID == "" { - m.reporter.Status(proto.StateObserved_STARTING, "Waiting on default policy with Fleet Server integration", nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, "Waiting on default policy with Fleet Server integration", nil) //nolint:errcheck // not clear what to do in failure cases } else { - m.reporter.Status(proto.StateObserved_STARTING, fmt.Sprintf("Waiting on policy with Fleet Server integration: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, fmt.Sprintf("Waiting on policy with Fleet Server integration: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases } - return proto.StateObserved_STARTING, nil + return client.UnitStateStarting, nil } var data policyData err := json.Unmarshal(m.policy.Data, &data) if err != nil { - return proto.StateObserved_FAILED, err + return client.UnitStateFailed, err } if !data.HasType("fleet-server") { // no fleet-server input - m.status = proto.StateObserved_STARTING + m.state = client.UnitStateStarting if m.policyID == "" { - m.reporter.Status(proto.StateObserved_STARTING, "Waiting on fleet-server input to be added to default policy", nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, "Waiting on fleet-server input to be added to default policy", nil) //nolint:errcheck // not clear what to do in failure cases } else { - m.reporter.Status(proto.StateObserved_STARTING, fmt.Sprintf("Waiting on fleet-server input to be added to policy: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, fmt.Sprintf("Waiting on fleet-server input to be added to policy: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases } - return proto.StateObserved_STARTING, nil + return client.UnitStateStarting, nil } - status := proto.StateObserved_HEALTHY + state := client.UnitStateHealthy extendMsg := "" var payload map[string]interface{} if m.fleet.Agent.ID == "" { - status = proto.StateObserved_DEGRADED + state = client.UnitStateDegraded extendMsg = "; missing config fleet.agent.id (expected during bootstrap process)" // Elastic Agent has not been enrolled; Fleet Server passes back the enrollment token so the Elastic Agent // can perform enrollment. tokens, err := m.enrollmentTokenF(ctx, m.bulker, m.policy.PolicyID) if err != nil { - return proto.StateObserved_FAILED, err + return client.UnitStateFailed, err } if len(tokens) == 0 { // no tokens created for the policy, still starting if m.policyID == "" { - m.reporter.Status(proto.StateObserved_STARTING, "Waiting on active enrollment keys to be created in default policy with Fleet Server integration", nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, "Waiting on active enrollment keys to be created in default policy with Fleet Server integration", nil) //nolint:errcheck // not clear what to do in failure cases } else { - m.reporter.Status(proto.StateObserved_STARTING, fmt.Sprintf("Waiting on active enrollment keys to be created in policy with Fleet Server integration: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(client.UnitStateStarting, fmt.Sprintf("Waiting on active enrollment keys to be created in policy with Fleet Server integration: %s", m.policyID), nil) //nolint:errcheck // not clear what to do in failure cases } - return proto.StateObserved_STARTING, nil + return client.UnitStateStarting, nil } payload = map[string]interface{}{ "enrollment_token": tokens[0].APIKey, } } - m.status = status + m.state = state if m.policyID == "" { - m.reporter.Status(status, fmt.Sprintf("Running on default policy with Fleet Server integration%s", extendMsg), payload) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(state, fmt.Sprintf("Running on default policy with Fleet Server integration%s", extendMsg), payload) //nolint:errcheck // not clear what to do in failure cases } else { - m.reporter.Status(status, fmt.Sprintf("Running on policy with Fleet Server integration: %s%s", m.policyID, extendMsg), payload) //nolint:errcheck // not clear what to do in failure cases + m.reporter.UpdateState(state, fmt.Sprintf("Running on policy with Fleet Server integration: %s%s", m.policyID, extendMsg), payload) //nolint:errcheck // not clear what to do in failure cases } - return status, nil + return state, nil } type policyData struct { diff --git a/internal/pkg/policy/self_test.go b/internal/pkg/policy/self_test.go index 2d81c8274..88a44b39a 100644 --- a/internal/pkg/policy/self_test.go +++ b/internal/pkg/policy/self_test.go @@ -15,7 +15,7 @@ import ( "testing" "time" - "github.com/elastic/elastic-agent-client/v7/pkg/proto" + "github.com/elastic/elastic-agent-client/v7/pkg/client" "github.com/gofrs/uuid" "github.com/rs/xid" "github.com/stretchr/testify/mock" @@ -69,9 +69,9 @@ func TestSelfMonitor_DefaultPolicy(t *testing.T) { // should be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != "Waiting on default policy with Fleet Server integration" { return fmt.Errorf("should be matching with default policy") @@ -110,9 +110,9 @@ func TestSelfMonitor_DefaultPolicy(t *testing.T) { // should still be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != "Waiting on fleet-server input to be added to default policy" { return fmt.Errorf("should be matching with default policy") @@ -154,9 +154,9 @@ func TestSelfMonitor_DefaultPolicy(t *testing.T) { // should now be set to healthy ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_HEALTHY { - return fmt.Errorf("should be reported as healthy; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateHealthy { + return fmt.Errorf("should be reported as healthy; instead its %s", state) } if msg != "Running on default policy with Fleet Server integration" { return fmt.Errorf("should be matching with default policy") @@ -225,9 +225,9 @@ func TestSelfMonitor_DefaultPolicy_Degraded(t *testing.T) { // should be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != "Waiting on default policy with Fleet Server integration" { return fmt.Errorf("should be matching with default policy") @@ -276,9 +276,9 @@ func TestSelfMonitor_DefaultPolicy_Degraded(t *testing.T) { // should be set to starting because of missing active enrollment keys ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != "Waiting on active enrollment keys to be created in default policy with Fleet Server integration" { return fmt.Errorf("should be matching with default policy") @@ -303,9 +303,9 @@ func TestSelfMonitor_DefaultPolicy_Degraded(t *testing.T) { // should now be set to degraded ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, payload := reporter.Current() - if status != proto.StateObserved_DEGRADED { - return fmt.Errorf("should be reported as degraded; instead its %s", status) + state, msg, payload := reporter.Current() + if state != client.UnitStateDegraded { + return fmt.Errorf("should be reported as degraded; instead its %s", state) } if msg != "Running on default policy with Fleet Server integration; missing config fleet.agent.id (expected during bootstrap process)" { return fmt.Errorf("should be matching with default policy") @@ -371,9 +371,9 @@ func TestSelfMonitor_SpecificPolicy(t *testing.T) { // should be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != fmt.Sprintf("Waiting on policy with Fleet Server integration: %s", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -411,9 +411,9 @@ func TestSelfMonitor_SpecificPolicy(t *testing.T) { // should still be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != fmt.Sprintf("Waiting on fleet-server input to be added to policy: %s", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -455,9 +455,9 @@ func TestSelfMonitor_SpecificPolicy(t *testing.T) { // should now be set to healthy ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_HEALTHY { - return fmt.Errorf("should be reported as healthy; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateHealthy { + return fmt.Errorf("should be reported as healthy; instead its %s", state) } if msg != fmt.Sprintf("Running on policy with Fleet Server integration: %s", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -527,9 +527,9 @@ func TestSelfMonitor_SpecificPolicy_Degraded(t *testing.T) { // should be set to starting ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != fmt.Sprintf("Waiting on policy with Fleet Server integration: %s", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -577,9 +577,9 @@ func TestSelfMonitor_SpecificPolicy_Degraded(t *testing.T) { // should be set to starting because of missing active enrollment keys ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, _ := reporter.Current() - if status != proto.StateObserved_STARTING { - return fmt.Errorf("should be reported as starting; instead its %s", status) + state, msg, _ := reporter.Current() + if state != client.UnitStateStarting { + return fmt.Errorf("should be reported as starting; instead its %s", state) } if msg != fmt.Sprintf("Waiting on active enrollment keys to be created in policy with Fleet Server integration: %s", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -604,9 +604,9 @@ func TestSelfMonitor_SpecificPolicy_Degraded(t *testing.T) { // should now be set to degraded ftesting.Retry(t, ctx, func(ctx context.Context) error { - status, msg, payload := reporter.Current() - if status != proto.StateObserved_DEGRADED { - return fmt.Errorf("should be reported as degraded; instead its %s", status) + state, msg, payload := reporter.Current() + if state != client.UnitStateDegraded { + return fmt.Errorf("should be reported as degraded; instead its %s", state) } if msg != fmt.Sprintf("Running on policy with Fleet Server integration: %s; missing config fleet.agent.id (expected during bootstrap process)", policyID) { return fmt.Errorf("should be matching with specific policy") @@ -633,22 +633,22 @@ func TestSelfMonitor_SpecificPolicy_Degraded(t *testing.T) { type FakeReporter struct { lock sync.Mutex - status proto.StateObserved_Status + state client.UnitState msg string payload map[string]interface{} } -func (r *FakeReporter) Status(status proto.StateObserved_Status, message string, payload map[string]interface{}) error { +func (r *FakeReporter) UpdateState(state client.UnitState, message string, payload map[string]interface{}) error { r.lock.Lock() defer r.lock.Unlock() - r.status = status + r.state = state r.msg = message r.payload = payload return nil } -func (r *FakeReporter) Current() (proto.StateObserved_Status, string, map[string]interface{}) { +func (r *FakeReporter) Current() (client.UnitState, string, map[string]interface{}) { r.lock.Lock() defer r.lock.Unlock() - return r.status, r.msg, r.payload + return r.state, r.msg, r.payload } diff --git a/internal/pkg/server/agent.go b/internal/pkg/server/agent.go index 56b5adfd5..dcfddf807 100644 --- a/internal/pkg/server/agent.go +++ b/internal/pkg/server/agent.go @@ -8,24 +8,28 @@ import ( "context" "errors" "fmt" + "github.com/elastic/fleet-server/v7/internal/pkg/sleep" + "github.com/elastic/fleet-server/v7/internal/pkg/state" "io" "sync" "time" "github.com/elastic/elastic-agent-client/v7/pkg/client" - "github.com/elastic/go-ucfg" - "github.com/elastic/go-ucfg/yaml" - "github.com/elastic/fleet-server/v7/internal/pkg/build" "github.com/elastic/fleet-server/v7/internal/pkg/config" "github.com/elastic/fleet-server/v7/internal/pkg/reload" - "github.com/elastic/fleet-server/v7/internal/pkg/sleep" - "github.com/elastic/fleet-server/v7/internal/pkg/status" - + "github.com/elastic/go-ucfg" "github.com/rs/zerolog/log" ) -const kAgentModeRestartLoopDelay = 2 * time.Second +const ( + kAgentModeRestartLoopDelay = 2 * time.Second + + kFleetServer = "fleet-server" + kElasticsearch = "elasticsearch" + + kStopped = "Stopped" +) type firstCfg struct { cfg *config.Config @@ -40,14 +44,15 @@ type Agent struct { bi build.Info reloadables []reload.Reloadable - agent client.Client + agent client.V2 + + outputUnit *client.Unit + inputUnit *client.Unit - mux sync.Mutex - firstCfg chan firstCfg srv *Fleet srvCtx context.Context srvCanceller context.CancelFunc - startChan chan struct{} + srvDone chan bool } // NewAgent returns an Agent that will gather connection information from the passed reader. @@ -59,7 +64,14 @@ func NewAgent(cliCfg *ucfg.Config, reader io.Reader, bi build.Info, reloadables bi: bi, reloadables: reloadables, } - a.agent, err = client.NewFromReader(reader, a) + a.agent, _, err = client.NewV2FromReader(reader, client.VersionInfo{ + Name: kFleetServer, + Version: bi.Version, + Meta: map[string]string{ + "commit": bi.Commit, + "build_time": bi.BuildTime.String(), + }, + }) if err != nil { return nil, err } @@ -68,180 +80,310 @@ func NewAgent(cliCfg *ucfg.Config, reader io.Reader, bi build.Info, reloadables // Run starts a Server instance using config from the configured client. func (a *Agent) Run(ctx context.Context) error { - ctx, canceller := context.WithCancel(ctx) - defer canceller() + subCtx, subCanceller := context.WithCancel(ctx) + defer subCanceller() + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + + t := time.NewTicker(1 * time.Second) + defer t.Stop() + for { + select { + case <-subCtx.Done(): + return + case err := <-a.agent.Errors(): + if err != nil && !errors.Is(err, context.Canceled) && !errors.Is(err, io.EOF) { + log.Error().Err(err) + } + case change := <-a.agent.UnitChanges(): + switch change.Type { + case client.UnitChangedAdded: + err := a.unitAdded(subCtx, change.Unit) + if err != nil { + log.Error().Str("unit", change.Unit.ID()).Err(err) + _ = change.Unit.UpdateState(client.UnitStateFailed, err.Error(), nil) + } + case client.UnitChangedModified: + err := a.unitModified(subCtx, change.Unit) + if err != nil { + log.Error().Str("unit", change.Unit.ID()).Err(err) + _ = change.Unit.UpdateState(client.UnitStateFailed, err.Error(), nil) + } + case client.UnitChangedRemoved: + a.unitRemoved(change.Unit) + } + case <-t.C: + // Fleet Server is the only component that gets started by Elastic Agent without an Agent ID. We loop + // here on interval waiting for the Elastic Agent to enroll so then the Agent ID is then set. + agentInfo := a.agent.AgentInfo() + if agentInfo != nil && agentInfo.ID != "" { + // Agent ID is not set for the component. + t.Stop() + err := a.reconfigure(subCtx) + if err != nil { + log.Error().Err(err) + } + } + } + } + }() - a.firstCfg = make(chan firstCfg) - a.startChan = make(chan struct{}, 1) log.Info().Msg("starting communication connection back to Elastic Agent") - err := a.agent.Start(ctx) + err := a.agent.Start(subCtx) if err != nil { return err } - // wait for the initial configuration to be sent from the - // Elastic Agent before starting the actual Fleet Server. - log.Info().Msg("waiting for Elastic Agent to send initial configuration") - var cfg firstCfg - select { - case <-ctx.Done(): - return fmt.Errorf("never received initial configuration: %w", ctx.Err()) - case cfg = <-a.firstCfg: + <-subCtx.Done() + wg.Wait() + + return nil +} + +// UpdateState updates the state of the message and payload. +func (a *Agent) UpdateState(state client.UnitState, message string, payload map[string]interface{}) error { + if a.inputUnit != nil { + _ = a.inputUnit.UpdateState(state, message, payload) + } + if a.outputUnit != nil { + _ = a.outputUnit.UpdateState(state, message, payload) + } + return nil +} + +func (a *Agent) unitAdded(ctx context.Context, unit *client.Unit) error { + if unit.Type() == client.UnitTypeInput { + _, _, cfg := unit.Expected() + if cfg.Type != kFleetServer { + // not support input type + _ = unit.UpdateState(client.UnitStateFailed, fmt.Sprintf("%s is an unsupported input type", cfg.Type), nil) + return nil + } + if a.inputUnit != nil { + // original input unit is being stopped; swapping in this unit as the new input unit + _ = a.inputUnit.UpdateState(client.UnitStateStopped, kStopped, nil) + } + a.inputUnit = unit + if a.outputUnit == nil { + // waiting for output unit to really start Fleet Server + _ = unit.UpdateState(client.UnitStateStarting, "waiting for output unit", nil) + return nil + } + return a.start(ctx) + } + if unit.Type() == client.UnitTypeOutput { + _, _, cfg := unit.Expected() + if cfg.Type != kElasticsearch { + // not support output type + _ = unit.UpdateState(client.UnitStateFailed, fmt.Sprintf("%s is an unsupported output type", cfg.Type), nil) + return nil + } + if a.outputUnit != nil { + // original output unit is being stopped; swapping in this unit as the new output unit + _ = a.outputUnit.UpdateState(client.UnitStateStopped, kStopped, nil) + } + a.outputUnit = unit + if a.inputUnit == nil { + // waiting for input unit to really start Fleet Server + _ = unit.UpdateState(client.UnitStateStarting, "waiting for input unit", nil) + return nil + } + return a.start(ctx) + } + return fmt.Errorf("unknown unit type %v", unit.Type()) +} + +func (a *Agent) unitModified(ctx context.Context, unit *client.Unit) error { + state, _, _ := unit.Expected() + if unit.Type() == client.UnitTypeInput { + if a.inputUnit != unit { + // not our input unit; would have been marked failed in unitAdded; do nothing + return nil + } + if state == client.UnitStateHealthy { + if a.outputUnit == nil { + // still no output unit; would have been marked starting already; do nothing + return nil + } + + // configuration modified (should still be running) + return a.reconfigure(ctx) + } else if state == client.UnitStateStopped { + // unit should be stopped + a.stop() + return nil + } + return fmt.Errorf("unknown unit state %v", state) + } + if unit.Type() == client.UnitTypeOutput { + if a.outputUnit != unit { + // not our output unit; would have been marked failed in unitAdded; do nothing + return nil + } + if state == client.UnitStateHealthy { + if a.inputUnit == nil { + // still no input unit; would have been marked starting already; do nothing + return nil + } + + // configuration modified (should still be running) + return a.reconfigure(ctx) + } else if state == client.UnitStateStopped { + // unit should be stopped + a.stop() + return nil + } + return fmt.Errorf("unknown unit state %v", state) + } + return fmt.Errorf("unknown unit type %v", unit.Type()) +} + +func (a *Agent) unitRemoved(unit *client.Unit) { + stop := false + if a.inputUnit == unit || a.outputUnit == unit { + stop = true + } + if stop { + a.stop() + } + if a.inputUnit == unit { + a.inputUnit = nil + } + if a.outputUnit == unit { + a.outputUnit = nil } +} - // possible that first configuration resulted in an error - if cfg.err != nil { - // unblock startChan even though there was an error - a.startChan <- struct{}{} - return cfg.err +func (a *Agent) start(ctx context.Context) error { + if a.srv != nil { + return a.reconfigure(ctx) } - // start fleet server with the initial configuration and its - // own context (needed so when OnStop occurs the fleet server - // is stopped and not the elastic-agent-client as well) - srvCtx, srvCancel := context.WithCancel(ctx) - defer srvCancel() - log.Info().Msg("received initial configuration starting Fleet Server") - srv, err := NewFleet(cfg.cfg, a.bi, status.NewChained(status.NewLog(), a.agent)) + cfg, err := a.configFromUnits() if err != nil { - // unblock startChan even though there was an error - a.startChan <- struct{}{} return err } - a.mux.Lock() - close(a.firstCfg) - a.firstCfg = nil - a.srv = srv - a.srvCtx = srvCtx - a.srvCanceller = srvCancel - a.mux.Unlock() - // trigger startChan so OnConfig can continue - a.startChan <- struct{}{} + // reload the generic reloadables + for _, r := range a.reloadables { + err = r.Reload(ctx, cfg) + if err != nil { + return err + } + } + + srvDone := make(chan bool) + srvCtx, srvCanceller := context.WithCancel(ctx) + srv, err := NewFleet(a.bi, state.NewChained(state.NewLog(), a)) + if err != nil { + close(srvDone) + srvCanceller() + return err + } - // keep trying to restart the FleetServer on failure, reporting - // the status back to Elastic Agent - res := make(chan error) go func() { + defer close(srvDone) for { - err := a.srv.Run(srvCtx) + err := srv.Run(srvCtx, cfg) if err == nil || errors.Is(err, context.Canceled) { - res <- err return } // sleep some before calling Run again _ = sleep.WithContext(srvCtx, kAgentModeRestartLoopDelay) } }() - return <-res -} -// OnConfig defines what the fleet-server running under the elastic-agent does when it receives a new config. -// This is part of the client.StateInterface definition. -func (a *Agent) OnConfig(s string) { - a.mux.Lock() - cliCfg := ucfg.MustNewFrom(a.cliCfg, config.DefaultOptions...) - srv := a.srv - ctx := a.srvCtx - canceller := a.srvCanceller - cfgChan := a.firstCfg - startChan := a.startChan - a.mux.Unlock() - - var cfg *config.Config - var err error - defer func() { - if err != nil { - if cfgChan != nil { - // failure on first config - cfgChan <- firstCfg{ - cfg: nil, - err: err, - } - // block until startChan signalled - <-startChan - return - } - - log.Err(err).Msg("failed to reload configuration") - if canceller != nil { - canceller() - } - } - }() + a.srv = srv + a.srvCtx = srvCtx + a.srvCanceller = srvCanceller + a.srvDone = srvDone + return nil +} - // load configuration and then merge it on top of the CLI configuration - var cfgData *ucfg.Config - cfgData, err = yaml.NewConfig([]byte(s), config.DefaultOptions...) - if err != nil { - return +func (a *Agent) reconfigure(ctx context.Context) error { + if a.srv == nil { + return a.start(ctx) } - err = cliCfg.Merge(cfgData, config.DefaultOptions...) - if err != nil { - return - } - cfg, err = config.FromConfig(cliCfg) + + cfg, err := a.configFromUnits() if err != nil { - return + return err } - // Pass config if it's the initial config on startup - // TODO maybe use sync.Once to make it clear that this block only occurs on startup? - if cfgChan != nil { - // reload the generic reloadables - for _, r := range a.reloadables { - err = r.Reload(ctx, cfg) - if err != nil { - return - } - } - - // send starting configuration so Fleet Server can start - cfgChan <- firstCfg{ - cfg: cfg, - err: nil, + // reload the generic reloadables + for _, r := range a.reloadables { + err = r.Reload(ctx, cfg) + if err != nil { + return err } + } - // block handling more OnConfig calls until the Fleet Server - // has been fully started - <-startChan - } else if srv != nil { // Reload config if the server is running. - // reload the generic reloadables - for _, r := range a.reloadables { - err = r.Reload(ctx, cfg) - if err != nil { - return - } - } + return a.srv.Reload(ctx, cfg) +} - // reload the server - err = srv.Reload(ctx, cfg) - if err != nil { - return - } - } else { - err = fmt.Errorf("internal service should have been started") +func (a *Agent) stop() { + if a.srvCanceller == nil { return } -} -// OnStop defines what the fleet-server running under the elastic-agent does when the agent sends a stop signal. -// This is part of the client.StateInterface definition. -// The root context will be cancelled to stop. -func (a *Agent) OnStop() { - a.mux.Lock() canceller := a.srvCanceller - a.mux.Unlock() + a.srvCanceller = nil + a.srvCtx = nil + a.srv = nil + canceller() + <-a.srvDone + a.srvDone = nil - if canceller != nil { - canceller() + if a.inputUnit != nil { + _ = a.inputUnit.UpdateState(client.UnitStateStopped, kStopped, nil) + } + if a.outputUnit != nil { + _ = a.outputUnit.UpdateState(client.UnitStateStopped, kStopped, nil) } } -// OnError defines what the fleet-server running under the elastic-agent does when there is an error communicating with the elastic-agent. -// This is part of the client.StateInterface definition. -// Communication errors will be logged. The elastic-agent-client handles -// retries and reconnects internally automatically. -func (a *Agent) OnError(err error) { - log.Err(err) +// configFromUnits takes both inputUnit and outputUnit and creates a single configuration just like fleet server was +// being started from a configuration file. +func (a *Agent) configFromUnits() (*config.Config, error) { + agentID := "" + agentVersion := "" + agentInfo := a.agent.AgentInfo() + if agentInfo != nil { + agentID = agentInfo.ID + agentVersion = agentInfo.Version + } + _, inputLevel, inputCfg := a.inputUnit.Expected() + _, outputLevel, outputCfg := a.outputUnit.Expected() + logLevel := inputLevel + if outputLevel > logLevel { + logLevel = outputLevel + } + + cfgData, err := ucfg.NewFrom(map[string]interface{}{ + "fleet": map[string]interface{}{ + "agent": map[string]interface{}{ + "id": agentID, + "version": agentVersion, + "logging": map[string]interface{}{ + "level": logLevel.String(), + }, + }, + }, + "output": map[string]interface{}{ + "elasticsearch": outputCfg.Source.AsMap(), + }, + "inputs": []interface{}{ + inputCfg.Source.AsMap(), + }, + "logging": map[string]interface{}{ + "level": logLevel.String(), + }, + }) + if err != nil { + return nil, err + } + return config.FromConfig(cfgData) } diff --git a/internal/pkg/server/agent_integration_test.go b/internal/pkg/server/agent_integration_test.go new file mode 100644 index 000000000..00862f4a8 --- /dev/null +++ b/internal/pkg/server/agent_integration_test.go @@ -0,0 +1,402 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +//go:build integration +// +build integration + +package server + +import ( + "context" + "errors" + "fmt" + "net" + "os" + "strings" + "sync" + "testing" + "time" + + "github.com/elastic/elastic-agent-client/v7/pkg/client" + "github.com/elastic/elastic-agent-client/v7/pkg/client/mock" + "github.com/elastic/elastic-agent-client/v7/pkg/proto" + "github.com/elastic/go-ucfg" + "github.com/gofrs/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/protobuf/types/known/structpb" + + "github.com/elastic/fleet-server/v7/internal/pkg/build" + "github.com/elastic/fleet-server/v7/internal/pkg/dl" + "github.com/elastic/fleet-server/v7/internal/pkg/model" + ftesting "github.com/elastic/fleet-server/v7/internal/pkg/testing" +) + +var biInfo = build.Info{ + Version: "1.0.0", + Commit: "integration", +} + +var policyData = []byte(` +{ + "outputs": { + "default": { + "type": "elasticsearch" + } + }, + "inputs": [ + { + "type": "fleet-server" + } + ] +} +`) + +func TestAgent(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + bulker := ftesting.SetupBulk(ctx, t) + + // add a real default fleet server policy + policyID := uuid.Must(uuid.NewV4()).String() + _, err := dl.CreatePolicy(ctx, bulker, model.Policy{ + PolicyID: policyID, + RevisionIdx: 1, + DefaultFleetServer: true, + Data: policyData, + }) + require.NoError(t, err) + + // add entry for enrollment key (doesn't have to be a real key) + _, err = dl.CreateEnrollmentAPIKey(ctx, bulker, model.EnrollmentAPIKey{ + Name: "Default", + APIKey: "keyvalue", + APIKeyID: "keyid", + PolicyID: policyID, + Active: true, + }) + require.NoError(t, err) + + inputSource, err := structpb.NewStruct(map[string]interface{}{ + "id": "fleet-server", + "type": "fleet-server", + "name": "fleet-server", + "revision": 1, + }) + require.NoError(t, err) + outputSource, err := structpb.NewStruct(map[string]interface{}{ + "id": "default", + "type": "elasticsearch", + "name": "elasticsearch", + "revision": 1, + "hosts": getESHosts(), + "service_token": getESServiceToken(), + }) + require.NoError(t, err) + expected := makeExpected("", 1, inputSource, 1, outputSource) + control := createAndStartControlServer(t, expected) + defer control.Stop() + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + + a := &Agent{ + cliCfg: ucfg.New(), + bi: biInfo, + } + a.agent = client.NewV2(fmt.Sprintf("localhost:%d", control.Port()), control.Token(), client.VersionInfo{ + Name: "fleet-server", + Version: "1.0.0", + }, grpc.WithTransportCredentials(insecure.NewCredentials())) + err = a.Run(ctx) + assert.NoError(t, err) + }() + + // wait for fleet-server to report as degraded (starting mode without agent.id) + ftesting.Retry(t, ctx, func(ctx context.Context) error { + state := getUnitState(control, proto.UnitType_INPUT, "fleet-server-default-fleet-server") + if state != proto.State_DEGRADED { + return fmt.Errorf("should be reported as degraded; instead its %s", state) + } + return nil + }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) + + // reconfigure with agent ID set + agentID := uuid.Must(uuid.NewV4()).String() + expected = makeExpected(agentID, 1, inputSource, 1, outputSource) + control.Expected(expected) + require.NoError(t, err) + + // wait for fleet-server to report as healthy + ftesting.Retry(t, ctx, func(ctx context.Context) error { + state := getUnitState(control, proto.UnitType_INPUT, "fleet-server-default-fleet-server") + if state != proto.State_HEALTHY { + return fmt.Errorf("should be reported as healthy; instead its %s", state) + } + return nil + }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) + + // trigger update with bad configuration + badSource, err := structpb.NewStruct(map[string]interface{}{ + "id": "default", + "type": "elasticsearch", + "name": "elasticsearch", + "revision": 1, + "hosts": []interface{}{"localhost:63542"}, + "service_token": getESServiceToken(), + }) + require.NoError(t, err) + expected = makeExpected(agentID, 1, inputSource, 2, badSource) + control.Expected(expected) + + // wait for fleet-server to report as failed + ftesting.Retry(t, ctx, func(ctx context.Context) error { + state := getUnitState(control, proto.UnitType_INPUT, "fleet-server-default-fleet-server") + if state != proto.State_FAILED { + return fmt.Errorf("should be reported as failed; instead its %s", state) + } + return nil + }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) + + // reconfigure to good config + goodSource, err := structpb.NewStruct(map[string]interface{}{ + "id": "default", + "type": "elasticsearch", + "name": "elasticsearch", + "revision": 1, + "hosts": getESHosts(), + "service_token": getESServiceToken(), + }) + require.NoError(t, err) + expected = makeExpected(agentID, 1, inputSource, 3, goodSource) + control.Expected(expected) + + // wait for fleet-server to report as healthy + ftesting.Retry(t, ctx, func(ctx context.Context) error { + state := getUnitState(control, proto.UnitType_INPUT, "fleet-server-default-fleet-server") + if state != proto.State_HEALTHY { + return fmt.Errorf("should be reported as healthy; instead its %s", state) + } + return nil + }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) + + // trigger stop + expected = makeExpected(agentID, 1, inputSource, 3, outputSource) + expected.Units[0].State = proto.State_STOPPED + expected.Units[1].State = proto.State_STOPPED + control.Expected(expected) + + // wait for fleet-server to report as stopped + ftesting.Retry(t, ctx, func(ctx context.Context) error { + state := getUnitState(control, proto.UnitType_INPUT, "fleet-server-default-fleet-server") + if state != proto.State_STOPPED { + return fmt.Errorf("should be reported as stopped; instead its %s", state) + } + return nil + }, ftesting.RetrySleep(100*time.Millisecond), ftesting.RetryCount(120)) + + // stop the agent and wait for go routine to exit + cancel() + wg.Wait() +} + +func createAndStartControlServer(t *testing.T, expected *proto.CheckinExpected) *StubV2Control { + t.Helper() + + srv := NewStubV2Control(expected) + require.NoError(t, srv.Start()) + return srv +} + +type StubV2Control struct { + proto.UnimplementedElasticAgentServer + + token string + port int + + server *grpc.Server + + mx sync.Mutex + observed *proto.CheckinObserved + expected *proto.CheckinExpected + forceSend chan struct{} +} + +func NewStubV2Control(expected *proto.CheckinExpected) *StubV2Control { + token := mock.NewID() + s := &StubV2Control{ + token: token, + expected: expected, + forceSend: make(chan struct{}), + } + return s +} + +func (s *StubV2Control) Token() string { + return s.token +} + +func (s *StubV2Control) Port() int { + return s.port +} + +func (s *StubV2Control) Start(opt ...grpc.ServerOption) error { + lis, err := net.Listen("tcp", "localhost:0") + if err != nil { + return err + } + s.port = lis.Addr().(*net.TCPAddr).Port + srv := grpc.NewServer(opt...) + s.server = srv + proto.RegisterElasticAgentServer(s.server, s) + go func() { + _ = srv.Serve(lis) + }() + return nil +} + +func (s *StubV2Control) Stop() { + if s.server != nil { + s.server.Stop() + s.server = nil + } +} + +func (s *StubV2Control) Expected(expected *proto.CheckinExpected) { + s.mx.Lock() + s.expected = expected + s.mx.Unlock() + s.forceSend <- struct{}{} +} + +func (s *StubV2Control) Observed() *proto.CheckinObserved { + s.mx.Lock() + defer s.mx.Unlock() + return s.observed +} + +// Checkin is the checkin implementation for the mock server +func (s *StubV2Control) Checkin(server proto.ElasticAgent_CheckinServer) error { + return errors.New("no V1 support") +} + +// CheckinV2 is the V2 checkin implementation for the mock server +func (s *StubV2Control) CheckinV2(server proto.ElasticAgent_CheckinV2Server) error { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + go func() { + for { + select { + case <-ctx.Done(): + return + case <-s.forceSend: + s.mx.Lock() + expected := s.expected + s.mx.Unlock() + _ = server.Send(expected) + } + } + }() + + for { + checkin, err := server.Recv() + if err != nil { + return err + } + if checkin.Token != s.token { + return errors.New("invalid token") + } + + s.mx.Lock() + s.observed = checkin + expected := s.expected + s.mx.Unlock() + + err = server.Send(expected) + if err != nil { + return err + } + } +} + +// Actions is the action implementation for the mock server +func (s *StubV2Control) Actions(server proto.ElasticAgent_ActionsServer) error { + return nil +} + +func getESHosts() []interface{} { + hosts := os.Getenv("ELASTICSEARCH_HOSTS") + if hosts == "" { + return []interface{}{"localhost:9200"} + } + hostsSplit := strings.Split(hosts, ",") + rawHosts := make([]interface{}, 0, len(hostsSplit)) + for _, host := range hostsSplit { + rawHosts = append(rawHosts, host) + } + return rawHosts +} + +func getESServiceToken() string { + return os.Getenv("ELASTICSEARCH_SERVICE_TOKEN") +} + +func getUnitState(control *StubV2Control, unitType proto.UnitType, unitID string) proto.State { + obs := control.Observed() + if obs == nil { + return proto.State_STARTING + } + for _, unit := range obs.Units { + if unit.Type == unitType && unit.Id == unitID { + return unit.State + } + } + return proto.State_STARTING +} + +func makeExpected(agentID string, inputConfigIdx uint64, inputSource *structpb.Struct, outputConfigIdx uint64, outputSource *structpb.Struct) *proto.CheckinExpected { + return &proto.CheckinExpected{ + AgentInfo: &proto.CheckinAgentInfo{ + Id: agentID, + Version: "8.5.0", + Snapshot: true, + }, + Units: []*proto.UnitExpected{ + { + Id: "fleet-server-default-fleet-server", + Type: proto.UnitType_INPUT, + State: proto.State_HEALTHY, + ConfigStateIdx: inputConfigIdx, + Config: &proto.UnitExpectedConfig{ + Source: inputSource, + Id: "fleet-server", + Type: "fleet-server", + Name: "Fleet Server", + Revision: 1, + }, + LogLevel: proto.UnitLogLevel_INFO, + }, + { + Id: "fleet-server-default", + Type: proto.UnitType_OUTPUT, + State: proto.State_HEALTHY, + ConfigStateIdx: outputConfigIdx, + Config: &proto.UnitExpectedConfig{ + Source: outputSource, + Id: "default", + Type: "elasticsearch", + Name: "elasticsearch", + Revision: 1, + }, + LogLevel: proto.UnitLogLevel_INFO, + }, + }, + } +} diff --git a/internal/pkg/server/fleet.go b/internal/pkg/server/fleet.go index fecc81b6d..27ada184d 100644 --- a/internal/pkg/server/fleet.go +++ b/internal/pkg/server/fleet.go @@ -8,13 +8,14 @@ import ( "context" "errors" "fmt" + "github.com/elastic/elastic-agent-client/v7/pkg/client" + "github.com/elastic/fleet-server/v7/internal/pkg/state" "net/url" "os" "reflect" "runtime/debug" "time" - "github.com/elastic/elastic-agent-client/v7/pkg/proto" "go.elastic.co/apm" apmtransport "go.elastic.co/apm/transport" @@ -33,7 +34,6 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/policy" "github.com/elastic/fleet-server/v7/internal/pkg/profile" "github.com/elastic/fleet-server/v7/internal/pkg/scheduler" - "github.com/elastic/fleet-server/v7/internal/pkg/status" "github.com/elastic/fleet-server/v7/internal/pkg/ver" "github.com/hashicorp/go-version" @@ -49,47 +49,46 @@ type Fleet struct { bi build.Info verCon version.Constraints - cfg *config.Config cfgCh chan *config.Config cache cache.Cache - reporter status.Reporter + reporter state.Reporter } // NewFleet creates the actual fleet server service. -func NewFleet(cfg *config.Config, bi build.Info, reporter status.Reporter) (*Fleet, error) { +func NewFleet(bi build.Info, reporter state.Reporter) (*Fleet, error) { verCon, err := api.BuildVersionConstraint(bi.Version) if err != nil { return nil, err } - err = cfg.LoadServerLimits() - if err != nil { - return nil, fmt.Errorf("encountered error while loading server limits: %w", err) - } - - cacheCfg := config.CopyCache(cfg) - log.Info().Interface("cfg", cacheCfg).Msg("Setting cache config options") - cache, err := cache.New(cacheCfg) - if err != nil { - return nil, err - } - return &Fleet{ bi: bi, verCon: verCon, - cfg: cfg, cfgCh: make(chan *config.Config, 1), - cache: cache, reporter: reporter, }, nil } type runFunc func(context.Context) error +type runFuncCfg func(context.Context, *config.Config) error + // Run runs the fleet server -func (f *Fleet) Run(ctx context.Context) error { +func (f *Fleet) Run(ctx context.Context, initCfg *config.Config) error { + err := initCfg.LoadServerLimits() + if err != nil { + return fmt.Errorf("encountered error while loading server limits: %w", err) + } + cacheCfg := config.CopyCache(initCfg) + log.Info().Interface("cfg", cacheCfg).Msg("Setting cache config options") + cache, err := cache.New(cacheCfg) + if err != nil { + return err + } + f.cache = cache + var curCfg *config.Config - newCfg := f.cfg + newCfg := initCfg // Replace context with cancellable ctx // in order to automatically cancel all the go routines @@ -109,12 +108,12 @@ func (f *Fleet) Run(ctx context.Context) error { } } - start := func(ctx context.Context, runfn runFunc, ech chan<- error) (*errgroup.Group, context.CancelFunc) { + start := func(ctx context.Context, runfn runFuncCfg, cfg *config.Config, ech chan<- error) (*errgroup.Group, context.CancelFunc) { ctx, cn = context.WithCancel(ctx) g, ctx := errgroup.WithContext(ctx) g.Go(func() error { - err := runfn(ctx) + err := runfn(ctx, cfg) if err != nil { ech <- err } @@ -134,10 +133,10 @@ LOOP: for { ech := make(chan error, 2) if started { - f.reporter.Status(proto.StateObserved_CONFIGURING, "Re-configuring", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? + f.reporter.UpdateState(client.UnitStateConfiguring, "Re-configuring", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? } else { started = true - f.reporter.Status(proto.StateObserved_STARTING, "Starting", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? + f.reporter.UpdateState(client.UnitStateStarting, "Starting", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? } err := newCfg.LoadServerLimits() @@ -165,9 +164,9 @@ LOOP: proEg, proCancel = nil, nil if newCfg.Inputs[0].Server.Profiler.Enabled { log.Info().Msg("starting profiler on configuration change") - proEg, proCancel = start(ctx, func(ctx context.Context) error { - return profile.RunProfiler(ctx, newCfg.Inputs[0].Server.Profiler.Bind) - }, ech) + proEg, proCancel = start(ctx, func(ctx context.Context, cfg *config.Config) error { + return profile.RunProfiler(ctx, cfg.Inputs[0].Server.Profiler.Bind) + }, newCfg, ech) } } @@ -178,30 +177,29 @@ LOOP: stop(srvCancel, srvEg) } log.Info().Msg("starting server on configuration change") - srvEg, srvCancel = start(ctx, func(ctx context.Context) error { - return f.runServer(ctx, newCfg) - }, ech) + srvEg, srvCancel = start(ctx, func(ctx context.Context, cfg *config.Config) error { + return f.runServer(ctx, cfg) + }, newCfg, ech) } curCfg = newCfg - f.cfg = curCfg select { case newCfg = <-f.cfgCh: log.Info().Msg("Server configuration update") case err := <-ech: - f.reporter.Status(proto.StateObserved_FAILED, fmt.Sprintf("Error - %s", err), nil) //nolint:errcheck // unclear on what should we do if updating the status fails? + f.reporter.UpdateState(client.UnitStateFailed, fmt.Sprintf("Error - %s", err), nil) //nolint:errcheck // unclear on what should we do if updating the status fails? log.Error().Err(err).Msg("Fleet Server failed") return err case <-ctx.Done(): - f.reporter.Status(proto.StateObserved_STOPPING, "Stopping", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? + f.reporter.UpdateState(client.UnitStateStopping, "Stopping", nil) //nolint:errcheck // unclear on what should we do if updating the status fails? break LOOP } } // Server is coming down; wait for the server group to exit cleanly. // Timeout if something is locked up. - err := safeWait(srvEg, time.Second) + err = safeWait(srvEg, time.Second) // Eat cancel error to minimize confusion in logs if errors.Is(err, context.Canceled) { diff --git a/cmd/fleet/server_integration_test.go b/internal/pkg/server/fleet_integration_test.go similarity index 88% rename from cmd/fleet/server_integration_test.go rename to internal/pkg/server/fleet_integration_test.go index 31398213b..4191db0c7 100644 --- a/cmd/fleet/server_integration_test.go +++ b/internal/pkg/server/fleet_integration_test.go @@ -5,7 +5,7 @@ //go:build integration // +build integration -package fleet +package server import ( "bytes" @@ -30,10 +30,11 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/api" "github.com/elastic/fleet-server/v7/internal/pkg/build" "github.com/elastic/fleet-server/v7/internal/pkg/config" + "github.com/elastic/fleet-server/v7/internal/pkg/dl" "github.com/elastic/fleet-server/v7/internal/pkg/logger" - "github.com/elastic/fleet-server/v7/internal/pkg/server" + "github.com/elastic/fleet-server/v7/internal/pkg/model" "github.com/elastic/fleet-server/v7/internal/pkg/sleep" - "github.com/elastic/fleet-server/v7/internal/pkg/status" + "github.com/elastic/fleet-server/v7/internal/pkg/state" ftesting "github.com/elastic/fleet-server/v7/internal/pkg/testing" ) @@ -46,7 +47,7 @@ const ( type tserver struct { cfg *config.Config g *errgroup.Group - srv *server.Fleet + srv *Fleet } func (s *tserver) baseURL() string { @@ -63,14 +64,40 @@ func (s *tserver) waitExit() error { return s.g.Wait() } -func startTestServer(ctx context.Context) (*tserver, error) { - cfg, err := config.LoadFile("../../fleet-server.yml") +func startTestServer(t *testing.T, ctx context.Context) (*tserver, error) { + t.Helper() + + cfg, err := config.LoadFile("../../../fleet-server.yml") if err != nil { return nil, fmt.Errorf("config load error: %w", err) } logger.Init(cfg, "fleet-server") //nolint:errcheck // test logging setup + bulker := ftesting.SetupBulk(ctx, t) + + policyID := uuid.Must(uuid.NewV4()).String() + _, err = dl.CreatePolicy(ctx, bulker, model.Policy{ + PolicyID: policyID, + RevisionIdx: 1, + DefaultFleetServer: true, + Data: policyData, + }) + if err != nil { + return nil, err + } + + _, err = dl.CreateEnrollmentAPIKey(ctx, bulker, model.EnrollmentAPIKey{ + Name: "Default", + APIKey: "keyvalue", + APIKeyID: "keyid", + PolicyID: policyID, + Active: true, + }) + if err != nil { + return nil, err + } + port, err := ftesting.FreePort() if err != nil { return nil, fmt.Errorf("unable to find port: %w", err) @@ -83,7 +110,7 @@ func startTestServer(ctx context.Context) (*tserver, error) { cfg.Inputs[0].Server = *srvcfg log.Info().Uint16("port", port).Msg("Test fleet server") - srv, err := server.NewFleet(cfg, build.Info{Version: serverVersion}, status.NewLog()) + srv, err := NewFleet(build.Info{Version: serverVersion}, state.NewLog()) if err != nil { return nil, fmt.Errorf("unable to create server: %w", err) } @@ -91,7 +118,7 @@ func startTestServer(ctx context.Context) (*tserver, error) { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { - return srv.Run(ctx) + return srv.Run(ctx, cfg) }) tsrv := &tserver{cfg: cfg, g: g, srv: srv} @@ -141,7 +168,7 @@ func TestServerUnauthorized(t *testing.T) { defer cancel() // Start test server - srv, err := startTestServer(ctx) + srv, err := startTestServer(t, ctx) require.NoError(t, err) agentID := uuid.Must(uuid.NewV4()).String() @@ -245,7 +272,7 @@ func TestServerInstrumentation(t *testing.T) { defer server.Close() // Start test server - srv, err := startTestServer(ctx) + srv, err := startTestServer(t, ctx) require.NoError(t, err) newInstrumentationCfg := func(cfg config.Config, instr config.Instrumentation) { //nolint:govet // mutex should not be copied in operation (hopefully) diff --git a/internal/pkg/server/server.go b/internal/pkg/server/server.go deleted file mode 100644 index b8f4c1a0a..000000000 --- a/internal/pkg/server/server.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package server defines the fleet-server instance. -package server - -import ( - "context" -) - -// Server defines the interface to run the service instance. -type Server interface { - Run(context.Context) error -} diff --git a/internal/pkg/state/reporter.go b/internal/pkg/state/reporter.go new file mode 100644 index 000000000..e2224c80f --- /dev/null +++ b/internal/pkg/state/reporter.go @@ -0,0 +1,51 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package state wraps elastic-agent-client's unit.UpdateState rpc calls. +package state + +import ( + "github.com/elastic/elastic-agent-client/v7/pkg/client" + "github.com/rs/zerolog/log" +) + +// Reporter is interface that reports updated state on. +type Reporter interface { + // UpdateState triggers updating the state. + UpdateState(state client.UnitState, message string, payload map[string]interface{}) error +} + +// Log will write state' to log. +type Log struct{} + +// NewLog creates a Log. +func NewLog() *Log { + return &Log{} +} + +// UpdateState triggers updating the state. +func (l *Log) UpdateState(state client.UnitState, message string, _ map[string]interface{}) error { + log.Info().Str("state", state.String()).Msg(message) + return nil +} + +// Chained calls State on all the provided reporters in the provided order. +type Chained struct { + reporters []Reporter +} + +// NewChained creates a Chained with provided reporters. +func NewChained(reporters ...Reporter) *Chained { + return &Chained{reporters} +} + +// UpdateState triggers updating the state. +func (l *Chained) UpdateState(state client.UnitState, message string, payload map[string]interface{}) error { + for _, reporter := range l.reporters { + if err := reporter.UpdateState(state, message, payload); err != nil { + return err + } + } + return nil +} diff --git a/internal/pkg/status/reporter.go b/internal/pkg/status/reporter.go deleted file mode 100644 index ac823ea17..000000000 --- a/internal/pkg/status/reporter.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package status wraps elastic-agent-client's Status rpc calls. -// The Status calls update fleet-server's status (RUNNING, ERROR, etc) elastic-agent. -package status - -import ( - "github.com/rs/zerolog/log" - - "github.com/elastic/elastic-agent-client/v7/pkg/proto" -) - -// Reporter is interface that reports updated status on. -type Reporter interface { - // Status triggers updating the status. - Status(status proto.StateObserved_Status, message string, payload map[string]interface{}) error -} - -// Log will write status' to log. -type Log struct{} - -// NewLog creates a Log. -func NewLog() *Log { - return &Log{} -} - -// Status triggers updating the status. -func (l *Log) Status(status proto.StateObserved_Status, message string, _ map[string]interface{}) error { - log.Info().Str("status", status.String()).Msg(message) - return nil -} - -// Chained calls Status on all the provided reporters in the provided order. -type Chained struct { - reporters []Reporter -} - -// NewChained creates a Chained with provided reporters. -func NewChained(reporters ...Reporter) *Chained { - return &Chained{reporters} -} - -// Status triggers updating the status. -func (l *Chained) Status(status proto.StateObserved_Status, message string, payload map[string]interface{}) error { - for _, reporter := range l.reporters { - if err := reporter.Status(status, message, payload); err != nil { - return err - } - } - return nil -} diff --git a/model/schema.json b/model/schema.json index 78debe5c9..d1a3db241 100644 --- a/model/schema.json +++ b/model/schema.json @@ -520,6 +520,15 @@ "description": "Last checkin message", "type": "string" }, + "last_checkin_message": { + "description": "Last checkin message", + "type": "string" + }, + "components": { + "description": "Elastic Agent components detailed status information", + "type": "object", + "format": "raw" + }, "default_api_key_id": { "description": "Deprecated. Use Outputs instead. ID of the API key the Elastic Agent uses to authenticate with elasticsearch", "type": "string"