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
…24062)

[Ingest Management] Fix reloading of log level for services (#24055)
  • Loading branch information
michalpristas authored Feb 16, 2021
1 parent 774cc05 commit da7de8d
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 @@ -29,6 +29,7 @@
- Fix timeout issue stopping service applications {pull}20256[20256]
- Fix incorrect hash when upgrading agent {pull}22322[22322]
- Fixed nil pointer during unenroll {pull}23609[23609]
- 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 da7de8d

Please sign in to comment.