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

Cherry-pick #24055 to 7.x: Fix reloading of log level for services #24061

Merged
merged 1 commit into from
Feb 16, 2021
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
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 make status readable in the log. {pull}23849[23849]
- Fixed Monitoring filebeat and metricbeat not connecting to Agent over GRPC {pull}23843[23843]
- 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