Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ReportsRemoteConfig capability #114

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
tigrannajaryan marked this conversation as resolved.
Show resolved Hide resolved
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.