Skip to content

Commit

Permalink
Use ReportsRemoteConfig capability
Browse files Browse the repository at this point in the history
Implements spec change open-telemetry/opamp-spec#115
  • Loading branch information
tigrannajaryan committed Jul 28, 2022
1 parent 3d4cbdc commit 6f10b4c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/clientimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ func verifyRemoteConfigUpdate(t *testing.T, successCase bool, expectStatus *prot
}
},
},
Capabilities: protobufs.AgentCapabilities_AcceptsRemoteConfig,
Capabilities: protobufs.AgentCapabilities_AcceptsRemoteConfig | protobufs.AgentCapabilities_ReportsRemoteConfig,
}
prepareClient(t, &settings, client)

Expand Down
5 changes: 5 additions & 0 deletions client/internal/clientcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
ErrAgentDescriptionNoAttributes = errors.New("AgentDescription has no attributes defined")
ErrAgentHealthMissing = errors.New("AgentHealth is nil")
ErrReportsEffectiveConfigNotSet = errors.New("ReportsEffectiveConfig capability is not set")
ErrReportsRemoteConfigNotSet = errors.New("ReportsRemoteConfig capability is not set")
ErrPackagesStateProviderNotSet = errors.New("PackagesStateProvider must be set")
ErrAcceptsPackagesNotSet = errors.New("AcceptsPackages and ReportsPackageStatuses must be set")

Expand Down Expand Up @@ -293,6 +294,10 @@ func (c *ClientCommon) UpdateEffectiveConfig(ctx context.Context) error {
// It also remembers the new RemoteConfigStatus in the client state so that it can be
// sent to the Server when the Server asks for it.
func (c *ClientCommon) SetRemoteConfigStatus(status *protobufs.RemoteConfigStatus) error {
if c.Capabilities&protobufs.AgentCapabilities_ReportsRemoteConfig == 0 {
return ErrReportsRemoteConfigNotSet
}

if status.LastRemoteConfigHash == nil {
return errLastRemoteConfigHashNil
}
Expand Down
1 change: 1 addition & 0 deletions internal/examples/agent/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (agent *Agent) start() error {
},
RemoteConfigStatus: agent.remoteConfigStatus,
Capabilities: protobufs.AgentCapabilities_AcceptsRemoteConfig |
protobufs.AgentCapabilities_ReportsRemoteConfig |
protobufs.AgentCapabilities_ReportsEffectiveConfig |
protobufs.AgentCapabilities_ReportsOwnMetrics,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/examples/server/data/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (agent *Agent) processStatusUpdate(
// Check if any fields were omitted in the status report.
effectiveConfigOmitted := agent.hasCapability(protobufs.AgentCapabilities_ReportsEffectiveConfig) && newStatus.EffectiveConfig == nil
packageStatusesOmitted := agent.hasCapability(protobufs.AgentCapabilities_ReportsPackageStatuses) && newStatus.PackageStatuses == nil
remoteConfigStatusOmitted := agent.hasCapability(protobufs.AgentCapabilities_AcceptsRemoteConfig) && newStatus.RemoteConfigStatus == nil
remoteConfigStatusOmitted := agent.hasCapability(protobufs.AgentCapabilities_ReportsRemoteConfig) && newStatus.RemoteConfigStatus == nil
healthOmitted := agent.hasCapability(protobufs.AgentCapabilities_ReportsHealth) && newStatus.Health == nil

// True if the status was not fully reported.
Expand Down
1 change: 1 addition & 0 deletions internal/examples/supervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (s *Supervisor) startOpAMP() error {
OnMessageFunc: s.onMessage,
},
Capabilities: protobufs.AgentCapabilities_AcceptsRemoteConfig |
protobufs.AgentCapabilities_ReportsRemoteConfig |
protobufs.AgentCapabilities_ReportsEffectiveConfig |
protobufs.AgentCapabilities_ReportsOwnMetrics |
protobufs.AgentCapabilities_ReportsHealth,
Expand Down
2 changes: 2 additions & 0 deletions internal/proto/opamp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ enum AgentCapabilities {
AcceptsRestartCommand = 0x00000400;
// The Agent will report Health via AgentToServer.health field.
ReportsHealth = 0x00000800;
// The Agent will report RemoteConfig status via AgentToServer.remote_config_status field.
ReportsRemoteConfig = 0x00001000;

// Add new capabilities here, continuing with the least significant unused bit.
}
Expand Down
18 changes: 12 additions & 6 deletions protobufs/opamp.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f10b4c

Please sign in to comment.