Skip to content

Commit

Permalink
[Ingest Management] Fix reloading of log level for services (#24055)
Browse files Browse the repository at this point in the history
[Ingest Management] Fix reloading of log level for services (#24055)
  • Loading branch information
michalpristas authored Feb 16, 2021
1 parent 5538a21 commit 55b1e2a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- Fixed Monitoring filebeat and metricbeat not connecting to Agent over GRPC {pull}23843[23843]
- Fixed make status readable in the log. {pull}23849[23849]
- Windows agent doesn't uninstall with a lowercase `c:` drive in the path {pull}23998[23998]
- Fix reloading of log level for services {pull}[24055]24055

==== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ revision: 5
fleet:
agent:
id: fleet-agent-id
logging.level: error
host:
id: host-agent-id
api:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Endpoint Host
fleet:
agent:
id: fleet-agent-id
logging.level: error
host:
id: host-agent-id
access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw
Expand Down
6 changes: 6 additions & 0 deletions x-pack/elastic-agent/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ func NewConfigFrom(from interface{}, opts ...interface{}) (*Config, error) {
}
if len(skippedKeys) > 0 {
err = cfg.Merge(skippedKeys, ucfg.ResolveNOOP)

// we modified incoming object
// cleanup so skipped keys are not missing
for k, v := range skippedKeys {
data[k] = v
}
}
return newConfigFrom(cfg), err
}
Expand Down
11 changes: 11 additions & 0 deletions x-pack/elastic-agent/pkg/core/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ func (s *Server) Checkin(server proto.ElasticAgent_CheckinServer) error {
}()

var ok bool
var observedConfigStateIdx uint64
var firstCheckin *proto.StateObserved
select {
case firstCheckin, ok = <-firstCheckinChan:
if firstCheckin != nil {
observedConfigStateIdx = firstCheckin.ConfigStateIdx
}
break
case <-time.After(InitialCheckinTimeout):
// close connection
Expand Down Expand Up @@ -281,6 +285,13 @@ func (s *Server) Checkin(server proto.ElasticAgent_CheckinServer) error {
s.logger.Debug("check-in stream cannot connect, application is being destroyed; closing connection")
return status.Error(codes.Unavailable, "application cannot connect being destroyed")
}

// application is running as a service and counter is already counting
// force config reload
if observedConfigStateIdx > 0 {
appState.expectedConfigIdx = observedConfigStateIdx + 1
}

checkinDone := make(chan bool)
appState.checkinDone = checkinDone
appState.checkinLock.Unlock()
Expand Down

0 comments on commit 55b1e2a

Please sign in to comment.