Skip to content

Commit

Permalink
[Elastic Agent] Add basic protocol to control Elastic Agent. (#20146)
Browse files Browse the repository at this point in the history
* Add protocl to control Elastic Agent.

* Add more to version response.

* Fix CI with protoc.

* Improve protocol and try and fix CI.

* Fix proto.

* Remove CI changes.

* Update go.mod.

* Add status ROLLBACK.

* Run mage fmt.
  • Loading branch information
blakerouse authored Jul 28, 2020
1 parent ac688ca commit e9f8f17
Show file tree
Hide file tree
Showing 5 changed files with 1,200 additions and 38 deletions.
74 changes: 37 additions & 37 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16196,6 +16196,43 @@ Contents of probable licence file $GOMODCACHE/google.golang.org/grpc@v1.29.1/LIC
limitations under the License.


--------------------------------------------------------------------------------
Dependency : google.golang.org/protobuf
Version: v1.23.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.23.0/LICENSE:

Copyright (c) 2018 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : gopkg.in/inf.v0
Version: v0.9.1
Expand Down Expand Up @@ -38509,43 +38546,6 @@ Contents of probable licence file $GOMODCACHE/google.golang.org/appengine@v1.6.5
limitations under the License.


--------------------------------------------------------------------------------
Dependency : google.golang.org/protobuf
Version: v1.23.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/google.golang.org/protobuf@v1.23.0/LICENSE:

Copyright (c) 2018 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : gopkg.in/airbrake/gobrake.v2
Version: v2.0.9
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ require (
google.golang.org/api v0.15.0
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.23.0
gopkg.in/inf.v0 v0.9.1
gopkg.in/jcmturner/gokrb5.v7 v7.5.0
gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
Expand Down
119 changes: 119 additions & 0 deletions x-pack/elastic-agent/control.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// 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.

syntax = "proto3";

package proto;

option cc_enable_arenas = true;
option go_package = "pkg/agent/control/proto;proto";

// Status codes for the current state.
enum Status {
STARTING = 0;
CONFIGURING = 1;
HEALTHY = 2;
DEGRADED = 3;
FAILED = 4;
STOPPING = 5;
UPGRADING = 6;
ROLLBACK = 7;
}

// Action status codes for restart and upgrade response.
enum ActionStatus {
// Action was successful.
SUCCESS = 0;
// Action failed.
FAILURE = 1;
}

// Empty message.
message Empty {
}

// Version response message.
message VersionResponse {
// Current running version.
string version = 1;
// Current running commit.
string commit = 2;
// Current running build time.
string buildTime = 3;
// Current running version is a snapshot.
bool snapshot = 4;
}

message RestartResponse {
// Response status.
ActionStatus status = 1;
// Error message when it fails to trigger restart.
string error = 2;
}

// Upgrade request message.
message UpgradeRequest {
// (Optional) Version to upgrade to.
//
// If not provided Elastic Agent will auto discover the latest version in the same major
// to upgrade to. If wanting to upgrade to a new major that major must be present in the
// this version field.
string version = 1;

// (Optional) Use a different source URI then configured.
//
// If provided the upgrade process will use the provided sourceURI instead of the configured
// sourceURI in the configuration.
string sourceURI = 2;
}

// A upgrade response message.
message UpgradeResponse {
// Response status.
ActionStatus status = 1;

// Version that is being upgraded to.
string version = 2;

// Error message when it fails to trigger upgrade.
string error = 3;
}

// Current status of the application in Elastic Agent.
message ApplicationStatus {
// Unique application ID.
string id = 1;
// Application name.
string name = 2;
// Current status.
Status status = 3;
// Current status message.
string message = 4;
// Current status payload.
string payload = 5;
}

// Status is the current status of Elastic Agent.
message StatusResponse {
// Overall status of Elastic Agent.
Status status = 1;
// Overall status message of Elastic Agent.
string message = 2;
// Status of each application in Elastic Agent.
repeated ApplicationStatus applications = 3;
}

service ElasticAgent {
// Fetches the currently running version of the Elastic Agent.
rpc Version(Empty) returns (VersionResponse);

// Fetches the currently status of the Elastic Agent.
rpc Status(Empty) returns (StatusResponse);

// Restart restarts the current running Elastic Agent.
rpc Restart(Empty) returns (RestartResponse);

// Upgrade starts the upgrade process of Elastic Agent.
rpc Upgrade(UpgradeRequest) returns (UpgradeResponse);
}
7 changes: 6 additions & 1 deletion x-pack/elastic-agent/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func commitID() string {
return commitID
}

// Update is an alias for executing fields, dashboards, config, includes.
// Update is an alias for executing control protocol, configs, and specs.
func Update() {
mg.SerialDeps(Config, BuildSpec, BuildFleetCfg)
}
Expand All @@ -349,6 +349,11 @@ func Config() {
mg.Deps(configYML)
}

// ControlProto generates pkg/agent/control/proto module.
func ControlProto() error {
return sh.RunV("protoc", "--go_out=plugins=grpc:.", "control.proto")
}

// BuildSpec make sure that all the suppported program spec are built into the binary.
func BuildSpec() error {
// go run x-pack/agent/dev-tools/cmd/buildspec/buildspec.go --in x-pack/agent/spec/*.yml --out x-pack/agent/pkg/agent/program/supported.go
Expand Down
Loading

0 comments on commit e9f8f17

Please sign in to comment.