From 7bb4acdb3992fb6d7b504f4ed2aeaf945511b810 Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Wed, 15 Jun 2022 11:47:11 -0400 Subject: [PATCH] [v2] Calculate the expected runtime components from policy (#550) * Upgrade elastic-agent-client. * Calculate the expected running components and units from the v2 specification and the current policy. * Update NOTICE.txt. * Fix lint from servicable main.go. * Update GRPC for the agent CLI control protocol. Fix name collision issue. * Run go mod tidy. * Fix more lint issues. * Fix fmt. * Update logic to always compute model, with err set on each component. Check runtime preventions at model generation time. * Fix items from code review, and issue on windows test runner. * Try to cleanup duplication in tests. * Try 2 of fixing duplicate lint failure, that is not really a duplicate. * Re-run mage fmt. * Lint fixes for linux, why different? * Fix nolint comment. * Add comment. --- NOTICE.txt | 100 +- control.proto | 4 +- go.mod | 14 +- go.sum | 21 +- internal/pkg/agent/cmd/diagnostics.go | 50 +- internal/pkg/agent/cmd/enroll_cmd.go | 4 +- internal/pkg/agent/control/client/client.go | 48 +- .../control/{proto => cproto}/control.pb.go | 724 +++++---------- .../agent/control/cproto/control_grpc.pb.go | 340 +++++++ internal/pkg/agent/control/server/server.go | 127 +-- .../serviceable-1.0-darwin-x86_64/main.go | 27 +- magefile.go | 6 +- pkg/component/component.go | 308 +++++++ pkg/component/component_test.go | 851 ++++++++++++++++++ pkg/component/load.go | 158 ++++ pkg/component/load_test.go | 50 +- pkg/component/platforms.go | 45 +- pkg/component/spec.go | 19 +- pkg/component/spec_test.go | 23 +- pkg/core/server/server.go | 30 +- specs/{apm-server.yml => apm-server.spec.yml} | 0 specs/{auditbeat.yml => auditbeat.spec.yml} | 0 specs/{cloudbeat.yml => cloudbeat.spec.yml} | 0 ...ecurity.yml => endpoint-security.spec.yml} | 0 specs/{filebeat.yml => filebeat.spec.yml} | 0 ...fleet-server.yml => fleet-server.spec.yml} | 0 specs/{heartbeat.yml => heartbeat.spec.yml} | 0 specs/{metricbeat.yml => metricbeat.spec.yml} | 0 .../{osquerybeat.yml => osquerybeat.spec.yml} | 0 specs/{packetbeat.yml => packetbeat.spec.yml} | 0 30 files changed, 2215 insertions(+), 734 deletions(-) rename internal/pkg/agent/control/{proto => cproto}/control.pb.go (55%) create mode 100644 internal/pkg/agent/control/cproto/control_grpc.pb.go create mode 100644 pkg/component/component.go create mode 100644 pkg/component/component_test.go rename specs/{apm-server.yml => apm-server.spec.yml} (100%) rename specs/{auditbeat.yml => auditbeat.spec.yml} (100%) rename specs/{cloudbeat.yml => cloudbeat.spec.yml} (100%) rename specs/{endpoint-security.yml => endpoint-security.spec.yml} (100%) rename specs/{filebeat.yml => filebeat.spec.yml} (100%) rename specs/{fleet-server.yml => fleet-server.spec.yml} (100%) rename specs/{heartbeat.yml => heartbeat.spec.yml} (100%) rename specs/{metricbeat.yml => metricbeat.spec.yml} (100%) rename specs/{osquerybeat.yml => osquerybeat.spec.yml} (100%) rename specs/{packetbeat.yml => packetbeat.spec.yml} (100%) diff --git a/NOTICE.txt b/NOTICE.txt index 4b402c790f4..f7854b64dc5 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -828,11 +828,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-a -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-client/v7 -Version: v7.0.0-20210727140539-f0905d9377f6 +Version: v7.0.0-20220524131921-43bacbeec516 Licence type (autodetected): Elastic -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.0.0-20210727140539-f0905d9377f6/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.0.0-20220524131921-43bacbeec516/LICENSE.txt: ELASTIC LICENSE AGREEMENT @@ -2183,44 +2183,6 @@ 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/golang/protobuf -Version: v1.5.2 -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/golang/protobuf@v1.5.2/LICENSE: - -Copyright 2010 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 : github.com/google/go-cmp Version: v0.5.6 @@ -5274,11 +5236,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. @@ -5348,11 +5310,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Dependency : google.golang.org/grpc -Version: v1.42.0 +Version: v1.46.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.42.0/LICENSE: +Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.46.0/LICENSE: Apache License @@ -5560,11 +5522,11 @@ Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.42.0/LIC -------------------------------------------------------------------------------- Dependency : google.golang.org/protobuf -Version: v1.27.1 +Version: v1.28.0 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.27.1/LICENSE: +Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.28.0/LICENSE: Copyright (c) 2018 The Go Authors. All rights reserved. @@ -9588,6 +9550,44 @@ third-party archives. limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/golang/protobuf +Version: v1.5.2 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/golang/protobuf@v1.5.2/LICENSE: + +Copyright 2010 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 : github.com/google/gofuzz Version: v1.1.0 @@ -15217,11 +15217,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. @@ -15651,11 +15651,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 +Version: v0.0.0-20220426171045-31bebdecfb46 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/google.golang.org/genproto@v0.0.0-20211208223120-3a66f561d7aa/LICENSE: +Contents of probable licence file $GOMODCACHE/google.golang.org/genproto@v0.0.0-20220426171045-31bebdecfb46/LICENSE: Apache License diff --git a/control.proto b/control.proto index c49502db920..efd063822de 100644 --- a/control.proto +++ b/control.proto @@ -4,10 +4,10 @@ syntax = "proto3"; -package proto; +package cproto; option cc_enable_arenas = true; -option go_package = "pkg/agent/control/proto;proto"; +option go_package = "internal/pkg/agent/control/cproto"; // Status codes for the current state. enum Status { diff --git a/go.mod b/go.mod index 37c11d9bfb6..2cf5692b25a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/docker/go-units v0.4.0 github.com/elastic/e2e-testing v1.99.2-0.20220117192005-d3365c99b9c4 github.com/elastic/elastic-agent-autodiscover v0.0.0-20220404145827-89887023c1ab - github.com/elastic/elastic-agent-client/v7 v7.0.0-20210727140539-f0905d9377f6 + github.com/elastic/elastic-agent-client/v7 v7.0.0-20220524131921-43bacbeec516 github.com/elastic/elastic-agent-libs v0.2.3 github.com/elastic/elastic-agent-system-metrics v0.3.0 github.com/elastic/go-licenser v0.4.0 @@ -20,7 +20,6 @@ require ( github.com/elastic/go-ucfg v0.8.5 github.com/gofrs/flock v0.8.1 github.com/gofrs/uuid v4.2.0+incompatible - github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.6 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 @@ -47,10 +46,10 @@ require ( golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 + golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 golang.org/x/tools v0.1.9 - google.golang.org/grpc v1.42.0 - google.golang.org/protobuf v1.27.1 + google.golang.org/grpc v1.46.0 + google.golang.org/protobuf v1.28.0 gopkg.in/yaml.v2 v2.4.0 gotest.tools v2.2.0+incompatible gotest.tools/gotestsum v1.7.0 @@ -83,6 +82,7 @@ require ( github.com/gobuffalo/here v0.6.0 // indirect github.com/godbus/dbus/v5 v5.0.5 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect @@ -121,14 +121,14 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/mod v0.5.1 // indirect - golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect + google.golang.org/genproto v0.0.0-20220426171045-31bebdecfb46 // indirect google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/go.sum b/go.sum index 91a2ec0da3a..d12450c533f 100644 --- a/go.sum +++ b/go.sum @@ -382,8 +382,8 @@ github.com/elastic/e2e-testing v1.99.2-0.20220117192005-d3365c99b9c4 h1:uYT+Krd8 github.com/elastic/e2e-testing v1.99.2-0.20220117192005-d3365c99b9c4/go.mod h1:UcNuf4pX/qDVNQr0zybm1NL2YoWik+jKBaINZqQCA40= github.com/elastic/elastic-agent-autodiscover v0.0.0-20220404145827-89887023c1ab h1:Jk6Mfk5BF8gtfE7X0bNCiDGBtwJVxRI79b4wLCAsP+A= github.com/elastic/elastic-agent-autodiscover v0.0.0-20220404145827-89887023c1ab/go.mod h1:Gg1fsQI+rVms9FJ2DefBSojfPIzgkV8xlyG8fPG0DE8= -github.com/elastic/elastic-agent-client/v7 v7.0.0-20210727140539-f0905d9377f6 h1:nFvXHBjYK3e9+xF0WKDeAKK4aOO51uC28s+L9rBmilo= -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-20220524131921-43bacbeec516 h1:8sGoTlgXRCesR1+FjBv8YY5CyVhNSDjXlo4uq5q1RGM= +github.com/elastic/elastic-agent-client/v7 v7.0.0-20220524131921-43bacbeec516/go.mod h1:fkvyUfFwyAG5OnMF0h+FV9sC0Xn9YLITwQpSuwungQs= github.com/elastic/elastic-agent-libs v0.0.0-20220303160015-5b4e674da3dd/go.mod h1://82M1l73IHx0wDbS2Tzkq6Fx9fkmytS1KgkIyzvNTM= 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= @@ -424,6 +424,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m 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/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +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/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -1405,8 +1406,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= @@ -1562,8 +1564,9 @@ 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-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= @@ -1783,8 +1786,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= @@ -1816,8 +1820,10 @@ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= 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 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A= google.golang.org/grpc v1.42.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/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 h1:r16FSFCMhn7+LU8CzbtAIKppYeU6NUPJVdvXeIqVIq8= google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767/go.mod h1:wKDg0brwMZpaizQ1i7IzYcJjH1TmbJudYdnQC9+J+LE= @@ -1833,8 +1839,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/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/pkg/agent/cmd/diagnostics.go b/internal/pkg/agent/cmd/diagnostics.go index 9095e34bfc3..ad3a77e1a4f 100644 --- a/internal/pkg/agent/cmd/diagnostics.go +++ b/internal/pkg/agent/cmd/diagnostics.go @@ -27,17 +27,23 @@ import ( "github.com/elastic/elastic-agent/internal/pkg/agent/application/paths" "github.com/elastic/elastic-agent/internal/pkg/agent/configuration" "github.com/elastic/elastic-agent/internal/pkg/agent/control/client" - "github.com/elastic/elastic-agent/internal/pkg/agent/control/proto" + "github.com/elastic/elastic-agent/internal/pkg/agent/control/cproto" "github.com/elastic/elastic-agent/internal/pkg/agent/errors" "github.com/elastic/elastic-agent/internal/pkg/agent/program" "github.com/elastic/elastic-agent/internal/pkg/cli" "github.com/elastic/elastic-agent/internal/pkg/config/operations" ) +const ( + outputTypeHuman = "human" + outputTypeJSON = "json" + outputTypeYAML = "yaml" +) + var diagOutputs = map[string]outputter{ - "human": humanDiagnosticsOutput, - "json": jsonOutput, - "yaml": yamlOutput, + outputTypeHuman: humanDiagnosticsOutput, + outputTypeJSON: jsonOutput, + outputTypeYAML: yamlOutput, } // DiagnosticsInfo a struct to track all information related to diagnostics for the agent. @@ -98,8 +104,8 @@ func newDiagnosticsCollectCommandWithArgs(_ []string, streams *cli.IOStreams) *c output, _ := c.Flags().GetString("output") switch output { - case "yaml": - case "json": + case outputTypeYAML: + case outputTypeJSON: default: return fmt.Errorf("unsupported output: %s", output) } @@ -254,7 +260,7 @@ func diagnosticsCollectCmd(streams *cli.IOStreams, fileName, outputFormat string } func diagnosticsPprofCmd(streams *cli.IOStreams, dur, cmdTimeout time.Duration, outFile, pType, appName, rk string) error { - pt, ok := proto.PprofOption_value[strings.ToUpper(pType)] + pt, ok := cproto.PprofOption_value[strings.ToUpper(pType)] if !ok { return fmt.Errorf("unknown pprof-type %q, select one of [allocs, block, cmdline, goroutine, heap, mutex, profile, threadcreate, trace]", pType) } @@ -278,13 +284,13 @@ func diagnosticsPprofCmd(streams *cli.IOStreams, dur, cmdTimeout time.Duration, return err } - pprofData, err := daemon.Pprof(innerCtx, dur, []proto.PprofOption{proto.PprofOption(pt)}, appName, rk) + pprofData, err := daemon.Pprof(innerCtx, dur, []cproto.PprofOption{cproto.PprofOption(pt)}, appName, rk) if err != nil { return err } // validate response - pArr, ok := pprofData[proto.PprofOption_name[pt]] + pArr, ok := pprofData[cproto.PprofOption_name[pt]] if !ok { return fmt.Errorf("route key %q not found in response data (map length: %d)", rk, len(pprofData)) } @@ -350,7 +356,7 @@ func getDiagnostics(ctx context.Context) (DiagnosticsInfo, error) { return diag, nil } -func gatherMetrics(ctx context.Context) (*proto.ProcMetricsResponse, error) { +func gatherMetrics(ctx context.Context) (*cproto.ProcMetricsResponse, error) { daemon := client.New() err := daemon.Connect(ctx) if err != nil { @@ -453,7 +459,7 @@ func gatherConfig() (AgentConfig, error) { // // The passed DiagnosticsInfo and AgentConfig data is written in the specified output format. // Any local log files are collected and copied into the archive. -func createZip(fileName, outputFormat string, diag DiagnosticsInfo, cfg AgentConfig, pprof map[string][]client.ProcPProf, metrics *proto.ProcMetricsResponse, errs []error) error { +func createZip(fileName, outputFormat string, diag DiagnosticsInfo, cfg AgentConfig, pprof map[string][]client.ProcPProf, metrics *cproto.ProcMetricsResponse, errs []error) error { f, err := os.Create(fileName) if err != nil { return err @@ -667,16 +673,16 @@ func getAllPprof(ctx context.Context, d time.Duration) (map[string][]client.Proc if err != nil { return nil, err } - pprofTypes := []proto.PprofOption{ - proto.PprofOption_ALLOCS, - proto.PprofOption_BLOCK, - proto.PprofOption_CMDLINE, - proto.PprofOption_GOROUTINE, - proto.PprofOption_HEAP, - proto.PprofOption_MUTEX, - proto.PprofOption_PROFILE, - proto.PprofOption_THREADCREATE, - proto.PprofOption_TRACE, + pprofTypes := []cproto.PprofOption{ + cproto.PprofOption_ALLOCS, + cproto.PprofOption_BLOCK, + cproto.PprofOption_CMDLINE, + cproto.PprofOption_GOROUTINE, + cproto.PprofOption_HEAP, + cproto.PprofOption_MUTEX, + cproto.PprofOption_PROFILE, + cproto.PprofOption_THREADCREATE, + cproto.PprofOption_TRACE, } return daemon.Pprof(ctx, d, pprofTypes, "", "") } @@ -717,7 +723,7 @@ func zipProfs(zw *zip.Writer, pprof map[string][]client.ProcPProf) error { return nil } -func zipMetrics(zw *zip.Writer, metrics *proto.ProcMetricsResponse) error { +func zipMetrics(zw *zip.Writer, metrics *cproto.ProcMetricsResponse) error { //nolint:staticcheck,wastedassign // false positive zf, err := zw.Create("metrics/") if err != nil { diff --git a/internal/pkg/agent/cmd/enroll_cmd.go b/internal/pkg/agent/cmd/enroll_cmd.go index 6525a8a9fde..6d8858a99c4 100644 --- a/internal/pkg/agent/cmd/enroll_cmd.go +++ b/internal/pkg/agent/cmd/enroll_cmd.go @@ -28,7 +28,7 @@ import ( "github.com/elastic/elastic-agent/internal/pkg/agent/application/secret" "github.com/elastic/elastic-agent/internal/pkg/agent/configuration" "github.com/elastic/elastic-agent/internal/pkg/agent/control/client" - "github.com/elastic/elastic-agent/internal/pkg/agent/control/proto" + "github.com/elastic/elastic-agent/internal/pkg/agent/control/cproto" "github.com/elastic/elastic-agent/internal/pkg/agent/errors" "github.com/elastic/elastic-agent/internal/pkg/agent/install" "github.com/elastic/elastic-agent/internal/pkg/agent/storage" @@ -767,7 +767,7 @@ func waitForFleetServer(ctx context.Context, agentSubproc <-chan *os.ProcessStat continue } log.Debugf("%s: %s - %s", waitingForFleetServer, app.Status, app.Message) - if app.Status == proto.Status_DEGRADED || app.Status == proto.Status_HEALTHY { + if app.Status == cproto.Status_DEGRADED || app.Status == cproto.Status_HEALTHY { // app has started and is running if app.Message != "" { log.Infof("Fleet Server - %s", app.Message) diff --git a/internal/pkg/agent/control/client/client.go b/internal/pkg/agent/control/client/client.go index 8a40143ff94..728e830b462 100644 --- a/internal/pkg/agent/control/client/client.go +++ b/internal/pkg/agent/control/client/client.go @@ -12,27 +12,27 @@ import ( "time" "github.com/elastic/elastic-agent/internal/pkg/agent/control" - "github.com/elastic/elastic-agent/internal/pkg/agent/control/proto" + "github.com/elastic/elastic-agent/internal/pkg/agent/control/cproto" ) // Status is the status of the Elastic Agent -type Status = proto.Status +type Status = cproto.Status const ( // Starting is when the it is still starting. - Starting Status = proto.Status_STARTING + Starting Status = cproto.Status_STARTING // Configuring is when it is configuring. - Configuring Status = proto.Status_CONFIGURING + Configuring Status = cproto.Status_CONFIGURING // Healthy is when it is healthy. - Healthy Status = proto.Status_HEALTHY + Healthy Status = cproto.Status_HEALTHY // Degraded is when it is degraded. - Degraded Status = proto.Status_DEGRADED + Degraded Status = cproto.Status_DEGRADED // Failed is when it is failed. - Failed Status = proto.Status_FAILED + Failed Status = cproto.Status_FAILED // Stopping is when it is stopping. - Stopping Status = proto.Status_STOPPING + Stopping Status = cproto.Status_STOPPING // Upgrading is when it is upgrading. - Upgrading Status = proto.Status_UPGRADING + Upgrading Status = cproto.Status_UPGRADING ) // Version is the current running version of the daemon. @@ -104,9 +104,9 @@ type Client interface { // ProcMeta gathers running process meta-data. ProcMeta(ctx context.Context) ([]ProcMeta, error) // Pprof gathers data from the /debug/pprof/ endpoints specified. - Pprof(ctx context.Context, d time.Duration, pprofTypes []proto.PprofOption, appName, routeKey string) (map[string][]ProcPProf, error) + Pprof(ctx context.Context, d time.Duration, pprofTypes []cproto.PprofOption, appName, routeKey string) (map[string][]ProcPProf, error) // ProcMetrics gathers /buffer data and from the agent and each running process and returns the result. - ProcMetrics(ctx context.Context) (*proto.ProcMetricsResponse, error) + ProcMetrics(ctx context.Context) (*cproto.ProcMetricsResponse, error) } // client manages the state and communication to the Elastic Agent. @@ -114,7 +114,7 @@ type client struct { ctx context.Context cancel context.CancelFunc wg sync.WaitGroup - client proto.ElasticAgentControlClient + client cproto.ElasticAgentControlClient } // New creates a client connection to Elastic Agent. @@ -129,7 +129,7 @@ func (c *client) Connect(ctx context.Context) error { if err != nil { return err } - c.client = proto.NewElasticAgentControlClient(conn) + c.client = cproto.NewElasticAgentControlClient(conn) return nil } @@ -145,7 +145,7 @@ func (c *client) Disconnect() { // Version returns the current version of the running agent. func (c *client) Version(ctx context.Context) (Version, error) { - res, err := c.client.Version(ctx, &proto.Empty{}) + res, err := c.client.Version(ctx, &cproto.Empty{}) if err != nil { return Version{}, err } @@ -163,7 +163,7 @@ func (c *client) Version(ctx context.Context) (Version, error) { // Status returns the current status of the running agent. func (c *client) Status(ctx context.Context) (*AgentStatus, error) { - res, err := c.client.Status(ctx, &proto.Empty{}) + res, err := c.client.Status(ctx, &cproto.Empty{}) if err != nil { return nil, err } @@ -193,11 +193,11 @@ func (c *client) Status(ctx context.Context) (*AgentStatus, error) { // Restart triggers restarting the current running daemon. func (c *client) Restart(ctx context.Context) error { - res, err := c.client.Restart(ctx, &proto.Empty{}) + res, err := c.client.Restart(ctx, &cproto.Empty{}) if err != nil { return err } - if res.Status == proto.ActionStatus_FAILURE { + if res.Status == cproto.ActionStatus_FAILURE { return fmt.Errorf(res.Error) } return nil @@ -205,14 +205,14 @@ func (c *client) Restart(ctx context.Context) error { // Upgrade triggers upgrade of the current running daemon. func (c *client) Upgrade(ctx context.Context, version string, sourceURI string) (string, error) { - res, err := c.client.Upgrade(ctx, &proto.UpgradeRequest{ + res, err := c.client.Upgrade(ctx, &cproto.UpgradeRequest{ Version: version, SourceURI: sourceURI, }) if err != nil { return "", err } - if res.Status == proto.ActionStatus_FAILURE { + if res.Status == cproto.ActionStatus_FAILURE { return "", fmt.Errorf(res.Error) } return res.Version, nil @@ -220,7 +220,7 @@ func (c *client) Upgrade(ctx context.Context, version string, sourceURI string) // ProcMeta gathers running beat metadata. func (c *client) ProcMeta(ctx context.Context) ([]ProcMeta, error) { - resp, err := c.client.ProcMeta(ctx, &proto.Empty{}) + resp, err := c.client.ProcMeta(ctx, &cproto.Empty{}) if err != nil { return nil, err } @@ -261,8 +261,8 @@ func (c *client) ProcMeta(ctx context.Context) ([]ProcMeta, error) { } // Pprof gathers /debug/pprof data and returns a map of pprof-type: ProcPProf data -func (c *client) Pprof(ctx context.Context, d time.Duration, pprofTypes []proto.PprofOption, appName, routeKey string) (map[string][]ProcPProf, error) { - resp, err := c.client.Pprof(ctx, &proto.PprofRequest{ +func (c *client) Pprof(ctx context.Context, d time.Duration, pprofTypes []cproto.PprofOption, appName, routeKey string) (map[string][]ProcPProf, error) { + resp, err := c.client.Pprof(ctx, &cproto.PprofRequest{ PprofType: pprofTypes, TraceDuration: d.String(), AppName: appName, @@ -287,6 +287,6 @@ func (c *client) Pprof(ctx context.Context, d time.Duration, pprofTypes []proto. } // ProcMetrics gathers /buffer data and from the agent and each running process and returns the result. -func (c *client) ProcMetrics(ctx context.Context) (*proto.ProcMetricsResponse, error) { - return c.client.ProcMetrics(ctx, &proto.Empty{}) +func (c *client) ProcMetrics(ctx context.Context) (*cproto.ProcMetricsResponse, error) { + return c.client.ProcMetrics(ctx, &cproto.Empty{}) } diff --git a/internal/pkg/agent/control/proto/control.pb.go b/internal/pkg/agent/control/cproto/control.pb.go similarity index 55% rename from internal/pkg/agent/control/proto/control.pb.go rename to internal/pkg/agent/control/cproto/control.pb.go index ba5cad29109..43609b68f0a 100644 --- a/internal/pkg/agent/control/proto/control.pb.go +++ b/internal/pkg/agent/control/cproto/control.pb.go @@ -4,20 +4,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.18.0 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: control.proto -package proto +package cproto import ( - context "context" reflect "reflect" sync "sync" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) @@ -332,7 +328,7 @@ type RestartResponse struct { unknownFields protoimpl.UnknownFields // Response status. - Status ActionStatus `protobuf:"varint,1,opt,name=status,proto3,enum=proto.ActionStatus" json:"status,omitempty"` + Status ActionStatus `protobuf:"varint,1,opt,name=status,proto3,enum=cproto.ActionStatus" json:"status,omitempty"` // Error message when it fails to trigger restart. Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } @@ -455,7 +451,7 @@ type UpgradeResponse struct { unknownFields protoimpl.UnknownFields // Response status. - Status ActionStatus `protobuf:"varint,1,opt,name=status,proto3,enum=proto.ActionStatus" json:"status,omitempty"` + Status ActionStatus `protobuf:"varint,1,opt,name=status,proto3,enum=cproto.ActionStatus" json:"status,omitempty"` // Version that is being upgraded to. Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // Error message when it fails to trigger upgrade. @@ -526,7 +522,7 @@ type ApplicationStatus struct { // Application name. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Current status. - Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=proto.Status" json:"status,omitempty"` + Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=cproto.Status" json:"status,omitempty"` // Current status message. Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` // Current status payload. @@ -767,7 +763,7 @@ type StatusResponse struct { unknownFields protoimpl.UnknownFields // Overall status of Elastic Agent. - Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=proto.Status" json:"status,omitempty"` + Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=cproto.Status" json:"status,omitempty"` // Overall status message of Elastic Agent. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // Status of each application in Elastic Agent. @@ -882,7 +878,7 @@ type PprofRequest struct { unknownFields protoimpl.UnknownFields // The profiles that are requested - PprofType []PprofOption `protobuf:"varint,1,rep,packed,name=pprofType,proto3,enum=proto.PprofOption" json:"pprofType,omitempty"` + PprofType []PprofOption `protobuf:"varint,1,rep,packed,name=pprofType,proto3,enum=cproto.PprofOption" json:"pprofType,omitempty"` // A string representing a time.Duration to apply to trace, and profile options. TraceDuration string `protobuf:"bytes,2,opt,name=traceDuration,proto3" json:"traceDuration,omitempty"` // The application that will be profiled, if empty all applications are profiled. @@ -959,7 +955,7 @@ type PprofResult struct { AppName string `protobuf:"bytes,1,opt,name=appName,proto3" json:"appName,omitempty"` RouteKey string `protobuf:"bytes,2,opt,name=routeKey,proto3" json:"routeKey,omitempty"` - PprofType PprofOption `protobuf:"varint,3,opt,name=pprofType,proto3,enum=proto.PprofOption" json:"pprofType,omitempty"` + PprofType PprofOption `protobuf:"varint,3,opt,name=pprofType,proto3,enum=cproto.PprofOption" json:"pprofType,omitempty"` Result []byte `protobuf:"bytes,4,opt,name=result,proto3" json:"result,omitempty"` Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` } @@ -1203,163 +1199,165 @@ var File_control_proto protoreflect.FileDescriptor var file_control_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x7d, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, - 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x22, 0x54, - 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x22, 0x48, 0x0a, 0x0e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x52, 0x49, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x52, 0x49, 0x22, 0x6e, - 0x0a, 0x0f, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x92, - 0x01, 0x0a, 0x11, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x22, 0xb5, 0x03, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, - 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x70, - 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, - 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, - 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x67, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x47, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, - 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1b, 0x0a, - 0x09, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6c, - 0x61, 0x73, 0x74, 0x69, 0x63, 0x5f, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x64, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x4c, 0x69, 0x63, - 0x65, 0x6e, 0x73, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0f, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x8f, 0x01, 0x0a, 0x0e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x3c, 0x0a, 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x39, 0x0a, - 0x10, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x25, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, - 0x61, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x63, 0x73, 0x22, 0x9c, 0x01, 0x0a, 0x0c, 0x50, 0x70, 0x72, - 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x09, 0x70, 0x70, 0x72, - 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, - 0x72, 0x61, 0x63, 0x65, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x63, 0x65, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x50, 0x70, 0x72, 0x6f, - 0x66, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x30, 0x0a, - 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3d, 0x0a, - 0x0d, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, - 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x75, 0x0a, 0x0f, - 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x06, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x7d, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, + 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x22, + 0x55, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x48, 0x0a, 0x0e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x52, 0x49, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x52, 0x49, + 0x22, 0x6f, 0x0a, 0x0f, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x22, 0x93, 0x01, 0x0a, 0x11, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0e, 0x2e, 0x63, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xb5, 0x03, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, + 0x4d, 0x65, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, + 0x0a, 0x0c, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x49, + 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x67, 0x69, 0x64, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x47, 0x69, 0x64, 0x12, 0x22, 0x0a, + 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, + 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x0d, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x29, + 0x0a, 0x10, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x5f, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, + 0x65, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, + 0x63, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, + 0x91, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x0e, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x3d, 0x0a, 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x22, 0x3a, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x63, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x63, 0x73, 0x22, + 0x9d, 0x01, 0x0a, 0x0c, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x31, 0x0a, 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, + 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x63, 0x65, 0x44, 0x75, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x63, + 0x65, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x22, + 0xa4, 0x01, 0x0a, 0x0b, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2a, 0x79, 0x0a, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x41, 0x52, 0x54, 0x49, 0x4e, 0x47, - 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, 0x55, 0x52, 0x49, 0x4e, - 0x47, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x48, 0x45, 0x41, 0x4c, 0x54, 0x48, 0x59, 0x10, 0x02, - 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x45, 0x47, 0x52, 0x41, 0x44, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0a, - 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, - 0x4f, 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x50, 0x47, 0x52, - 0x41, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x4f, 0x4c, 0x4c, 0x42, - 0x41, 0x43, 0x4b, 0x10, 0x07, 0x2a, 0x28, 0x0a, 0x0c, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, - 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x01, 0x2a, - 0x7f, 0x0a, 0x0b, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0a, - 0x0a, 0x06, 0x41, 0x4c, 0x4c, 0x4f, 0x43, 0x53, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x4c, - 0x4f, 0x43, 0x4b, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4d, 0x44, 0x4c, 0x49, 0x4e, 0x45, - 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x47, 0x4f, 0x52, 0x4f, 0x55, 0x54, 0x49, 0x4e, 0x45, 0x10, - 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x45, 0x41, 0x50, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x4d, - 0x55, 0x54, 0x45, 0x58, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, 0x46, 0x49, 0x4c, - 0x45, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x43, 0x52, 0x45, - 0x41, 0x54, 0x45, 0x10, 0x07, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x08, - 0x32, 0x80, 0x03, 0x0a, 0x13, 0x45, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x41, 0x67, 0x65, 0x6e, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x12, 0x2f, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x06, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x12, - 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x12, - 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, - 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0b, 0x50, 0x72, - 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0x22, 0x5a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x09, 0x70, 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, + 0x70, 0x72, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3e, 0x0a, 0x0d, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x75, 0x0a, 0x0f, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x46, 0x0a, + 0x13, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x65, + 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2a, 0x79, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x41, 0x52, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x0f, 0x0a, + 0x0b, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, 0x55, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x48, 0x45, 0x41, 0x4c, 0x54, 0x48, 0x59, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x44, + 0x45, 0x47, 0x52, 0x41, 0x44, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, + 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x49, 0x4e, + 0x47, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x50, 0x47, 0x52, 0x41, 0x44, 0x49, 0x4e, 0x47, + 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x4f, 0x4c, 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x07, + 0x2a, 0x28, 0x0a, 0x0c, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x0b, 0x0a, + 0x07, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x01, 0x2a, 0x7f, 0x0a, 0x0b, 0x50, 0x70, + 0x72, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x4c, 0x4c, + 0x4f, 0x43, 0x53, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4d, 0x44, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x02, 0x12, 0x0d, 0x0a, + 0x09, 0x47, 0x4f, 0x52, 0x4f, 0x55, 0x54, 0x49, 0x4e, 0x45, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, + 0x48, 0x45, 0x41, 0x50, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x55, 0x54, 0x45, 0x58, 0x10, + 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x06, 0x12, 0x10, + 0x0a, 0x0c, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x07, + 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x08, 0x32, 0x8e, 0x03, 0x0a, 0x13, + 0x45, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x12, 0x31, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, + 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x17, 0x2e, + 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x0d, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, + 0x16, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x12, 0x0d, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x17, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x07, 0x55, 0x70, + 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x16, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, + 0x74, 0x61, 0x12, 0x0d, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x18, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x4d, + 0x65, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x50, + 0x70, 0x72, 0x6f, 0x66, 0x12, 0x14, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, + 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x63, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, + 0x12, 0x0d, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, + 0x1b, 0x2e, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x26, 0x5a, 0x21, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x67, 0x65, + 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x63, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1377,49 +1375,49 @@ func file_control_proto_rawDescGZIP() []byte { var file_control_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_control_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_control_proto_goTypes = []interface{}{ - (Status)(0), // 0: proto.Status - (ActionStatus)(0), // 1: proto.ActionStatus - (PprofOption)(0), // 2: proto.PprofOption - (*Empty)(nil), // 3: proto.Empty - (*VersionResponse)(nil), // 4: proto.VersionResponse - (*RestartResponse)(nil), // 5: proto.RestartResponse - (*UpgradeRequest)(nil), // 6: proto.UpgradeRequest - (*UpgradeResponse)(nil), // 7: proto.UpgradeResponse - (*ApplicationStatus)(nil), // 8: proto.ApplicationStatus - (*ProcMeta)(nil), // 9: proto.ProcMeta - (*StatusResponse)(nil), // 10: proto.StatusResponse - (*ProcMetaResponse)(nil), // 11: proto.ProcMetaResponse - (*PprofRequest)(nil), // 12: proto.PprofRequest - (*PprofResult)(nil), // 13: proto.PprofResult - (*PprofResponse)(nil), // 14: proto.PprofResponse - (*MetricsResponse)(nil), // 15: proto.MetricsResponse - (*ProcMetricsResponse)(nil), // 16: proto.ProcMetricsResponse + (Status)(0), // 0: cproto.Status + (ActionStatus)(0), // 1: cproto.ActionStatus + (PprofOption)(0), // 2: cproto.PprofOption + (*Empty)(nil), // 3: cproto.Empty + (*VersionResponse)(nil), // 4: cproto.VersionResponse + (*RestartResponse)(nil), // 5: cproto.RestartResponse + (*UpgradeRequest)(nil), // 6: cproto.UpgradeRequest + (*UpgradeResponse)(nil), // 7: cproto.UpgradeResponse + (*ApplicationStatus)(nil), // 8: cproto.ApplicationStatus + (*ProcMeta)(nil), // 9: cproto.ProcMeta + (*StatusResponse)(nil), // 10: cproto.StatusResponse + (*ProcMetaResponse)(nil), // 11: cproto.ProcMetaResponse + (*PprofRequest)(nil), // 12: cproto.PprofRequest + (*PprofResult)(nil), // 13: cproto.PprofResult + (*PprofResponse)(nil), // 14: cproto.PprofResponse + (*MetricsResponse)(nil), // 15: cproto.MetricsResponse + (*ProcMetricsResponse)(nil), // 16: cproto.ProcMetricsResponse } var file_control_proto_depIdxs = []int32{ - 1, // 0: proto.RestartResponse.status:type_name -> proto.ActionStatus - 1, // 1: proto.UpgradeResponse.status:type_name -> proto.ActionStatus - 0, // 2: proto.ApplicationStatus.status:type_name -> proto.Status - 0, // 3: proto.StatusResponse.status:type_name -> proto.Status - 8, // 4: proto.StatusResponse.applications:type_name -> proto.ApplicationStatus - 9, // 5: proto.ProcMetaResponse.procs:type_name -> proto.ProcMeta - 2, // 6: proto.PprofRequest.pprofType:type_name -> proto.PprofOption - 2, // 7: proto.PprofResult.pprofType:type_name -> proto.PprofOption - 13, // 8: proto.PprofResponse.results:type_name -> proto.PprofResult - 15, // 9: proto.ProcMetricsResponse.result:type_name -> proto.MetricsResponse - 3, // 10: proto.ElasticAgentControl.Version:input_type -> proto.Empty - 3, // 11: proto.ElasticAgentControl.Status:input_type -> proto.Empty - 3, // 12: proto.ElasticAgentControl.Restart:input_type -> proto.Empty - 6, // 13: proto.ElasticAgentControl.Upgrade:input_type -> proto.UpgradeRequest - 3, // 14: proto.ElasticAgentControl.ProcMeta:input_type -> proto.Empty - 12, // 15: proto.ElasticAgentControl.Pprof:input_type -> proto.PprofRequest - 3, // 16: proto.ElasticAgentControl.ProcMetrics:input_type -> proto.Empty - 4, // 17: proto.ElasticAgentControl.Version:output_type -> proto.VersionResponse - 10, // 18: proto.ElasticAgentControl.Status:output_type -> proto.StatusResponse - 5, // 19: proto.ElasticAgentControl.Restart:output_type -> proto.RestartResponse - 7, // 20: proto.ElasticAgentControl.Upgrade:output_type -> proto.UpgradeResponse - 11, // 21: proto.ElasticAgentControl.ProcMeta:output_type -> proto.ProcMetaResponse - 14, // 22: proto.ElasticAgentControl.Pprof:output_type -> proto.PprofResponse - 16, // 23: proto.ElasticAgentControl.ProcMetrics:output_type -> proto.ProcMetricsResponse + 1, // 0: cproto.RestartResponse.status:type_name -> cproto.ActionStatus + 1, // 1: cproto.UpgradeResponse.status:type_name -> cproto.ActionStatus + 0, // 2: cproto.ApplicationStatus.status:type_name -> cproto.Status + 0, // 3: cproto.StatusResponse.status:type_name -> cproto.Status + 8, // 4: cproto.StatusResponse.applications:type_name -> cproto.ApplicationStatus + 9, // 5: cproto.ProcMetaResponse.procs:type_name -> cproto.ProcMeta + 2, // 6: cproto.PprofRequest.pprofType:type_name -> cproto.PprofOption + 2, // 7: cproto.PprofResult.pprofType:type_name -> cproto.PprofOption + 13, // 8: cproto.PprofResponse.results:type_name -> cproto.PprofResult + 15, // 9: cproto.ProcMetricsResponse.result:type_name -> cproto.MetricsResponse + 3, // 10: cproto.ElasticAgentControl.Version:input_type -> cproto.Empty + 3, // 11: cproto.ElasticAgentControl.Status:input_type -> cproto.Empty + 3, // 12: cproto.ElasticAgentControl.Restart:input_type -> cproto.Empty + 6, // 13: cproto.ElasticAgentControl.Upgrade:input_type -> cproto.UpgradeRequest + 3, // 14: cproto.ElasticAgentControl.ProcMeta:input_type -> cproto.Empty + 12, // 15: cproto.ElasticAgentControl.Pprof:input_type -> cproto.PprofRequest + 3, // 16: cproto.ElasticAgentControl.ProcMetrics:input_type -> cproto.Empty + 4, // 17: cproto.ElasticAgentControl.Version:output_type -> cproto.VersionResponse + 10, // 18: cproto.ElasticAgentControl.Status:output_type -> cproto.StatusResponse + 5, // 19: cproto.ElasticAgentControl.Restart:output_type -> cproto.RestartResponse + 7, // 20: cproto.ElasticAgentControl.Upgrade:output_type -> cproto.UpgradeResponse + 11, // 21: cproto.ElasticAgentControl.ProcMeta:output_type -> cproto.ProcMetaResponse + 14, // 22: cproto.ElasticAgentControl.Pprof:output_type -> cproto.PprofResponse + 16, // 23: cproto.ElasticAgentControl.ProcMetrics:output_type -> cproto.ProcMetricsResponse 17, // [17:24] is the sub-list for method output_type 10, // [10:17] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name @@ -1622,313 +1620,3 @@ func file_control_proto_init() { file_control_proto_goTypes = nil file_control_proto_depIdxs = nil } - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// ElasticAgentControlClient is the client API for ElasticAgentControl service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ElasticAgentControlClient interface { - // Fetches the currently running version of the Elastic Agent. - Version(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*VersionResponse, error) - // Fetches the currently status of the Elastic Agent. - Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*StatusResponse, error) - // Restart restarts the current running Elastic Agent. - Restart(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RestartResponse, error) - // Upgrade starts the upgrade process of Elastic Agent. - Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (*UpgradeResponse, error) - // Gather all running process metadata. - ProcMeta(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetaResponse, error) - // Gather requested pprof data from specified applications. - Pprof(ctx context.Context, in *PprofRequest, opts ...grpc.CallOption) (*PprofResponse, error) - // Gather all running process metrics. - ProcMetrics(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetricsResponse, error) -} - -type elasticAgentControlClient struct { - cc grpc.ClientConnInterface -} - -func NewElasticAgentControlClient(cc grpc.ClientConnInterface) ElasticAgentControlClient { - return &elasticAgentControlClient{cc} -} - -func (c *elasticAgentControlClient) Version(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*VersionResponse, error) { - out := new(VersionResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/Version", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*StatusResponse, error) { - out := new(StatusResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/Status", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) Restart(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RestartResponse, error) { - out := new(RestartResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/Restart", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (*UpgradeResponse, error) { - out := new(UpgradeResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/Upgrade", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) ProcMeta(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetaResponse, error) { - out := new(ProcMetaResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/ProcMeta", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) Pprof(ctx context.Context, in *PprofRequest, opts ...grpc.CallOption) (*PprofResponse, error) { - out := new(PprofResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/Pprof", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *elasticAgentControlClient) ProcMetrics(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetricsResponse, error) { - out := new(ProcMetricsResponse) - err := c.cc.Invoke(ctx, "/proto.ElasticAgentControl/ProcMetrics", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ElasticAgentControlServer is the server API for ElasticAgentControl service. -type ElasticAgentControlServer interface { - // Fetches the currently running version of the Elastic Agent. - Version(context.Context, *Empty) (*VersionResponse, error) - // Fetches the currently status of the Elastic Agent. - Status(context.Context, *Empty) (*StatusResponse, error) - // Restart restarts the current running Elastic Agent. - Restart(context.Context, *Empty) (*RestartResponse, error) - // Upgrade starts the upgrade process of Elastic Agent. - Upgrade(context.Context, *UpgradeRequest) (*UpgradeResponse, error) - // Gather all running process metadata. - ProcMeta(context.Context, *Empty) (*ProcMetaResponse, error) - // Gather requested pprof data from specified applications. - Pprof(context.Context, *PprofRequest) (*PprofResponse, error) - // Gather all running process metrics. - ProcMetrics(context.Context, *Empty) (*ProcMetricsResponse, error) -} - -// UnimplementedElasticAgentControlServer can be embedded to have forward compatible implementations. -type UnimplementedElasticAgentControlServer struct { -} - -func (*UnimplementedElasticAgentControlServer) Version(context.Context, *Empty) (*VersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Version not implemented") -} -func (*UnimplementedElasticAgentControlServer) Status(context.Context, *Empty) (*StatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") -} -func (*UnimplementedElasticAgentControlServer) Restart(context.Context, *Empty) (*RestartResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Restart not implemented") -} -func (*UnimplementedElasticAgentControlServer) Upgrade(context.Context, *UpgradeRequest) (*UpgradeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Upgrade not implemented") -} -func (*UnimplementedElasticAgentControlServer) ProcMeta(context.Context, *Empty) (*ProcMetaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProcMeta not implemented") -} -func (*UnimplementedElasticAgentControlServer) Pprof(context.Context, *PprofRequest) (*PprofResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Pprof not implemented") -} -func (*UnimplementedElasticAgentControlServer) ProcMetrics(context.Context, *Empty) (*ProcMetricsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProcMetrics not implemented") -} - -func RegisterElasticAgentControlServer(s *grpc.Server, srv ElasticAgentControlServer) { - s.RegisterService(&_ElasticAgentControl_serviceDesc, srv) -} - -func _ElasticAgentControl_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).Version(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/Version", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).Version(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).Status(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/Status", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).Status(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_Restart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).Restart(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/Restart", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).Restart(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_Upgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpgradeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).Upgrade(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/Upgrade", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).Upgrade(ctx, req.(*UpgradeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_ProcMeta_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).ProcMeta(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/ProcMeta", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).ProcMeta(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_Pprof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PprofRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).Pprof(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/Pprof", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).Pprof(ctx, req.(*PprofRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ElasticAgentControl_ProcMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ElasticAgentControlServer).ProcMetrics(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.ElasticAgentControl/ProcMetrics", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ElasticAgentControlServer).ProcMetrics(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -var _ElasticAgentControl_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.ElasticAgentControl", - HandlerType: (*ElasticAgentControlServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Version", - Handler: _ElasticAgentControl_Version_Handler, - }, - { - MethodName: "Status", - Handler: _ElasticAgentControl_Status_Handler, - }, - { - MethodName: "Restart", - Handler: _ElasticAgentControl_Restart_Handler, - }, - { - MethodName: "Upgrade", - Handler: _ElasticAgentControl_Upgrade_Handler, - }, - { - MethodName: "ProcMeta", - Handler: _ElasticAgentControl_ProcMeta_Handler, - }, - { - MethodName: "Pprof", - Handler: _ElasticAgentControl_Pprof_Handler, - }, - { - MethodName: "ProcMetrics", - Handler: _ElasticAgentControl_ProcMetrics_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "control.proto", -} diff --git a/internal/pkg/agent/control/cproto/control_grpc.pb.go b/internal/pkg/agent/control/cproto/control_grpc.pb.go new file mode 100644 index 00000000000..3365f1a6496 --- /dev/null +++ b/internal/pkg/agent/control/cproto/control_grpc.pb.go @@ -0,0 +1,340 @@ +// 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. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.19.4 +// source: control.proto + +package cproto + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ElasticAgentControlClient is the client API for ElasticAgentControl service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ElasticAgentControlClient interface { + // Fetches the currently running version of the Elastic Agent. + Version(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*VersionResponse, error) + // Fetches the currently status of the Elastic Agent. + Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*StatusResponse, error) + // Restart restarts the current running Elastic Agent. + Restart(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RestartResponse, error) + // Upgrade starts the upgrade process of Elastic Agent. + Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (*UpgradeResponse, error) + // Gather all running process metadata. + ProcMeta(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetaResponse, error) + // Gather requested pprof data from specified applications. + Pprof(ctx context.Context, in *PprofRequest, opts ...grpc.CallOption) (*PprofResponse, error) + // Gather all running process metrics. + ProcMetrics(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetricsResponse, error) +} + +type elasticAgentControlClient struct { + cc grpc.ClientConnInterface +} + +func NewElasticAgentControlClient(cc grpc.ClientConnInterface) ElasticAgentControlClient { + return &elasticAgentControlClient{cc} +} + +func (c *elasticAgentControlClient) Version(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*VersionResponse, error) { + out := new(VersionResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/Version", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/Status", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) Restart(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RestartResponse, error) { + out := new(RestartResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/Restart", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (*UpgradeResponse, error) { + out := new(UpgradeResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/Upgrade", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) ProcMeta(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetaResponse, error) { + out := new(ProcMetaResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/ProcMeta", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) Pprof(ctx context.Context, in *PprofRequest, opts ...grpc.CallOption) (*PprofResponse, error) { + out := new(PprofResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/Pprof", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *elasticAgentControlClient) ProcMetrics(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ProcMetricsResponse, error) { + out := new(ProcMetricsResponse) + err := c.cc.Invoke(ctx, "/cproto.ElasticAgentControl/ProcMetrics", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ElasticAgentControlServer is the server API for ElasticAgentControl service. +// All implementations must embed UnimplementedElasticAgentControlServer +// for forward compatibility +type ElasticAgentControlServer interface { + // Fetches the currently running version of the Elastic Agent. + Version(context.Context, *Empty) (*VersionResponse, error) + // Fetches the currently status of the Elastic Agent. + Status(context.Context, *Empty) (*StatusResponse, error) + // Restart restarts the current running Elastic Agent. + Restart(context.Context, *Empty) (*RestartResponse, error) + // Upgrade starts the upgrade process of Elastic Agent. + Upgrade(context.Context, *UpgradeRequest) (*UpgradeResponse, error) + // Gather all running process metadata. + ProcMeta(context.Context, *Empty) (*ProcMetaResponse, error) + // Gather requested pprof data from specified applications. + Pprof(context.Context, *PprofRequest) (*PprofResponse, error) + // Gather all running process metrics. + ProcMetrics(context.Context, *Empty) (*ProcMetricsResponse, error) + mustEmbedUnimplementedElasticAgentControlServer() +} + +// UnimplementedElasticAgentControlServer must be embedded to have forward compatible implementations. +type UnimplementedElasticAgentControlServer struct { +} + +func (UnimplementedElasticAgentControlServer) Version(context.Context, *Empty) (*VersionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Version not implemented") +} +func (UnimplementedElasticAgentControlServer) Status(context.Context, *Empty) (*StatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} +func (UnimplementedElasticAgentControlServer) Restart(context.Context, *Empty) (*RestartResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Restart not implemented") +} +func (UnimplementedElasticAgentControlServer) Upgrade(context.Context, *UpgradeRequest) (*UpgradeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Upgrade not implemented") +} +func (UnimplementedElasticAgentControlServer) ProcMeta(context.Context, *Empty) (*ProcMetaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProcMeta not implemented") +} +func (UnimplementedElasticAgentControlServer) Pprof(context.Context, *PprofRequest) (*PprofResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Pprof not implemented") +} +func (UnimplementedElasticAgentControlServer) ProcMetrics(context.Context, *Empty) (*ProcMetricsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProcMetrics not implemented") +} +func (UnimplementedElasticAgentControlServer) mustEmbedUnimplementedElasticAgentControlServer() {} + +// UnsafeElasticAgentControlServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ElasticAgentControlServer will +// result in compilation errors. +type UnsafeElasticAgentControlServer interface { + mustEmbedUnimplementedElasticAgentControlServer() +} + +func RegisterElasticAgentControlServer(s grpc.ServiceRegistrar, srv ElasticAgentControlServer) { + s.RegisterService(&ElasticAgentControl_ServiceDesc, srv) +} + +func _ElasticAgentControl_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).Version(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/Version", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).Version(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/Status", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).Status(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_Restart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).Restart(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/Restart", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).Restart(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_Upgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpgradeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).Upgrade(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/Upgrade", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).Upgrade(ctx, req.(*UpgradeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_ProcMeta_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).ProcMeta(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/ProcMeta", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).ProcMeta(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_Pprof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PprofRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).Pprof(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/Pprof", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).Pprof(ctx, req.(*PprofRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ElasticAgentControl_ProcMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ElasticAgentControlServer).ProcMetrics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cproto.ElasticAgentControl/ProcMetrics", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ElasticAgentControlServer).ProcMetrics(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +// ElasticAgentControl_ServiceDesc is the grpc.ServiceDesc for ElasticAgentControl service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ElasticAgentControl_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cproto.ElasticAgentControl", + HandlerType: (*ElasticAgentControlServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Version", + Handler: _ElasticAgentControl_Version_Handler, + }, + { + MethodName: "Status", + Handler: _ElasticAgentControl_Status_Handler, + }, + { + MethodName: "Restart", + Handler: _ElasticAgentControl_Restart_Handler, + }, + { + MethodName: "Upgrade", + Handler: _ElasticAgentControl_Upgrade_Handler, + }, + { + MethodName: "ProcMeta", + Handler: _ElasticAgentControl_ProcMeta_Handler, + }, + { + MethodName: "Pprof", + Handler: _ElasticAgentControl_Pprof_Handler, + }, + { + MethodName: "ProcMetrics", + Handler: _ElasticAgentControl_ProcMetrics_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "control.proto", +} diff --git a/internal/pkg/agent/control/server/server.go b/internal/pkg/agent/control/server/server.go index 366676540d9..6d3e5181729 100644 --- a/internal/pkg/agent/control/server/server.go +++ b/internal/pkg/agent/control/server/server.go @@ -23,10 +23,9 @@ import ( "github.com/elastic/elastic-agent/internal/pkg/agent/application/reexec" "github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade" "github.com/elastic/elastic-agent/internal/pkg/agent/control" - "github.com/elastic/elastic-agent/internal/pkg/agent/control/proto" + "github.com/elastic/elastic-agent/internal/pkg/agent/control/cproto" "github.com/elastic/elastic-agent/internal/pkg/agent/errors" "github.com/elastic/elastic-agent/internal/pkg/agent/program" - "github.com/elastic/elastic-agent/internal/pkg/core/monitoring/beats" monitoring "github.com/elastic/elastic-agent/internal/pkg/core/monitoring/beats" monitoringCfg "github.com/elastic/elastic-agent/internal/pkg/core/monitoring/config" "github.com/elastic/elastic-agent/internal/pkg/core/socket" @@ -37,8 +36,12 @@ import ( "github.com/elastic/elastic-agent/pkg/core/logger" ) +const agentName = "elastic-agent" + // Server is the daemon side of the control protocol. type Server struct { + cproto.UnimplementedElasticAgentControlServer + logger *logger.Logger rex reexec.ExecManager statusCtrl status.Controller @@ -113,7 +116,7 @@ func (s *Server) Start() error { } else { s.server = grpc.NewServer() } - proto.RegisterElasticAgentControlServer(s.server, s) + cproto.RegisterElasticAgentControlServer(s.server, s) // start serving GRPC connections go func() { @@ -137,8 +140,8 @@ func (s *Server) Stop() { } // Version returns the currently running version. -func (s *Server) Version(_ context.Context, _ *proto.Empty) (*proto.VersionResponse, error) { - return &proto.VersionResponse{ +func (s *Server) Version(_ context.Context, _ *cproto.Empty) (*cproto.VersionResponse, error) { + return &cproto.VersionResponse{ Version: release.Version(), Commit: release.Commit(), BuildTime: release.BuildTime().Format(control.TimeFormat()), @@ -147,9 +150,9 @@ func (s *Server) Version(_ context.Context, _ *proto.Empty) (*proto.VersionRespo } // Status returns the overall status of the agent. -func (s *Server) Status(_ context.Context, _ *proto.Empty) (*proto.StatusResponse, error) { +func (s *Server) Status(_ context.Context, _ *cproto.Empty) (*cproto.StatusResponse, error) { status := s.statusCtrl.Status() - return &proto.StatusResponse{ + return &cproto.StatusResponse{ Status: agentStatusToProto(status.Status), Message: status.Message, Applications: agentAppStatusToProto(status.Applications), @@ -157,29 +160,29 @@ func (s *Server) Status(_ context.Context, _ *proto.Empty) (*proto.StatusRespons } // Restart performs re-exec. -func (s *Server) Restart(_ context.Context, _ *proto.Empty) (*proto.RestartResponse, error) { +func (s *Server) Restart(_ context.Context, _ *cproto.Empty) (*cproto.RestartResponse, error) { s.rex.ReExec(nil) - return &proto.RestartResponse{ - Status: proto.ActionStatus_SUCCESS, + return &cproto.RestartResponse{ + Status: cproto.ActionStatus_SUCCESS, }, nil } // Upgrade performs the upgrade operation. -func (s *Server) Upgrade(ctx context.Context, request *proto.UpgradeRequest) (*proto.UpgradeResponse, error) { +func (s *Server) Upgrade(ctx context.Context, request *cproto.UpgradeRequest) (*cproto.UpgradeResponse, error) { s.lock.RLock() u := s.up s.lock.RUnlock() if u == nil { // not running with upgrader (must be controlled by Fleet) - return &proto.UpgradeResponse{ - Status: proto.ActionStatus_FAILURE, + return &cproto.UpgradeResponse{ + Status: cproto.ActionStatus_FAILURE, Error: "cannot be upgraded; perform upgrading using Fleet", }, nil } cb, err := u.Upgrade(ctx, &upgradeRequest{request}, false) if err != nil { - return &proto.UpgradeResponse{ - Status: proto.ActionStatus_FAILURE, + return &cproto.UpgradeResponse{ //nolint:nilerr // returns err as response + Status: cproto.ActionStatus_FAILURE, Error: err.Error(), }, nil } @@ -189,8 +192,8 @@ func (s *Server) Upgrade(ctx context.Context, request *proto.UpgradeRequest) (*p <-time.After(time.Second) s.rex.ReExec(cb) }() - return &proto.UpgradeResponse{ - Status: proto.ActionStatus_SUCCESS, + return &cproto.UpgradeResponse{ + Status: cproto.ActionStatus_SUCCESS, Version: request.Version, }, nil } @@ -213,13 +216,13 @@ type BeatInfo struct { } // ProcMeta returns version and beat inforation for all running processes. -func (s *Server) ProcMeta(ctx context.Context, _ *proto.Empty) (*proto.ProcMetaResponse, error) { +func (s *Server) ProcMeta(ctx context.Context, _ *cproto.Empty) (*cproto.ProcMetaResponse, error) { if s.routeFn == nil { return nil, errors.New("route function is nil") } - resp := &proto.ProcMetaResponse{ - Procs: []*proto.ProcMeta{}, + resp := &cproto.ProcMetaResponse{ + Procs: []*cproto.ProcMeta{}, } // gather spec data for all rk/apps running @@ -236,7 +239,7 @@ func (s *Server) ProcMeta(ctx context.Context, _ *proto.Empty) (*proto.ProcMetaR } // Pprof returns /debug/pprof data for the requested applicaiont-route_key or all running applications. -func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.PprofResponse, error) { +func (s *Server) Pprof(ctx context.Context, req *cproto.PprofRequest) (*cproto.PprofResponse, error) { if s.monitoringCfg == nil || s.monitoringCfg.Pprof == nil || !s.monitoringCfg.Pprof.Enabled { return nil, fmt.Errorf("agent.monitoring.pprof disabled") } @@ -250,20 +253,20 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr return nil, fmt.Errorf("unable to parse trace duration: %w", err) } - resp := &proto.PprofResponse{ - Results: []*proto.PprofResult{}, + resp := &cproto.PprofResponse{ + Results: []*cproto.PprofResult{}, } var wg sync.WaitGroup - ch := make(chan *proto.PprofResult, 1) + ch := make(chan *cproto.PprofResult, 1) // retrieve elastic-agent pprof data if requested or application is unspecified. - if req.AppName == "" || req.AppName == "elastic-agent" { - endpoint := beats.AgentMonitoringEndpoint(runtime.GOOS, s.monitoringCfg.HTTP) - c := newSocketRequester("elastic-agent", "", endpoint) + if req.AppName == "" || req.AppName == agentName { + endpoint := monitoring.AgentMonitoringEndpoint(runtime.GOOS, s.monitoringCfg.HTTP) + c := newSocketRequester(agentName, "", endpoint) for _, opt := range req.PprofType { wg.Add(1) - go func(opt proto.PprofOption) { + go func(opt cproto.PprofOption) { res := c.getPprof(ctx, opt, dur) ch <- res wg.Done() @@ -273,7 +276,7 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr // get requested rk/appname spec or all specs var specs []specInfo - if req.AppName != "elastic-agent" { + if req.AppName != agentName { specs = s.getSpecInfo(req.RouteKey, req.AppName) } for _, si := range specs { @@ -282,7 +285,7 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr // Launch a concurrent goroutine to gather all pprof endpoints from a socket. for _, opt := range req.PprofType { wg.Add(1) - go func(opt proto.PprofOption) { + go func(opt cproto.PprofOption) { res := c.getPprof(ctx, opt, dur) ch <- res wg.Done() @@ -305,9 +308,9 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr // ProcMetrics returns all buffered metrics data for the agent and running processes. // If the agent.monitoring.http.buffer variable is not set, or set to false, a nil result attribute is returned -func (s *Server) ProcMetrics(ctx context.Context, _ *proto.Empty) (*proto.ProcMetricsResponse, error) { +func (s *Server) ProcMetrics(ctx context.Context, _ *cproto.Empty) (*cproto.ProcMetricsResponse, error) { if s.monitoringCfg == nil || s.monitoringCfg.HTTP == nil || s.monitoringCfg.HTTP.Buffer == nil || !s.monitoringCfg.HTTP.Buffer.Enabled { - return &proto.ProcMetricsResponse{}, nil + return &cproto.ProcMetricsResponse{}, nil } if s.routeFn == nil { @@ -315,12 +318,12 @@ func (s *Server) ProcMetrics(ctx context.Context, _ *proto.Empty) (*proto.ProcMe } // gather metrics buffer data from the elastic-agent - endpoint := beats.AgentMonitoringEndpoint(runtime.GOOS, s.monitoringCfg.HTTP) - c := newSocketRequester("elastic-agent", "", endpoint) + endpoint := monitoring.AgentMonitoringEndpoint(runtime.GOOS, s.monitoringCfg.HTTP) + c := newSocketRequester(agentName, "", endpoint) metrics := c.procMetrics(ctx) - resp := &proto.ProcMetricsResponse{ - Result: []*proto.MetricsResponse{metrics}, + resp := &cproto.ProcMetricsResponse{ + Result: []*cproto.MetricsResponse{metrics}, } // gather metrics buffer data from all other processes @@ -442,8 +445,8 @@ func (r *socketRequester) getPath(ctx context.Context, path string) (*http.Respo } // procMeta will return process metadata by querying the "/" path. -func (r *socketRequester) procMeta(ctx context.Context) *proto.ProcMeta { - pm := &proto.ProcMeta{ +func (r *socketRequester) procMeta(ctx context.Context) *cproto.ProcMeta { + pm := &cproto.ProcMeta{ Name: r.appName, RouteKey: r.routeKey, } @@ -478,21 +481,21 @@ func (r *socketRequester) procMeta(ctx context.Context) *proto.ProcMeta { return pm } -var pprofEndpoints = map[proto.PprofOption]string{ - proto.PprofOption_ALLOCS: "/debug/pprof/allocs", - proto.PprofOption_BLOCK: "/debug/pprof/block", - proto.PprofOption_CMDLINE: "/debug/pprof/cmdline", - proto.PprofOption_GOROUTINE: "/debug/pprof/goroutine", - proto.PprofOption_HEAP: "/debug/pprof/heap", - proto.PprofOption_MUTEX: "/debug/pprof/mutex", - proto.PprofOption_PROFILE: "/debug/pprof/profile", - proto.PprofOption_THREADCREATE: "/debug/pprof/threadcreate", - proto.PprofOption_TRACE: "/debug/pprof/trace", +var pprofEndpoints = map[cproto.PprofOption]string{ + cproto.PprofOption_ALLOCS: "/debug/pprof/allocs", + cproto.PprofOption_BLOCK: "/debug/pprof/block", + cproto.PprofOption_CMDLINE: "/debug/pprof/cmdline", + cproto.PprofOption_GOROUTINE: "/debug/pprof/goroutine", + cproto.PprofOption_HEAP: "/debug/pprof/heap", + cproto.PprofOption_MUTEX: "/debug/pprof/mutex", + cproto.PprofOption_PROFILE: "/debug/pprof/profile", + cproto.PprofOption_THREADCREATE: "/debug/pprof/threadcreate", + cproto.PprofOption_TRACE: "/debug/pprof/trace", } // getProf will gather pprof data specified by the option. -func (r *socketRequester) getPprof(ctx context.Context, opt proto.PprofOption, dur time.Duration) *proto.PprofResult { - res := &proto.PprofResult{ +func (r *socketRequester) getPprof(ctx context.Context, opt cproto.PprofOption, dur time.Duration) *cproto.PprofResult { + res := &cproto.PprofResult{ AppName: r.appName, RouteKey: r.routeKey, PprofType: opt, @@ -504,7 +507,7 @@ func (r *socketRequester) getPprof(ctx context.Context, opt proto.PprofOption, d return res } - if opt == proto.PprofOption_PROFILE || opt == proto.PprofOption_TRACE { + if opt == cproto.PprofOption_PROFILE || opt == cproto.PprofOption_TRACE { path += fmt.Sprintf("?seconds=%0.f", dur.Seconds()) } @@ -525,8 +528,8 @@ func (r *socketRequester) getPprof(ctx context.Context, opt proto.PprofOption, d } // procMetrics will gather metrics buffer data -func (r *socketRequester) procMetrics(ctx context.Context) *proto.MetricsResponse { - res := &proto.MetricsResponse{ +func (r *socketRequester) procMetrics(ctx context.Context) *cproto.MetricsResponse { + res := &cproto.MetricsResponse{ AppName: r.appName, RouteKey: r.routeKey, } @@ -553,7 +556,7 @@ func (r *socketRequester) procMetrics(ctx context.Context) *proto.MetricsRespons } type upgradeRequest struct { - *proto.UpgradeRequest + *cproto.UpgradeRequest } func (r *upgradeRequest) Version() string { @@ -569,27 +572,27 @@ func (r *upgradeRequest) FleetAction() *fleetapi.ActionUpgrade { return nil } -func agentStatusToProto(code status.AgentStatusCode) proto.Status { +func agentStatusToProto(code status.AgentStatusCode) cproto.Status { if code == status.Degraded { - return proto.Status_DEGRADED + return cproto.Status_DEGRADED } if code == status.Failed { - return proto.Status_FAILED + return cproto.Status_FAILED } - return proto.Status_HEALTHY + return cproto.Status_HEALTHY } -func agentAppStatusToProto(apps []status.AgentApplicationStatus) []*proto.ApplicationStatus { - s := make([]*proto.ApplicationStatus, len(apps)) +func agentAppStatusToProto(apps []status.AgentApplicationStatus) []*cproto.ApplicationStatus { + s := make([]*cproto.ApplicationStatus, len(apps)) for i, a := range apps { var payload []byte if a.Payload != nil { payload, _ = json.Marshal(a.Payload) } - s[i] = &proto.ApplicationStatus{ + s[i] = &cproto.ApplicationStatus{ Id: a.ID, Name: a.Name, - Status: proto.Status(a.Status.ToProto()), + Status: cproto.Status(a.Status.ToProto()), Message: a.Message, Payload: string(payload), } diff --git a/internal/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/main.go b/internal/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/main.go index da9123f4587..99ceab143f1 100644 --- a/internal/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/main.go +++ b/internal/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/main.go @@ -14,9 +14,9 @@ import ( "path/filepath" "strconv" - protobuf "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + protobuf "google.golang.org/protobuf/proto" "gopkg.in/yaml.v2" "github.com/elastic/elastic-agent-client/v7/pkg/client" @@ -29,27 +29,27 @@ func main() { panic(err) } f, _ := os.OpenFile(filepath.Join(os.TempDir(), "testing.out"), os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) - f.WriteString("starting \n") + _, _ = f.WriteString("starting \n") ctx, cancel := context.WithCancel(context.Background()) s := &configServer{ f: f, ctx: ctx, cancel: cancel, } - f.WriteString(fmt.Sprintf("reading creds from port: %d\n", srvPort)) + _, _ = f.WriteString(fmt.Sprintf("reading creds from port: %d\n", srvPort)) client, err := clientFromNet(srvPort, s) if err != nil { - f.WriteString(err.Error()) + _, _ = f.WriteString(err.Error()) panic(err) } s.client = client err = client.Start(ctx) if err != nil { - f.WriteString(err.Error()) + _, _ = f.WriteString(err.Error()) panic(err) } <-ctx.Done() - f.WriteString("finished \n") + _, _ = f.WriteString("finished \n") } type configServer struct { @@ -60,41 +60,41 @@ type configServer struct { } func (s *configServer) OnConfig(cfgString string) { - s.client.Status(proto.StateObserved_CONFIGURING, "Writing config file", nil) + _ = s.client.Status(proto.StateObserved_CONFIGURING, "Writing config file", nil) testCfg := &TestConfig{} if err := yaml.Unmarshal([]byte(cfgString), &testCfg); err != nil { - s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to unmarshall config: %s", err), nil) + _ = s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to unmarshall config: %s", err), nil) return } if testCfg.TestFile != "" { tf, err := os.Create(testCfg.TestFile) if err != nil { - s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to create file %s: %s", testCfg.TestFile, err), nil) + _ = s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to create file %s: %s", testCfg.TestFile, err), nil) return } err = tf.Close() if err != nil { - s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to close file %s: %s", testCfg.TestFile, err), nil) + _ = s.client.Status(proto.StateObserved_FAILED, fmt.Sprintf("Failed to close file %s: %s", testCfg.TestFile, err), nil) return } } - s.client.Status(proto.StateObserved_HEALTHY, "Running", map[string]interface{}{ + _ = s.client.Status(proto.StateObserved_HEALTHY, "Running", map[string]interface{}{ "status": proto.StateObserved_HEALTHY, "message": "Running", }) } func (s *configServer) OnStop() { - s.client.Status(proto.StateObserved_STOPPING, "Stopping", nil) + _ = s.client.Status(proto.StateObserved_STOPPING, "Stopping", nil) s.cancel() } func (s *configServer) OnError(err error) { - s.f.WriteString(err.Error()) + _, _ = s.f.WriteString(err.Error()) } // TestConfig is a configuration for testing Config calls @@ -136,6 +136,7 @@ func clientFromNet(port int, impl client.StateInterface, actions ...client.Actio ServerName: connInfo.ServerName, Certificates: []tls.Certificate{cert}, RootCAs: caCertPool, + MinVersion: tls.VersionTLS12, }) return client.New(connInfo.Addr, connInfo.Token, impl, actions, grpc.WithTransportCredentials(trans)), nil } diff --git a/magefile.go b/magefile.go index aba39385159..b640f46fd08 100644 --- a/magefile.go +++ b/magefile.go @@ -496,7 +496,11 @@ func Config() { // ControlProto generates pkg/agent/control/proto module. func ControlProto() error { - return sh.RunV("protoc", "--go_out=plugins=grpc:.", "control.proto") + return sh.RunV( + "protoc", + "--go_out=internal/pkg/agent/control/cproto", "--go_opt=paths=source_relative", + "--go-grpc_out=internal/pkg/agent/control/cproto", "--go-grpc_opt=paths=source_relative", + "control.proto") } // BuildSpec make sure that all the suppported program spec are built into the binary. diff --git a/pkg/component/component.go b/pkg/component/component.go new file mode 100644 index 00000000000..db38bb38471 --- /dev/null +++ b/pkg/component/component.go @@ -0,0 +1,308 @@ +// 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 component + +import ( + "errors" + "fmt" + + "github.com/elastic/elastic-agent-client/v7/pkg/client" + + "github.com/elastic/elastic-agent/internal/pkg/agent/transpiler" + "github.com/elastic/elastic-agent/internal/pkg/eql" +) + +var ( + // ErrOutputNotSupported is returned when an input does not support an output type + ErrOutputNotSupported = errors.New("input doesn't support output type") +) + +// ErrInputRuntimeCheckFail error is used when an input specification runtime prevention check occurs. +type ErrInputRuntimeCheckFail struct { + // message is the reason defined in the check + message string +} + +// NewErrInputRuntimeCheckFail creates a ErrInputRuntimeCheckFail with the message. +func NewErrInputRuntimeCheckFail(message string) *ErrInputRuntimeCheckFail { + return &ErrInputRuntimeCheckFail{message} +} + +// Error returns the message set on the check. +func (e *ErrInputRuntimeCheckFail) Error() string { + return e.message +} + +// Unit is a single input or output that a component must run. +type Unit struct { + ID string + Type client.UnitType + Config map[string]interface{} +} + +// Component is a set of units that needs to run. +type Component struct { + // ID is the unique ID of the component. + ID string + + // Err used when there is an error with running this input. Used by the runtime to alert + // the reason that all of these units are failed. + Err error + + // Spec on how the input should run. + Spec InputRuntimeSpec + + // Units that should be running inside this component. + Units []Unit +} + +// ToComponents returns the components that should be running based on the policy and the current runtime specification. +func (r *RuntimeSpecs) ToComponents(policy map[string]interface{}) ([]Component, error) { + outputsMap, err := toIntermediate(policy) + if err != nil { + return nil, err + } + if outputsMap == nil { + return nil, nil + } + + // set the runtime variables that are available in the input specification runtime checks + vars, err := transpiler.NewVars(map[string]interface{}{ + "runtime": map[string]interface{}{ + "platform": r.platform.String(), + "os": r.platform.OS, + "arch": r.platform.Arch, + "family": r.platform.Family, + "major": r.platform.Major, + "minor": r.platform.Minor, + }, + }, nil) + if err != nil { + return nil, err + } + + var components []Component + for outputName, output := range outputsMap { + if !output.enabled { + // skip; not enabled + continue + } + + // merge aliases into same input type + inputsMap := make(map[string][]inputI) + for inputType, inputs := range output.inputs { + realInputType, ok := r.aliasMapping[inputType] + if ok { + inputsMap[realInputType] = append(inputsMap[realInputType], inputs...) + } else { + inputsMap[inputType] = append(inputsMap[inputType], inputs...) + } + } + + for inputType, inputs := range inputsMap { + inputSpec, err := r.GetInput(inputType) + if err == nil { + // update the inputType to match the spec; as it could have been alias + inputType = inputSpec.InputType + if !containsStr(inputSpec.Spec.Outputs, output.outputType) { + inputSpec = InputRuntimeSpec{} // empty the spec + err = ErrOutputNotSupported + } else { + err = validateRuntimeChecks(&inputSpec.Spec, vars) + if err != nil { + inputSpec = InputRuntimeSpec{} // empty the spec + } + } + } + units := make([]Unit, 0, len(inputs)+1) + for _, input := range inputs { + if !input.enabled { + // skip; not enabled + continue + } + units = append(units, Unit{ + ID: fmt.Sprintf("%s-%s-%s", inputType, outputName, input.id), + Type: client.UnitTypeInput, + Config: input.input, + }) + } + if len(units) > 0 { + componentID := fmt.Sprintf("%s-%s", inputType, outputName) + units = append(units, Unit{ + ID: componentID, + Type: client.UnitTypeOutput, + Config: output.output, + }) + components = append(components, Component{ + ID: componentID, + Err: err, + Spec: inputSpec, + Units: units, + }) + } + } + } + return components, nil +} + +// toIntermediate takes the policy and returns it into an intermediate representation that is easier to map into a set +// of components. +func toIntermediate(policy map[string]interface{}) (map[string]outputI, error) { + const ( + outputsKey = "outputs" + enabledKey = "enabled" + inputsKey = "inputs" + typeKey = "type" + idKey = "id" + useKey = "use_output" + ) + + // intermediate structure for output to input mapping (this structure allows different input types per output) + outputsMap := make(map[string]outputI) + + // map the outputs first + outputsRaw, ok := policy[outputsKey] + if !ok { + // no outputs defined; no components then + return nil, nil + } + outputs, ok := outputsRaw.(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("invalid 'outputs', expected a map not a %T", outputsRaw) + } + for name, outputRaw := range outputs { + output, ok := outputRaw.(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("invalid 'outputs.%s', expected a map not a %T", name, outputRaw) + } + typeRaw, ok := output[typeKey] + if !ok { + return nil, fmt.Errorf("invalid 'outputs.%s', 'type' missing", name) + } + t, ok := typeRaw.(string) + if !ok { + return nil, fmt.Errorf("invalid 'outputs.%s.type', expected a string not a %T", name, typeRaw) + } + enabled := true + if enabledRaw, ok := output[enabledKey]; ok { + enabledVal, ok := enabledRaw.(bool) + if !ok { + return nil, fmt.Errorf("invalid 'outputs.%s.enabled', expected a bool not a %T", name, enabledRaw) + } + enabled = enabledVal + delete(output, enabledKey) + } + outputsMap[name] = outputI{ + name: name, + enabled: enabled, + outputType: t, + output: output, + inputs: make(map[string][]inputI), + } + } + + // map the inputs to the outputs + inputsRaw, ok := policy[inputsKey] + if !ok { + // no inputs; no components then + return nil, nil + } + inputs, ok := inputsRaw.([]interface{}) + if !ok { + return nil, fmt.Errorf("invalid 'inputs', expected an array not a %T", inputsRaw) + } + for idx, inputRaw := range inputs { + input, ok := inputRaw.(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d', expected a map not a %T", idx, inputRaw) + } + typeRaw, ok := input[typeKey] + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d', 'type' missing", idx) + } + t, ok := typeRaw.(string) + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d.type', expected a string not a %T", idx, typeRaw) + } + idRaw, ok := input[idKey] + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d', 'id' missing", idx) + } + id, ok := idRaw.(string) + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d.id', expected a string not a %T", idx, idRaw) + } + outputName := "default" + if outputRaw, ok := input[useKey]; ok { + outputNameVal, ok := outputRaw.(string) + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d.use_output', expected a string not a %T", idx, outputRaw) + } + outputName = outputNameVal + delete(input, useKey) + } + output, ok := outputsMap[outputName] + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d.use_output', references an unknown output '%s'", idx, outputName) + } + enabled := true + if enabledRaw, ok := input[enabledKey]; ok { + enabledVal, ok := enabledRaw.(bool) + if !ok { + return nil, fmt.Errorf("invalid 'inputs.%d.enabled', expected a bool not a %T", idx, enabledRaw) + } + enabled = enabledVal + delete(input, enabledKey) + } + output.inputs[t] = append(output.inputs[t], inputI{ + idx: idx, + id: id, + enabled: enabled, + inputType: t, + input: input, + }) + } + if len(outputsMap) == 0 { + return nil, nil + } + return outputsMap, nil +} + +type inputI struct { + idx int + id string + enabled bool + inputType string + input map[string]interface{} +} + +type outputI struct { + name string + enabled bool + outputType string + output map[string]interface{} + inputs map[string][]inputI +} + +func validateRuntimeChecks(spec *InputSpec, store eql.VarStore) error { + for _, prevention := range spec.Runtime.Preventions { + expression, err := eql.New(prevention.Condition) + if err != nil { + // this should not happen because the specification already validates that this + // should never error; but just in-case we consider this a reason to prevent the running of the input + return NewErrInputRuntimeCheckFail(err.Error()) + } + ok, err := expression.Eval(store) + if err != nil { + // error is considered a failure and reported as a reason + return NewErrInputRuntimeCheckFail(err.Error()) + } + if ok { + // true means the prevention valid (so input should not run) + return NewErrInputRuntimeCheckFail(prevention.Message) + } + } + return nil +} diff --git a/pkg/component/component_test.go b/pkg/component/component_test.go new file mode 100644 index 00000000000..a929fbde7b3 --- /dev/null +++ b/pkg/component/component_test.go @@ -0,0 +1,851 @@ +// 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 component + +import ( + "path/filepath" + "sort" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/elastic/elastic-agent-client/v7/pkg/client" +) + +func TestToComponents(t *testing.T) { + var linuxAMD64Platform = PlatformDetail{ + Platform: Platform{ + OS: Linux, + Arch: AMD64, + GOOS: Linux, + }, + } + + scenarios := []struct { + Name string + Platform PlatformDetail + Policy map[string]interface{} + Err string + Result []Component + }{ + { + Name: "Empty policy", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{}, + }, + { + Name: "Invalid: outputs as an array", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": []string{"should be a map"}, + }, + Err: "invalid 'outputs', expected a map not a []string", + }, + { + Name: "Invalid: outputs entry as an array", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": []string{"should be a map"}, + }, + }, + Err: "invalid 'outputs.default', expected a map not a []string", + }, + { + Name: "Invalid: outputs entry missing type", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{}, + }, + }, + Err: "invalid 'outputs.default', 'type' missing", + }, + { + Name: "Invalid: outputs entry type not a string", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": 0, + }, + }, + }, + Err: "invalid 'outputs.default.type', expected a string not a int", + }, + { + Name: "Invalid: outputs entry type not a string", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": "false", + }, + }, + }, + Err: "invalid 'outputs.default.enabled', expected a bool not a string", + }, + { + Name: "No inputs", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + }, + }, + { + Name: "Invalid: inputs as a map", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": map[string]interface{}{}, + }, + Err: "invalid 'inputs', expected an array not a map[string]interface {}", + }, + { + Name: "Invalid: inputs entry as an array", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + []string{"should be a map"}, + }, + }, + Err: "invalid 'inputs.0', expected a map not a []string", + }, + { + Name: "Invalid: inputs entry missing type", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{}, + }, + }, + Err: "invalid 'inputs.0', 'type' missing", + }, + { + Name: "Invalid: inputs entry type not a string", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": 0, + }, + }, + }, + Err: "invalid 'inputs.0.type', expected a string not a int", + }, + { + Name: "Invalid: inputs entry missing id", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + }, + }, + }, + Err: "invalid 'inputs.0', 'id' missing", + }, + { + Name: "Invalid: inputs entry id not a string", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": 0, + }, + }, + }, + Err: "invalid 'inputs.0.id', expected a string not a int", + }, + { + Name: "Invalid: inputs entry use_output not a string", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "use_output": 0, + }, + }, + }, + Err: "invalid 'inputs.0.use_output', expected a string not a int", + }, + { + Name: "Invalid: inputs entry use_output references unknown output", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "use_output": "other", + }, + }, + }, + Err: "invalid 'inputs.0.use_output', references an unknown output 'other'", + }, + { + Name: "Invalid: inputs entry enabled not a bool", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "use_output": "default", + "enabled": "false", + }, + }, + }, + Err: "invalid 'inputs.0.enabled', expected a bool not a string", + }, + { + Name: "Invalid: inputs unknown type", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "unknown", + "id": "unknown-0", + "use_output": "default", + "enabled": true, + }, + }, + }, + Result: []Component{ + { + ID: "unknown-default", + Spec: InputRuntimeSpec{}, + Err: ErrInputNotSupported, + Units: []Unit{ + { + ID: "unknown-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "unknown-default-unknown-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "unknown", + "id": "unknown-0", + }, + }, + }, + }, + }, + }, + { + Name: "Invalid: inputs endpoint not support on container platform", + Platform: PlatformDetail{ + Platform: Platform{ + OS: Container, + Arch: AMD64, + GOOS: Linux, + }, + }, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + "use_output": "default", + "enabled": true, + }, + }, + }, + Result: []Component{ + { + ID: "endpoint-default", + Spec: InputRuntimeSpec{}, + Err: ErrInputNotSupportedOnPlatform, + Units: []Unit{ + { + ID: "endpoint-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "endpoint-default-endpoint-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + }, + }, + }, + }, + }, + }, + { + Name: "Invalid: inputs endpoint doesn't support logstash", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "logstash", + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + }, + }, + }, + Result: []Component{ + { + ID: "endpoint-default", + Spec: InputRuntimeSpec{}, + Err: ErrOutputNotSupported, + Units: []Unit{ + { + ID: "endpoint-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "logstash", + }, + }, + { + ID: "endpoint-default-endpoint-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + }, + }, + }, + }, + }, + }, + { + Name: "Invalid: inputs endpoint doesnt support arm64 redhat major 7", + Platform: PlatformDetail{ + Platform: Platform{ + OS: Linux, + Arch: ARM64, + GOOS: Linux, + }, + Family: "redhat", + Major: "7", + Minor: "2", + }, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + "use_output": "default", + "enabled": true, + }, + }, + }, + Result: []Component{ + { + ID: "endpoint-default", + Spec: InputRuntimeSpec{}, + Err: NewErrInputRuntimeCheckFail("No support for RHEL7 on arm64"), + Units: []Unit{ + { + ID: "endpoint-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "endpoint-default-endpoint-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "endpoint", + "id": "endpoint-0", + }, + }, + }, + }, + }, + }, + { + Name: "Output disabled", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": false, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "enabled": true, + }, + }, + }, + }, + { + Name: "Input disabled", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "enabled": false, + }, + }, + }, + }, + { + Name: "Simple representation", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + "enabled": true, + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + "enabled": true, + }, + map[string]interface{}{ + "type": "filestream", + "id": "filestream-1", + "enabled": false, + }, + }, + }, + Result: []Component{ + { + Spec: InputRuntimeSpec{ + InputType: "filestream", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "filestream-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "filestream-default-filestream-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + }, + }, + }, + }, + }, + }, + { + Name: "Complex representation", + Platform: linuxAMD64Platform, + Policy: map[string]interface{}{ + "outputs": map[string]interface{}{ + "default": map[string]interface{}{ + "type": "elasticsearch", + }, + "other": map[string]interface{}{ + "type": "elasticsearch", + }, + "stashit": map[string]interface{}{ + "type": "logstash", + }, + "redis": map[string]interface{}{ + "type": "redis", + }, + }, + "inputs": []interface{}{ + map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + }, + map[string]interface{}{ + "type": "filestream", + "id": "filestream-1", + }, + map[string]interface{}{ + "type": "filestream", + "id": "filestream-2", + "enabled": false, + }, + map[string]interface{}{ + "type": "filestream", + "id": "filestream-3", + "use_output": "other", + }, + map[string]interface{}{ + "type": "filestream", + "id": "filestream-4", + "use_output": "other", + }, + map[string]interface{}{ + "type": "logfile", + "id": "logfile-0", + "use_output": "default", + }, + map[string]interface{}{ + "type": "log", + "id": "logfile-1", + "use_output": "default", + }, + map[string]interface{}{ + "type": "logfile", + "id": "logfile-2", + "use_output": "other", + }, + map[string]interface{}{ + "type": "logfile", + "id": "logfile-3", + "use_output": "stashit", + }, + map[string]interface{}{ + "type": "logfile", + "id": "logfile-4", + "use_output": "redis", + }, + map[string]interface{}{ + "type": "apm", + "id": "apm-server-0", + }, + }, + }, + Result: []Component{ + { + Spec: InputRuntimeSpec{ + InputType: "filestream", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "filestream-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "filestream-default-filestream-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "filestream", + "id": "filestream-0", + }, + }, + { + ID: "filestream-default-filestream-1", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "filestream", + "id": "filestream-1", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "filestream", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "filestream-other", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "filestream-other-filestream-3", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "filestream", + "id": "filestream-3", + }, + }, + { + ID: "filestream-other-filestream-4", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "filestream", + "id": "filestream-4", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "log", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "log-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "log-default-logfile-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "logfile", + "id": "logfile-0", + }, + }, + { + ID: "log-default-logfile-1", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "log", + "id": "logfile-1", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "log", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "log-other", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "log-other-logfile-2", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "logfile", + "id": "logfile-2", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "log", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "log-stashit", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "logstash", + }, + }, + { + ID: "log-stashit-logfile-3", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "logfile", + "id": "logfile-3", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "log", + BinaryName: "filebeat", + BinaryPath: filepath.Join("..", "..", "specs", "filebeat"), + }, + Units: []Unit{ + { + ID: "log-redis", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "redis", + }, + }, + { + ID: "log-redis-logfile-4", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "logfile", + "id": "logfile-4", + }, + }, + }, + }, + { + Spec: InputRuntimeSpec{ + InputType: "apm", + BinaryName: "apm-server", + BinaryPath: filepath.Join("..", "..", "specs", "apm-server"), + }, + Units: []Unit{ + { + ID: "apm-default", + Type: client.UnitTypeOutput, + Config: map[string]interface{}{ + "type": "elasticsearch", + }, + }, + { + ID: "apm-default-apm-server-0", + Type: client.UnitTypeInput, + Config: map[string]interface{}{ + "type": "apm", + "id": "apm-server-0", + }, + }, + }, + }, + }, + }, + } + + for _, scenario := range scenarios { + t.Run(scenario.Name, func(t *testing.T) { + runtime, err := LoadRuntimeSpecs(filepath.Join("..", "..", "specs"), scenario.Platform, SkipBinaryCheck()) + require.NoError(t, err) + + result, err := runtime.ToComponents(scenario.Policy) + if scenario.Err != "" { + assert.Equal(t, scenario.Err, err.Error()) + } else { + require.NoError(t, err) + require.Len(t, result, len(scenario.Result)) + sortComponents(scenario.Result) + sortComponents(result) + for i, expected := range scenario.Result { + actual := result[i] + if expected.Err != nil { + assert.Equal(t, expected.Err, actual.Err) + assert.EqualValues(t, expected.Units, actual.Units) + } else { + assert.Equal(t, expected.Spec.InputType, actual.Spec.InputType) + assert.Equal(t, expected.Spec.BinaryName, actual.Spec.BinaryName) + assert.Equal(t, expected.Spec.BinaryPath, actual.Spec.BinaryPath) + assert.EqualValues(t, expected.Units, actual.Units) + } + } + } + }) + } +} + +func sortComponents(components []Component) { + for _, comp := range components { + sort.Slice(comp.Units, func(i, j int) bool { + return comp.Units[i].ID < comp.Units[j].ID + }) + } + sort.Slice(components[:], func(i, j int) bool { + return components[i].Units[0].ID < components[j].Units[0].ID + }) +} diff --git a/pkg/component/load.go b/pkg/component/load.go index 7782dcaa2a6..feb16d0b97c 100644 --- a/pkg/component/load.go +++ b/pkg/component/load.go @@ -5,9 +5,158 @@ package component import ( + "errors" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "github.com/elastic/go-ucfg/yaml" ) +const specGlobPattern = "*.spec.yml" + +var ( + // ErrInputNotSupported is returned when the input is not supported on any platform + ErrInputNotSupported = errors.New("input not supported") + // ErrInputNotSupportedOnPlatform is returned when the input is supported but not on this platform + ErrInputNotSupportedOnPlatform = errors.New("input not supported on this platform") +) + +// InputRuntimeSpec returns the specification for running this input on the current platform. +type InputRuntimeSpec struct { + InputType string + BinaryName string + BinaryPath string + Spec InputSpec +} + +// RuntimeSpecs return all the specifications for inputs that are supported on the current platform. +type RuntimeSpecs struct { + // platform that was loaded + platform PlatformDetail + + // inputTypes all input types even if that input is not supported on the current platform + inputTypes []string + + // inputSpecs only the input specs for the current platform + inputSpecs map[string]InputRuntimeSpec + + // aliasMapping maps aliases to real input name + aliasMapping map[string]string +} + +type loadRuntimeOpts struct { + skipBinaryCheck bool +} + +// LoadRuntimeOption are options for loading the runtime specs. +type LoadRuntimeOption func(o *loadRuntimeOpts) + +// SkipBinaryCheck skips checking that a binary is next to the runtime. +func SkipBinaryCheck() LoadRuntimeOption { + return func(o *loadRuntimeOpts) { + o.skipBinaryCheck = true + } +} + +// LoadRuntimeSpecs loads all the component input specifications from the provided directory. +// +// Returns a mapping of the input to binary name with specification for that input. The filenames in the directory +// are required to be {binary-name} with {binary-name}.spec.yml to be next to it. If a {binary-name}.spec.yml exists +// but no matching {binary-name} is found that will result in an error. If a {binary-name} exists without a +// {binary-name}.spec.yml then it will be ignored. +func LoadRuntimeSpecs(dir string, platform PlatformDetail, opts ...LoadRuntimeOption) (RuntimeSpecs, error) { + var opt loadRuntimeOpts + for _, o := range opts { + o(&opt) + } + matches, err := filepath.Glob(filepath.Join(dir, specGlobPattern)) + if err != nil { + return RuntimeSpecs{}, err + } + var types []string + mapping := make(map[string]InputRuntimeSpec) + aliases := make(map[string]string) + for _, match := range matches { + binaryName := filepath.Base(match[:len(match)-len(specGlobPattern)+1]) + binaryPath := match[:len(match)-len(specGlobPattern)+1] + if platform.OS == Windows { + binaryPath += ".exe" + } + if !opt.skipBinaryCheck { + info, err := os.Stat(binaryPath) + if errors.Is(err, os.ErrNotExist) { + return RuntimeSpecs{}, fmt.Errorf("missing matching binary for %s", match) + } else if err != nil { + return RuntimeSpecs{}, fmt.Errorf("failed to stat %s: %w", binaryPath, err) + } else if info.IsDir() { + return RuntimeSpecs{}, fmt.Errorf("missing matching binary for %s", match) + } + } + data, err := ioutil.ReadFile(match) + if err != nil { + return RuntimeSpecs{}, fmt.Errorf("failed reading spec %s: %w", match, err) + } + spec, err := LoadSpec(data) + if err != nil { + return RuntimeSpecs{}, fmt.Errorf("failed reading spec %s: %w", match, err) + } + for _, input := range spec.Inputs { + if !containsStr(types, input.Name) { + types = append(types, input.Name) + } + if !containsStr(input.Platforms, platform.String()) { + // input spec doesn't support this platform + continue + } + if existing, exists := mapping[input.Name]; exists { + return RuntimeSpecs{}, fmt.Errorf("failed loading spec '%s': input '%s' already exists in spec '%s'", match, input.Name, existing.BinaryName) + } + if existing, exists := aliases[input.Name]; exists { + return RuntimeSpecs{}, fmt.Errorf("failed loading spec '%s': input '%s' collides with an alias from another input '%s'", match, input.Name, existing) + } + for _, alias := range input.Aliases { + if existing, exists := mapping[alias]; exists { + return RuntimeSpecs{}, fmt.Errorf("failed loading spec '%s': input alias '%s' collides with an already defined input in spec '%s'", match, alias, existing.BinaryName) + } + if existing, exists := aliases[alias]; exists { + return RuntimeSpecs{}, fmt.Errorf("failed loading spec '%s': input alias '%s' collides with an already defined input alias for input '%s'", match, alias, existing) + } + } + mapping[input.Name] = InputRuntimeSpec{ + InputType: input.Name, + BinaryName: binaryName, + BinaryPath: binaryPath, + Spec: input, + } + for _, alias := range input.Aliases { + aliases[alias] = input.Name + } + } + } + return RuntimeSpecs{ + platform: platform, + inputTypes: types, + inputSpecs: mapping, + aliasMapping: aliases, + }, nil +} + +// GetInput returns the input runtime specification for this input on this platform. +func (r *RuntimeSpecs) GetInput(inputType string) (InputRuntimeSpec, error) { + runtime, ok := r.inputSpecs[inputType] + if ok { + return runtime, nil + } + if containsStr(r.inputTypes, inputType) { + // supported but not on this platform + return InputRuntimeSpec{}, ErrInputNotSupportedOnPlatform + } + // not supported at all + return InputRuntimeSpec{}, ErrInputNotSupported +} + // LoadSpec loads the component specification. // // Will error in the case that the specification is not valid. Only valid specifications are allowed. @@ -23,3 +172,12 @@ func LoadSpec(data []byte) (Spec, error) { } return spec, nil } + +func containsStr(s []string, v string) bool { + for _, i := range s { + if i == v { + return true + } + } + return false +} diff --git a/pkg/component/load_test.go b/pkg/component/load_test.go index 289ace2c72f..f9d88ebba26 100644 --- a/pkg/component/load_test.go +++ b/pkg/component/load_test.go @@ -9,9 +9,39 @@ import ( "path/filepath" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +func TestLoadRuntimeSpecs(t *testing.T) { + for _, platform := range GlobalPlatforms { + t.Run(platform.String(), func(t *testing.T) { + detail := PlatformDetail{ + Platform: platform, + } + runtime, err := LoadRuntimeSpecs(filepath.Join("..", "..", "specs"), detail, SkipBinaryCheck()) + require.NoError(t, err) + assert.Greater(t, len(runtime.inputTypes), 0) + assert.Greater(t, len(runtime.inputSpecs), 0) + + // filestream is supported by all platforms + input, err := runtime.GetInput("filestream") + require.NoError(t, err) + assert.NotNil(t, input) + + // unknown input + _, err = runtime.GetInput("unknown") + require.ErrorIs(t, err, ErrInputNotSupported) + + // endpoint not support on container platforms + if platform.OS == "container" { + _, err = runtime.GetInput("endpoint") + assert.ErrorIs(t, err, ErrInputNotSupportedOnPlatform) + } + }) + } +} + func TestLoadSpec_Components(t *testing.T) { scenarios := []struct { Name string @@ -19,43 +49,43 @@ func TestLoadSpec_Components(t *testing.T) { }{ { Name: "APM Server", - Path: "apm-server.yml", + Path: "apm-server.spec.yml", }, { Name: "Auditbeat", - Path: "auditbeat.yml", + Path: "auditbeat.spec.yml", }, { Name: "Cloudbeat", - Path: "cloudbeat.yml", + Path: "cloudbeat.spec.yml", }, { Name: "Endpoint Security", - Path: "endpoint-security.yml", + Path: "endpoint-security.spec.yml", }, { Name: "Filebeat", - Path: "filebeat.yml", + Path: "filebeat.spec.yml", }, { Name: "Fleet Server", - Path: "fleet-server.yml", + Path: "fleet-server.spec.yml", }, { Name: "Heartbeat", - Path: "heartbeat.yml", + Path: "heartbeat.spec.yml", }, { Name: "Metricbeat", - Path: "metricbeat.yml", + Path: "metricbeat.spec.yml", }, { Name: "Osquerybeat", - Path: "osquerybeat.yml", + Path: "osquerybeat.spec.yml", }, { Name: "Packetbeat", - Path: "packetbeat.yml", + Path: "packetbeat.spec.yml", }, } diff --git a/pkg/component/platforms.go b/pkg/component/platforms.go index b8ad7ec1e9d..98e5bf21cd6 100644 --- a/pkg/component/platforms.go +++ b/pkg/component/platforms.go @@ -4,6 +4,11 @@ package component +import ( + "fmt" + "strings" +) + const ( // Container represents running inside a container Container = "container" @@ -22,12 +27,18 @@ const ( ARM64 = "arm64" ) -// Platforms defines the platforms that a component can support -var Platforms = []struct { +// Platform defines the platform that a component can support +type Platform struct { OS string Arch string GOOS string -}{ +} + +// Platforms is an array of platforms. +type Platforms []Platform + +// GlobalPlatforms defines the platforms that a component can support +var GlobalPlatforms = Platforms{ { OS: Container, Arch: AMD64, @@ -64,3 +75,31 @@ var Platforms = []struct { GOOS: Windows, }, } + +// String returns the platform string identifier. +func (p *Platform) String() string { + return fmt.Sprintf("%s/%s", p.OS, p.Arch) +} + +// Exists returns true if the +func (p Platforms) Exists(platform string) bool { + pieces := strings.SplitN(platform, "/", 2) + if len(pieces) != 2 { + return false + } + for _, platform := range p { + if platform.OS == pieces[0] && platform.Arch == pieces[1] { + return true + } + } + return false +} + +// PlatformDetail is platform that has more detail information about the running platform. +type PlatformDetail struct { + Platform + + Family string + Major string + Minor string +} diff --git a/pkg/component/spec.go b/pkg/component/spec.go index e428fb71a5f..2800f7275a2 100644 --- a/pkg/component/spec.go +++ b/pkg/component/spec.go @@ -8,6 +8,8 @@ import ( "errors" "fmt" "time" + + "github.com/elastic/elastic-agent/internal/pkg/eql" ) // Spec a components specification. @@ -32,7 +34,7 @@ func (s *Spec) Validate() error { for _, platform := range input.Platforms { for _, existing := range a { if existing == platform { - return fmt.Errorf("input %s at inputs.%d defines the same platform as a previous definition", input.Name, i) + return fmt.Errorf("input '%s' at inputs.%d defines the same platform as a previous definition", input.Name, i) } } a = append(a, platform) @@ -58,22 +60,31 @@ type InputSpec struct { // Validate ensures correctness of input specification. func (s *InputSpec) Validate() error { if s.Command == nil && s.Service == nil { - return fmt.Errorf("input %s must define either command or service", s.Name) + return fmt.Errorf("input '%s' must define either command or service", s.Name) } for i, a := range s.Platforms { + if !GlobalPlatforms.Exists(a) { + return fmt.Errorf("input '%s' defines an unknown platform '%s'", s.Name, a) + } for j, b := range s.Platforms { if i != j && a == b { - return fmt.Errorf("input %s defines the platform %s more than once", s.Name, a) + return fmt.Errorf("input '%s' defines the platform '%s' more than once", s.Name, a) } } } for i, a := range s.Outputs { for j, b := range s.Outputs { if i != j && a == b { - return fmt.Errorf("input %s defines the output %s more than once", s.Name, a) + return fmt.Errorf("input '%s' defines the output '%s' more than once", s.Name, a) } } } + for idx, prevention := range s.Runtime.Preventions { + _, err := eql.New(prevention.Condition) + if err != nil { + return fmt.Errorf("input '%s' defined 'runtime.preventions.%d.condition' failed to compile: %w", s.Name, idx, err) + } + } return nil } diff --git a/pkg/component/spec_test.go b/pkg/component/spec_test.go index 3b7f3bf2ae8..33866df5b0f 100644 --- a/pkg/component/spec_test.go +++ b/pkg/component/spec_test.go @@ -39,7 +39,7 @@ inputs: outputs: - shipper `, - Err: "input testing must define either command or service accessing 'inputs.0'", + Err: "input 'testing' must define either command or service accessing 'inputs.0'", }, { Name: "Duplicate Platform", @@ -55,7 +55,22 @@ inputs: - shipper command: {} `, - Err: "input testing defines the platform linux/amd64 more than once accessing 'inputs.0'", + Err: "input 'testing' defines the platform 'linux/amd64' more than once accessing 'inputs.0'", + }, + { + Name: "Unknown Platform", + Spec: ` +version: 2 +inputs: + - name: testing + description: Testing Input + platforms: + - unknown/amd64 + outputs: + - shipper + command: {} +`, + Err: "input 'testing' defines an unknown platform 'unknown/amd64' accessing 'inputs.0'", }, { Name: "Duplicate Output", @@ -71,7 +86,7 @@ inputs: - shipper command: {} `, - Err: "input testing defines the output shipper more than once accessing 'inputs.0'", + Err: "input 'testing' defines the output 'shipper' more than once accessing 'inputs.0'", }, { Name: "Duplicate Platform Same Input Name", @@ -93,7 +108,7 @@ inputs: - shipper command: {} `, - Err: "input testing at inputs.1 defines the same platform as a previous definition accessing config", + Err: "input 'testing' at inputs.1 defines the same platform as a previous definition accessing config", }, { Name: "Valid", diff --git a/pkg/core/server/server.go b/pkg/core/server/server.go index f7535ecb7e9..6d3a284cd79 100644 --- a/pkg/core/server/server.go +++ b/pkg/core/server/server.go @@ -21,9 +21,9 @@ import ( "google.golang.org/grpc/status" "github.com/gofrs/uuid" - protobuf "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + protobuf "google.golang.org/protobuf/proto" "github.com/elastic/elastic-agent-client/v7/pkg/client" "github.com/elastic/elastic-agent-client/v7/pkg/proto" @@ -99,6 +99,8 @@ type Handler interface { // Server is the GRPC server that the launched applications connect back to. type Server struct { + proto.UnimplementedElasticAgentServer + logger *logger.Logger ca *authority.CertificateAuthority listenAddr string @@ -154,6 +156,7 @@ func (s *Server) Start() error { ClientAuth: tls.RequireAndVerifyClientCert, ClientCAs: certPool, GetCertificate: s.getCertificate, + MinVersion: tls.VersionTLS12, }) if s.tracer != nil { apmInterceptor := apmgrpc.NewUnaryServerInterceptor(apmgrpc.WithRecovery(), apmgrpc.WithTracer(s.tracer)) @@ -197,7 +200,10 @@ func (s *Server) Stop() { func (s *Server) Get(app interface{}) (*ApplicationState, bool) { var foundState *ApplicationState s.apps.Range(func(_ interface{}, val interface{}) bool { - as := val.(*ApplicationState) + as, ok := val.(*ApplicationState) + if !ok { + return true + } if as.app == app { foundState = as return false @@ -211,7 +217,10 @@ func (s *Server) Get(app interface{}) (*ApplicationState, bool) { func (s *Server) FindByInputType(inputType string) (*ApplicationState, bool) { var foundState *ApplicationState s.apps.Range(func(_ interface{}, val interface{}) bool { - as := val.(*ApplicationState) + as, ok := val.(*ApplicationState) + if !ok { + return true + } if as.inputTypes == nil { return true } @@ -385,6 +394,11 @@ func (s *Server) Checkin(server proto.ElasticAgent_CheckinServer) error { return nil } +// CheckinV2 implements the GRPC bi-direction stream connection for v2 check-ins. +func (s *Server) CheckinV2(server proto.ElasticAgent_CheckinV2Server) error { + return errors.New("not implemented") +} + // Actions implements the GRPC bi-direction stream connection for actions. func (s *Server) Actions(server proto.ElasticAgent_ActionsServer) error { firstRespChan := make(chan *proto.ActionResponse) @@ -883,7 +897,10 @@ func (s *Server) watchdog() { now := time.Now().UTC() s.apps.Range(func(_ interface{}, val interface{}) bool { - serverApp := val.(*ApplicationState) + serverApp, ok := val.(*ApplicationState) + if !ok { + return true + } serverApp.checkinLock.RLock() statusTime := serverApp.statusTime serverApp.checkinLock.RUnlock() @@ -934,7 +951,10 @@ func (s *Server) getByToken(token string) (*ApplicationState, bool) { func (s *Server) getCertificate(chi *tls.ClientHelloInfo) (*tls.Certificate, error) { var cert *tls.Certificate s.apps.Range(func(_ interface{}, val interface{}) bool { - sa := val.(*ApplicationState) + sa, ok := val.(*ApplicationState) + if !ok { + return true + } if sa.srvName == chi.ServerName { cert = sa.cert.Certificate return false diff --git a/specs/apm-server.yml b/specs/apm-server.spec.yml similarity index 100% rename from specs/apm-server.yml rename to specs/apm-server.spec.yml diff --git a/specs/auditbeat.yml b/specs/auditbeat.spec.yml similarity index 100% rename from specs/auditbeat.yml rename to specs/auditbeat.spec.yml diff --git a/specs/cloudbeat.yml b/specs/cloudbeat.spec.yml similarity index 100% rename from specs/cloudbeat.yml rename to specs/cloudbeat.spec.yml diff --git a/specs/endpoint-security.yml b/specs/endpoint-security.spec.yml similarity index 100% rename from specs/endpoint-security.yml rename to specs/endpoint-security.spec.yml diff --git a/specs/filebeat.yml b/specs/filebeat.spec.yml similarity index 100% rename from specs/filebeat.yml rename to specs/filebeat.spec.yml diff --git a/specs/fleet-server.yml b/specs/fleet-server.spec.yml similarity index 100% rename from specs/fleet-server.yml rename to specs/fleet-server.spec.yml diff --git a/specs/heartbeat.yml b/specs/heartbeat.spec.yml similarity index 100% rename from specs/heartbeat.yml rename to specs/heartbeat.spec.yml diff --git a/specs/metricbeat.yml b/specs/metricbeat.spec.yml similarity index 100% rename from specs/metricbeat.yml rename to specs/metricbeat.spec.yml diff --git a/specs/osquerybeat.yml b/specs/osquerybeat.spec.yml similarity index 100% rename from specs/osquerybeat.yml rename to specs/osquerybeat.spec.yml diff --git a/specs/packetbeat.yml b/specs/packetbeat.spec.yml similarity index 100% rename from specs/packetbeat.yml rename to specs/packetbeat.spec.yml