Skip to content

Commit 9ee5d99

Browse files
Introducing V1 grpc control protocol for backward compatibility with older agents (#1974)
Introducing V1 grpc control protocol for backward compatibility with older agents (#1974)
1 parent a0e6108 commit 9ee5d99

31 files changed

+1900
-333
lines changed

control_v1.proto

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
// or more contributor license agreements. Licensed under the Elastic License;
3+
// you may not use this file except in compliance with the Elastic License.
4+
5+
syntax = "proto3";
6+
7+
// proto namespace/package name is shared with elastic-agent-client
8+
// we need to be careful with modifications to avoid name collisions
9+
// proto is here to maintain backward compatibility and cannot be changed.
10+
// elastic-agent-client namespace is likely change after 8.6
11+
package proto;
12+
13+
option cc_enable_arenas = true;
14+
option go_package = "pkg/agent/control/proto;proto";
15+
16+
// Status codes for the current state.
17+
enum Status {
18+
V1_STARTING = 0;
19+
V1_CONFIGURING = 1;
20+
V1_HEALTHY = 2;
21+
V1_DEGRADED = 3;
22+
V1_FAILED = 4;
23+
V1_STOPPING = 5;
24+
V1_UPGRADING = 6;
25+
V1_SROLLBACK = 7;
26+
}
27+
28+
// Action status codes for restart and upgrade response.
29+
enum ActionStatus {
30+
// Action was successful.
31+
V1_SUCCESS = 0;
32+
// Action failed.
33+
V1_FAILURE = 1;
34+
}
35+
36+
// Empty message.
37+
message Empty {
38+
}
39+
40+
// Version response message.
41+
message VersionResponse {
42+
// Current running version.
43+
string version = 1;
44+
// Current running commit.
45+
string commit = 2;
46+
// Current running build time.
47+
string buildTime = 3;
48+
// Current running version is a snapshot.
49+
bool snapshot = 4;
50+
}
51+
52+
message RestartResponse {
53+
// Response status.
54+
ActionStatus status = 1;
55+
// Error message when it fails to trigger restart.
56+
string error = 2;
57+
}
58+
59+
// Upgrade request message.
60+
message UpgradeRequest {
61+
// (Optional) Version to upgrade to.
62+
//
63+
// If not provided Elastic Agent will auto discover the latest version in the same major
64+
// to upgrade to. If wanting to upgrade to a new major that major must be present in the
65+
// this version field.
66+
string version = 1;
67+
68+
// (Optional) Use a different source URI then configured.
69+
//
70+
// If provided the upgrade process will use the provided sourceURI instead of the configured
71+
// sourceURI in the configuration.
72+
string sourceURI = 2;
73+
}
74+
75+
// A upgrade response message.
76+
message UpgradeResponse {
77+
// Response status.
78+
ActionStatus status = 1;
79+
80+
// Version that is being upgraded to.
81+
string version = 2;
82+
83+
// Error message when it fails to trigger upgrade.
84+
string error = 3;
85+
}
86+
87+
// Current status of the application in Elastic Agent.
88+
message ApplicationStatus {
89+
// Unique application ID.
90+
string id = 1;
91+
// Application name.
92+
string name = 2;
93+
// Current status.
94+
Status status = 3;
95+
// Current status message.
96+
string message = 4;
97+
// Current status payload.
98+
string payload = 5;
99+
}
100+
101+
// Status is the current status of Elastic Agent.
102+
message StatusResponse {
103+
// Overall status of Elastic Agent.
104+
Status status = 1;
105+
// Overall status message of Elastic Agent.
106+
string message = 2;
107+
// Status of each application in Elastic Agent.
108+
repeated ApplicationStatus applications = 3;
109+
}
110+
111+
service ElasticAgentControl {
112+
// Fetches the currently running version of the Elastic Agent.
113+
rpc Version(Empty) returns (VersionResponse);
114+
115+
// Fetches the currently status of the Elastic Agent.
116+
rpc Status(Empty) returns (StatusResponse);
117+
118+
// Restart restarts the current running Elastic Agent.
119+
rpc Restart(Empty) returns (RestartResponse);
120+
121+
// Upgrade starts the upgrade process of Elastic Agent.
122+
rpc Upgrade(UpgradeRequest) returns (UpgradeResponse);
123+
}

control.proto control_v2.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ syntax = "proto3";
77
package cproto;
88

99
option cc_enable_arenas = true;
10-
option go_package = "internal/pkg/agent/control/cproto";
10+
option go_package = "internal/pkg/agent/control/v2/cproto";
1111
import "google/protobuf/timestamp.proto";
1212

1313
// State codes for the current state.
@@ -159,9 +159,9 @@ message StateResponse {
159159
StateAgentInfo info = 1;
160160
// Overall state of Elastic Agent.
161161
State state = 2;
162-
// Overall status message of Elastic Agent.
162+
// Overall state message of Elastic Agent.
163163
string message = 3;
164-
// Status of each component in Elastic Agent.
164+
// State of each component in Elastic Agent.
165165
repeated ComponentState components = 4;
166166
}
167167

internal/pkg/agent/application/coordinator/coordinator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/elastic/elastic-agent-client/v7/pkg/client"
2424
"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
2525
"github.com/elastic/elastic-agent/internal/pkg/agent/application/reexec"
26-
agentclient "github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
26+
agentclient "github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
2727
"github.com/elastic/elastic-agent/internal/pkg/agent/transpiler"
2828
"github.com/elastic/elastic-agent/internal/pkg/capabilities"
2929
"github.com/elastic/elastic-agent/internal/pkg/config"

internal/pkg/agent/application/coordinator/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"time"
1111

12-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
12+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
1313
)
1414

1515
// LivenessResponse is the response body for the liveness endpoint.

internal/pkg/agent/application/gateway/fleet/fleet_gateway.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator"
1313
"github.com/elastic/elastic-agent/internal/pkg/agent/application/gateway"
1414
"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
15-
agentclient "github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
15+
agentclient "github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
1616
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
1717
"github.com/elastic/elastic-agent/internal/pkg/core/backoff"
1818
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"

internal/pkg/agent/application/upgrade/error_checker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/hashicorp/go-multierror"
1313

1414
"github.com/elastic/elastic-agent/internal/pkg/agent/control"
15-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
15+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
1616
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
1717
"github.com/elastic/elastic-agent/pkg/core/logger"
1818
)

