Skip to content

Commit

Permalink
Cherry-pick #17391 to 7.x: [Agent] Rename agent to elastic-agent (#17599
Browse files Browse the repository at this point in the history
)

* [Agent] Rename agent to elastic-agent (#17391)

[Agent] Rename agent to elastic-agent (#17391)

(cherry picked from commit 66609a3)

* Add Elastic Agent in the Jenkinsfile (#17445)

* Add Elastic Agent in the Jenkinsfile

With the recent moves to Jenkins pipeline the Elastic Agent project was
not currently tested.

* Add Elastic Agent in the Jenkinsfile (#17445)

* Add Elastic Agent in the Jenkinsfile

With the recent moves to Jenkins pipeline the Elastic Agent project was
not currently tested.

* [Agent] Fix merge of config (#17399)

[Agent] Fix merge of config #17399

* [Agent] Handle abs paths on windows correctly (#17461)

* handle windows correctly

* Missing commits from the initial merges of the agent -> master

Co-authored-by: Michal Pristas <[email protected]>
Co-authored-by: Pier-Hugues Pellerin <[email protected]>
  • Loading branch information
ph and michalpristas authored Apr 14, 2020
1 parent 0d330fa commit 52a4e2b
Show file tree
Hide file tree
Showing 299 changed files with 1,275 additions and 583 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ jobs:
go: $TRAVIS_GO_VERSION
stage: test

# Agent
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
env: TARGETS="-C x-pack/elastic-agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Generators
- os: linux
env: TARGETS="-C generator/_templates/metricbeat test test-package"
Expand Down
46 changes: 46 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ pipeline {
stage('Build and Test'){
failFast false
parallel {
stage('Elastic Agent x-pack'){
agent { label 'ubuntu && immutable' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_ELASTIC_AGENT_XPACK != "false"
}
}
steps {
makeTarget("Elastic Agent x-pack Linux", "-C x-pack/elastic-agent testsuite")
}
}

stage('Elastic Agent x-pack Windows'){
agent { label 'windows-immutable && windows-2019' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.windowsTest
}
}
steps {
mageTargetWin("Elastic Agent x-pack Windows Unit test", "x-pack/elastic-agent", "unitTest")
}
}

stage('Elastic Agent Mac OS X'){
agent { label 'macosx' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.macosTest
}
}
steps {
makeTarget("Elastic Agent x-pack Mac OS X", "TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite")
}
}

stage('Filebeat oss'){
agent { label 'ubuntu && immutable' }
options { skipDefaultCheckout() }
Expand Down Expand Up @@ -892,5 +934,9 @@ def loadConfigEnvVars(){

env.BUILD_GENERATOR = isChangedOSSCode(["^generator/.*"])

env.BUILD_ELASTIC_AGENT_XPACK = isChangedXPackCode([
"^x-pack/elastic-agent/.*",
])

env.GO_VERSION = readFile(".go-version").trim()
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BUILD_DIR=$(CURDIR)/build
COVERAGE_DIR=$(BUILD_DIR)/coverage
BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat x-pack/agent
BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat x-pack/elastic-agent
PROJECTS=libbeat $(BEATS)
PROJECTS_ENV=libbeat filebeat metricbeat
PYTHON_ENV?=$(BUILD_DIR)/python-env
Expand Down
28 changes: 14 additions & 14 deletions dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ shared:
content: >
{{ commit }}
mode: 0644
/etc/{{.BeatName}}/agent.reference.yml:
source: 'agent.reference.yml'
/etc/{{.BeatName}}/elastic-agent.reference.yml:
source: 'elastic-agent.reference.yml'
mode: 0644
/etc/{{.BeatName}}/agent.yml:
source: 'agent.yml'
/etc/{{.BeatName}}/elastic-agent.yml:
source: 'elastic-agent.yml'
mode: 0600
config: true
/usr/share/{{.BeatName}}/bin/{{.BeatName}}-god:
Expand Down Expand Up @@ -90,11 +90,11 @@ shared:
/Library/Application Support/{{.BeatVendor}}/{{.BeatName}}/{{.identifier}}.plist:
template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/darwin/launchd-daemon.plist.tmpl'
mode: 0644
/etc/{{.BeatName}}/agent.reference.yml:
source: 'agent.reference.yml'
/etc/{{.BeatName}}/elastic-agent.reference.yml:
source: 'elastic-agent.reference.yml'
mode: 0644
/etc/{{.BeatName}}/agent.yml:
source: 'agent.yml'
/etc/{{.BeatName}}/elastic-agent.yml:
source: 'elastic-agent.yml'
mode: 0600
config: true
/etc/{{.BeatName}}/data/downloads/filebeat-{{ beat_version }}-{{.GOOS}}-{{.AgentArchName}}.tar.gz:
Expand All @@ -118,11 +118,11 @@ shared:
content: >
{{ commit }}
mode: 0644
'agent.reference.yml':
source: 'agent.reference.yml'
'elastic-agent.reference.yml':
source: 'elastic-agent.reference.yml'
mode: 0644
'agent.yml':
source: 'agent.yml'
'elastic-agent.yml':
source: 'elastic-agent.yml'
mode: 0600
config: true

Expand Down Expand Up @@ -163,8 +163,8 @@ shared:
user: 'root'
linux_capabilities: ''
files:
'agent.yml':
source: 'agent.docker.yml'
'elastic-agent.yml':
source: 'elastic-agent.docker.yml'
mode: 0600
config: true

Expand Down
2 changes: 1 addition & 1 deletion libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func (b *Beat) configure(settings Settings) error {
logp.Info("Beat ID: %v", b.Info.ID)

// initialize config manager
b.ConfigManager, err = management.Factory()(b.Config.Management, reload.Register, b.Beat.Info.ID)
b.ConfigManager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
if err != nil {
return err
}
Expand Down
25 changes: 21 additions & 4 deletions libbeat/management/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var Namespace = "libbeat.management"
// DebugK used as key for all things central management
var DebugK = "centralmgmt"

var centralMgmtKey = "x-pack-cm"

// ConfigManager interacts with the beat to update configurations
// from an external source
type ConfigManager interface {
Expand All @@ -47,32 +49,47 @@ type ConfigManager interface {
CheckRawConfig(cfg *common.Config) error
}

// PluginFunc for creating FactoryFunc if it matches a config
type PluginFunc func(*common.Config) FactoryFunc

// FactoryFunc for creating a config manager
type FactoryFunc func(*common.Config, *reload.Registry, uuid.UUID) (ConfigManager, error)

// Register a config manager
func Register(name string, fn FactoryFunc, stability feature.Stability) {
func Register(name string, fn PluginFunc, stability feature.Stability) {
f := feature.New(Namespace, name, fn, feature.MakeDetails(name, "", stability))
feature.MustRegister(f)
}

// Factory retrieves config manager constructor. If no one is registered
// it will create a nil manager
func Factory() FactoryFunc {
func Factory(cfg *common.Config) FactoryFunc {
factories, err := feature.GlobalRegistry().LookupAll(Namespace)
if err != nil {
return nilFactory
}

for _, f := range factories {
if factory, ok := f.Factory().(FactoryFunc); ok {
return factory
if plugin, ok := f.Factory().(PluginFunc); ok {
if factory := plugin(cfg); factory != nil {
return factory
}
}
}

return nilFactory
}

type modeConfig struct {
Mode string `config:"mode" yaml:"mode"`
}

func defaultModeConfig() *modeConfig {
return &modeConfig{
Mode: centralMgmtKey,
}
}

// nilManager, fallback when no manager is present
type nilManager struct{}

Expand Down
25 changes: 0 additions & 25 deletions x-pack/agent/pkg/agent/application/configuration_embed.go

This file was deleted.

33 changes: 0 additions & 33 deletions x-pack/agent/pkg/agent/program/supported.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# agent
build/
agent.dev.yml
elastic-agent.dev.yml
pkg/agent/operation/tests/scripts/short--1.0.yml
pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/configurable
pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/configurablebyfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@


==== Breaking changes
- Rename agent to elastic-agent {pull}17391[17391]

==== Bugfixes

- Fixed tests on windows {pull}16922[16922]
- Fixed installers for SNAPSHOTs and windows {pull}17077[17077]
- Fixed merge of config {pull}17399[17399]
- Handle abs paths on windows correctly {pull}17461[17461]

==== New features

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###################### Agent Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The agent.reference.yml file from the same directory contains all the
# options. The elastic-agent.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ datasources:
dataset: system.filesystem

management:
# Mode of magement, the agent support two modes of operation:
# Mode of management, the Elastic Agent support two modes of operation:
#
# local: The agent will expect to find the inputs configuration in the local file.
# local: The Elastic Agent will expect to find the inputs configuration in the local file.
#
# Default is local.
mode: "local"
Expand Down Expand Up @@ -65,7 +65,7 @@ management:
# Allow fleet to reload his configuration locally on disk.
# Notes: Only specific process configuration will be reloaded.
reload:
# enabled configure the agent to reload or not the local configuration.
# enabled configure the Elastic Agent to reload or not the local configuration.
#
# Default is true
enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###################### Agent Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The agent.reference.yml file from the same directory contains all the
# options. The elastic-agent.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ datasources:
dataset: system.filesystem

management:
# Mode of management, the agent currently only support the following mode:
# Mode of management, the Elastic Agent currently only support the following mode:
#
# local: The agent will expect to find the inputs configuration in the local file.
# local: The Elastic Agent will expect to find the inputs configuration in the local file.
#
# Default is local.
mode: local
Expand Down Expand Up @@ -65,7 +65,7 @@ management:
# Allow fleet to reload his configuration locally on disk.
# Notes: Only specific process configuration will be reloaded.
reload:
# enabled configure the agent to reload or not the local configuration.
# enabled configure the Elastic Agent to reload or not the local configuration.
#
# Default is true
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ datasources:
dataset: system.filesystem

management:
# Mode of management, the agent support two modes of operation:
# Mode of management, the Elastic Agent support two modes of operation:
#
# local: The agent will expect to find the inputs configuration in the local file.
# local: The Elastic Agent will expect to find the inputs configuration in the local file.
#
# Default is local.
mode: "local"
Expand All @@ -36,10 +36,10 @@ management:
# format in which logs will be written, options are json or default.
format: "default"

# Allow the agent to reload his configuration locally on disk.
# Allow the Elastic Agent to reload his configuration locally on disk.
# Notes: Only specific process configuration will be reloaded.
reload:
# enabled configure the agent to reload or not the local configuration.
# enabled configure the Elastic Agent to reload or not the local configuration.
#
# Default is true
enabled: true
Expand All @@ -56,7 +56,7 @@ download:
# timeout for downloading package
timeout: 30s
# file path to a public key used for verifying downloaded artifacts
# if not file is present agent will try to load public key from elastic.co website.
# if not file is present Elastic Agent will try to load public key from elastic.co website.
pgpfile: "${path.data}/elastic.pgp"
# install_path describes the location of installed packages/programs. It is also used
# for reading program specifications.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ download:
# timeout for downloading package
timeout: 30s
# file path to a public key used for verifying downloaded artifacts
# if not file is present agent will try to load public key from elastic.co website.
# if not file is present Elastic Agent will try to load public key from elastic.co website.
pgpfile: "${path.data}/elastic.pgp"
# install_path describes the location of installed packages/programs. It is also used
# for reading program specifications.
Expand Down
Loading

0 comments on commit 52a4e2b

Please sign in to comment.