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

Update to OpAMP spec 0.8.0 #207

Merged
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
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ type OpAMPClient interface {
// AgentDescription returns the last value successfully set by SetAgentDescription().
AgentDescription() *protobufs.AgentDescription

// SetHealth sets the health status of the Agent. The AgentHealth will be included
// SetHealth sets the health status of the Agent. The health will be included
// in the next status report sent to the Server. MAY be called before or after Start().
// May be also called after Start().
// May be also called from OnMessage handler.
//
// nil health parameter is not allowed and will return an error.
SetHealth(health *protobufs.AgentHealth) error
SetHealth(health *protobufs.ComponentHealth) error

// UpdateEffectiveConfig fetches the current local effective config using
// GetEffectiveConfig callback and sends it to the Server.
Expand Down
2 changes: 1 addition & 1 deletion client/clientimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ func TestReportAgentHealth(t *testing.T) {

assert.Error(t, client.SetHealth(nil))

sendHealth := &protobufs.AgentHealth{
sendHealth := &protobufs.ComponentHealth{
Healthy: true,
StartTimeUnixNano: 123,
LastError: "bad error",
Expand Down
2 changes: 1 addition & 1 deletion client/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *httpClient) SetAgentDescription(descr *protobufs.AgentDescription) erro
}

// SetHealth implements OpAMPClient.SetHealth.
func (c *httpClient) SetHealth(health *protobufs.AgentHealth) error {
func (c *httpClient) SetHealth(health *protobufs.ComponentHealth) error {
return c.common.SetHealth(health)
}

Expand Down
12 changes: 6 additions & 6 deletions client/internal/clientcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var (
ErrAgentDescriptionMissing = errors.New("AgentDescription is nil")
ErrAgentDescriptionNoAttributes = errors.New("AgentDescription has no attributes defined")
ErrAgentHealthMissing = errors.New("AgentHealth is nil")
ErrHealthMissing = errors.New("health 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")
Expand Down Expand Up @@ -84,7 +84,7 @@
}

if c.Capabilities&protobufs.AgentCapabilities_AgentCapabilities_ReportsHealth != 0 && c.ClientSyncedState.Health() == nil {
return ErrAgentHealthMissing
return ErrHealthMissing

Check warning on line 87 in client/internal/clientcommon.go

View check run for this annotation

Codecov / codecov/patch

client/internal/clientcommon.go#L87

Added line #L87 was not covered by tests
}

// Prepare remote config status.
Expand Down Expand Up @@ -243,11 +243,11 @@
return nil
}

// SetHealth sends a status update to the Server with the new AgentHealth
// and remembers the AgentHealth in the client state so that it can be sent
// SetHealth sends a status update to the Server with the new agent health
// and remembers the health in the client state so that it can be sent
// to the Server when the Server asks for it.
func (c *ClientCommon) SetHealth(health *protobufs.AgentHealth) error {
// store the AgentHealth to send on reconnect
func (c *ClientCommon) SetHealth(health *protobufs.ComponentHealth) error {
// store the health to send on reconnect
if err := c.ClientSyncedState.SetHealth(health); err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions client/internal/clientstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (

// ClientSyncedState stores the state of the Agent messages that the OpAMP Client needs to
// have access to synchronize to the Server. 4 messages can be stored in this store:
// AgentDescription, AgentHealth, RemoteConfigStatus and PackageStatuses.
// AgentDescription, ComponentHealth, RemoteConfigStatus and PackageStatuses.
//
// See OpAMP spec for more details on how state synchronization works:
// https://github.com/open-telemetry/opamp-spec/blob/main/specification.md#Agent-to-Server-state-synchronization
Expand All @@ -34,7 +34,7 @@ type ClientSyncedState struct {
mutex sync.Mutex

agentDescription *protobufs.AgentDescription
health *protobufs.AgentHealth
health *protobufs.ComponentHealth
remoteConfigStatus *protobufs.RemoteConfigStatus
packageStatuses *protobufs.PackageStatuses
}
Expand All @@ -45,7 +45,7 @@ func (s *ClientSyncedState) AgentDescription() *protobufs.AgentDescription {
return s.agentDescription
}

func (s *ClientSyncedState) Health() *protobufs.AgentHealth {
func (s *ClientSyncedState) Health() *protobufs.ComponentHealth {
defer s.mutex.Unlock()
s.mutex.Lock()
return s.health
Expand Down Expand Up @@ -82,13 +82,13 @@ func (s *ClientSyncedState) SetAgentDescription(descr *protobufs.AgentDescriptio
return nil
}

// SetHealth sets the AgentHealth in the state.
func (s *ClientSyncedState) SetHealth(health *protobufs.AgentHealth) error {
// SetHealth sets the agent health in the state.
func (s *ClientSyncedState) SetHealth(health *protobufs.ComponentHealth) error {
if health == nil {
return ErrAgentHealthMissing
return ErrHealthMissing
}

clone := proto.Clone(health).(*protobufs.AgentHealth)
clone := proto.Clone(health).(*protobufs.ComponentHealth)

defer s.mutex.Unlock()
s.mutex.Lock()
Expand Down
9 changes: 5 additions & 4 deletions client/wsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (c *wsClient) SetAgentDescription(descr *protobufs.AgentDescription) error
return c.common.SetAgentDescription(descr)
}

func (c *wsClient) SetHealth(health *protobufs.AgentHealth) error {
func (c *wsClient) SetHealth(health *protobufs.ComponentHealth) error {
return c.common.SetHealth(health)
}

Expand Down Expand Up @@ -193,9 +193,10 @@ func (c *wsClient) ensureConnected(ctx context.Context) error {
}

// runOneCycle performs the following actions:
// 1. connect (try until succeeds).
// 2. send first status report.
// 3. receive and process messages until error happens.
// 1. connect (try until succeeds).
// 2. send first status report.
// 3. receive and process messages until error happens.
//
// If it encounters an error it closes the connection and returns.
// Will stop and return if Stop() is called (ctx is cancelled, isStopping is set).
func (c *wsClient) runOneCycle(ctx context.Context) {
Expand Down
10 changes: 5 additions & 5 deletions internal/examples/supervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (s *Supervisor) startOpAMP() error {
return err
}

err = s.opampClient.SetHealth(&protobufs.AgentHealth{Healthy: false})
err = s.opampClient.SetHealth(&protobufs.ComponentHealth{Healthy: false})
if err != nil {
return err
}
Expand Down Expand Up @@ -413,7 +413,7 @@ func (s *Supervisor) startAgent() {
if err != nil {
errMsg := fmt.Sprintf("Cannot start the agent: %v", err)
s.logger.Errorf(errMsg)
s.opampClient.SetHealth(&protobufs.AgentHealth{Healthy: false, LastError: errMsg})
s.opampClient.SetHealth(&protobufs.ComponentHealth{Healthy: false, LastError: errMsg})
return
}
s.startedAt = time.Now()
Expand Down Expand Up @@ -448,7 +448,7 @@ func (s *Supervisor) healthCheck() {
}

// Prepare OpAMP health report.
health := &protobufs.AgentHealth{
health := &protobufs.ComponentHealth{
StartTimeUnixNano: uint64(s.startedAt.UnixNano()),
}

Expand Down Expand Up @@ -497,7 +497,7 @@ func (s *Supervisor) runAgentProcess() {
s.commander.Pid(), s.commander.ExitCode(),
)
s.logger.Debugf(errMsg)
s.opampClient.SetHealth(&protobufs.AgentHealth{Healthy: false, LastError: errMsg})
s.opampClient.SetHealth(&protobufs.ComponentHealth{Healthy: false, LastError: errMsg})

// TODO: decide why the agent stopped. If it was due to bad config, report it to server.

Expand Down Expand Up @@ -538,7 +538,7 @@ func (s *Supervisor) Shutdown() {
}
if s.opampClient != nil {
s.opampClient.SetHealth(
&protobufs.AgentHealth{
&protobufs.ComponentHealth{
Healthy: false, LastError: "Supervisor is shutdown",
},
)
Expand Down
2 changes: 1 addition & 1 deletion internal/opamp-spec
Submodule opamp-spec updated 3 files
+56 −0 faq.md
+95 −9 proto/opamp.proto
+490 −283 specification.md
Loading
Loading