Skip to content

Commit

Permalink
Agentbeat: remove unused files from package and silence new error mes…
Browse files Browse the repository at this point in the history
…sage (#39064) (#39159)

* Remove Beat config files from agentbeat.

Beats no longer reads config files at startup when run as part of agent.

* Silence new error message with agentbeat.

* Add comment to log line.

(cherry picked from commit e6cae46)

Co-authored-by: Craig MacKenzie <[email protected]>
  • Loading branch information
mergify[bot] and cmacknz authored Apr 23, 2024
1 parent 4baab4c commit d3b2beb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 34 deletions.
4 changes: 2 additions & 2 deletions dev-tools/packaging/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func checkConfigPermissionsWithMode(t *testing.T, p *packageFile, expectedMode o
return
}
}
t.Errorf("no config file found matching %v", configFilePattern)
t.Logf("no config file found matching %v", configFilePattern)
})
}

Expand All @@ -288,7 +288,7 @@ func checkConfigOwner(t *testing.T, p *packageFile, expectRoot bool) {
return
}
}
t.Errorf("no config file found matching %v", configFilePattern)
t.Logf("no config file found matching %v", configFilePattern)
})
}

Expand Down
6 changes: 5 additions & 1 deletion filebeat/fileset/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"gopkg.in/yaml.v2"

"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common/fleetmode"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/paths"
Expand Down Expand Up @@ -149,7 +150,10 @@ func NewModuleRegistry(moduleConfigs []*conf.C, beatInfo beat.Info, init bool, f
stat, err := os.Stat(modulesPath)
if err != nil || !stat.IsDir() {
log := logp.NewLogger(logName)
log.Errorf("Not loading modules. Module directory not found: %s", modulesPath)
if !fleetmode.Enabled() {
// When run under agent via agentbeat there is no modules directory and this is expected.
log.Errorf("Not loading modules. Module directory not found: %s", modulesPath)
}
return &ModuleRegistry{log: log}, nil //nolint:nilerr // empty registry, no error
}

Expand Down
31 changes: 0 additions & 31 deletions x-pack/agentbeat/dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ shared:
NOTICE.txt:
source: '{{ repo.RootDir }}/NOTICE.txt'
mode: 0644
README.md:
template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/common/README.md.tmpl'
mode: 0644
.build_hash.txt:
content: >
{{ commit }}
Expand All @@ -35,32 +32,6 @@ shared:
source: '{{.BeatName}}.spec.yml'
mode: 0644

- &config_files
'auditbeat.yml':
source: '{{ repo.RootDir }}/x-pack/auditbeat/auditbeat.yml'
mode: 0600
config: true
'filebeat.yml':
source: '{{ repo.RootDir }}/x-pack/filebeat/filebeat.yml'
mode: 0600
config: true
'heartbeat.yml':
source: '{{ repo.RootDir }}/x-pack/heartbeat/heartbeat.yml'
mode: 0600
config: true
'metricbeat.yml':
source: '{{ repo.RootDir }}/x-pack/metricbeat/metricbeat.yml'
mode: 0600
config: true
'osquerybeat.yml':
source: '{{ repo.RootDir }}/x-pack/osquerybeat/osquerybeat.yml'
mode: 0600
config: true
'packetbeat.yml':
source: '{{ repo.RootDir }}/x-pack/packetbeat/packetbeat.yml'
mode: 0600
config: true

- &unix_osquery_files
'osquery-extension.ext':
source: '{{ repo.RootDir }}/x-pack/osquerybeat/ext/osquery-extension/build/golang-crossbuild/osquery-extension-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}'
Expand All @@ -76,14 +47,12 @@ shared:
<<: *common
files:
<<: *binary_files
<<: *config_files
<<: *unix_osquery_files

- &windows_binary_spec
<<: *common
files:
<<: *binary_files
<<: *config_files
<<: *windows_osquery_files

# License modifiers for the Elastic License
Expand Down

0 comments on commit d3b2beb

Please sign in to comment.