internal/pkg/agent/application/upgrade/rollback.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1818
"github.com/elastic/elastic-agent/internal/pkg/agent/control"
19-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
19+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
2020
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
2121
"github.com/elastic/elastic-agent/internal/pkg/agent/install"
2222
"github.com/elastic/elastic-agent/internal/pkg/core/backoff"
@@ -114,7 +114,7 @@ func InvokeWatcher(log *logger.Logger) error {
114114
defer func() {
115115
if cmd.Process != nil {
116116
log.Debugf("releasing watcher %v", cmd.Process.Pid)
117-
cmd.Process.Release()
117+
_ = cmd.Process.Release()
118118
}
119119
}()
120120

internal/pkg/agent/cmd/diagnostics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/spf13/cobra"
2121

2222
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
23-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
23+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
2424
"github.com/elastic/elastic-agent/internal/pkg/cli"
2525
"github.com/elastic/elastic-agent/pkg/component"
2626
)

internal/pkg/agent/cmd/enroll_cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
2727
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
2828
"github.com/elastic/elastic-agent/internal/pkg/agent/configuration"
29-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
29+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
3030
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
3131
"github.com/elastic/elastic-agent/internal/pkg/agent/install"
3232
"github.com/elastic/elastic-agent/internal/pkg/agent/storage"

internal/pkg/agent/cmd/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
3737
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade"
3838
"github.com/elastic/elastic-agent/internal/pkg/agent/configuration"
39-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/server"
39+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/server"
4040
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
4141
"github.com/elastic/elastic-agent/internal/pkg/agent/storage"
4242
"github.com/elastic/elastic-agent/internal/pkg/cli"

internal/pkg/agent/cmd/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
"github.com/spf13/cobra"
1919

20-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
20+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
2121
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
2222
"github.com/elastic/elastic-agent/internal/pkg/cli"
2323
)

internal/pkg/agent/cmd/upgrade.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111

1212
"github.com/spf13/cobra"
1313

14-
"github.com/elastic/elastic-agent/internal/pkg/agent/control"
15-
"github.com/elastic/elastic-agent/internal/pkg/agent/control/client"
14+
control "github.com/elastic/elastic-agent/internal/pkg/agent/control"
15+
"github.com/elastic/elastic-agent/internal/pkg/agent/control/v2/client"
1616
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
1717
"github.com/elastic/elastic-agent/internal/pkg/cli"
1818
)

0 commit comments

Comments
 (0)