diff --git a/Jenkinsfile b/Jenkinsfile index 5a1e3f94f2a3..3e0197594af2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -309,7 +309,7 @@ def cloud(Map args = [:]) { withCloudTestEnv(args) { startCloudTestEnv(name: args.directory, dirs: args.dirs, withAWS: args.withAWS) try { - targetWithoutNode(context: args.context, command: args.command, directory: args.directory, label: args.label, withModule: args.withModule, isMage: true, id: args.id, name: args.directory) + targetWithoutNode(context: args.context, command: args.command, directory: args.directory, label: args.label, withModule: args.withModule, isMage: true, id: args.id) } finally { terraformCleanup(name: args.directory, dir: args.directory, withAWS: args.withAWS) } @@ -590,8 +590,6 @@ def targetWithoutNode(Map args = [:]) { def enableRetry = args.get('enableRetry', false) def withGCP = args.get('withGCP', false) def withNodejs = args.get('withNodejs', false) - // def dirs = args.get('dirs',[]) - String name = normalise(args.name) withGithubNotify(context: "${context}") { withBeatsEnv(archive: true, withModule: withModule, directory: directory, id: args.id) { dumpVariables() @@ -599,16 +597,6 @@ def targetWithoutNode(Map args = [:]) { // make commands use -C while mage commands require the dir(folder) // let's support this scenario with the location variable. dir(isMage ? directory : '') { - // unstash in the same directory where the files were stashed - // dir('input/awss3/_meta/terraform'){ - // echo "terraform-${name}" - // try { - // unstash(name: "terraform-${name}") - // sh "ls -la ${pwd()}" - // } catch (error) { - // echo "error unstashing: ${error}" - // } - // } if (enableRetry) { // Retry the same command to bypass any kind of flakiness. // Downside: genuine failures will be repeated. diff --git a/metricbeat/internal/sysinit/init.go b/metricbeat/internal/sysinit/init.go index 880063506b9c..a14a77095503 100644 --- a/metricbeat/internal/sysinit/init.go +++ b/metricbeat/internal/sysinit/init.go @@ -19,6 +19,7 @@ package sysinit import ( "flag" + "fmt" "sync" "github.com/elastic/beats/v7/libbeat/common/cfgwarn" @@ -39,21 +40,24 @@ type HostFSConfig struct { HostFS string `config:"hostfs"` } -// MetricbeatHostFSConfig +// MetricbeatHostFSConfig carries config information for the hostfs setting type MetricbeatHostFSConfig struct { HostFS string `config:"system.hostfs"` } -// Init either the system or linux module. This will produce different modules depending on if we're running under agent or not. +// InitSystemModule initializes either either the system or linux module. This will produce different modules depending on if we're running under agent or not. func InitSystemModule(base mb.BaseModule) (mb.Module, error) { // common code for the base use case of `hostfs` being set at the module-level logger := logp.L() - hostfs, userSet := findConfigValue(base) + hostfs, userSet, err := findConfigValue(base) + if err != nil { + return nil, fmt.Errorf("error fetching config value: %w", err) + } if fleetmode.Enabled() { logger.Infof("initializing HostFS values under agent: %s", hostfs) return fleetInit(base, hostfs, userSet) } - return metricbeatInit(base, hostfs, userSet) + return metricbeatInit(base, hostfs) } func fleetInit(base mb.BaseModule, modulepath string, moduleSet bool) (mb.Module, error) { @@ -71,12 +75,11 @@ func fleetInit(base mb.BaseModule, modulepath string, moduleSet bool) (mb.Module } // Deal with the legacy configs available to metricbeat -func metricbeatInit(base mb.BaseModule, modulePath string, moduleSet bool) (mb.Module, error) { +func metricbeatInit(base mb.BaseModule, modulePath string) (mb.Module, error) { var hostfs = modulePath var userSet bool // allow the CLI to override other settings if hostfsCLI != nil && *hostfsCLI != "" { - cfgwarn.Deprecate("8.0.0", "The --system.hostfs flag will be removed in the future and replaced by a config value.") hostfs = *hostfsCLI userSet = true } @@ -91,22 +94,29 @@ func metricbeatInit(base mb.BaseModule, modulePath string, moduleSet bool) (mb.M // A user can supply either `system.hostfs` or `hostfs`. // In additon, we will probably want to change Integration Config values to `hostfs` as well. // We need to figure out which one we got, if any. -func findConfigValue(base mb.BaseModule) (string, bool) { +// Returns false if no config value was set +func findConfigValue(base mb.BaseModule) (string, bool, error) { partialConfig := HostFSConfig{} - base.UnpackConfig(&partialConfig) + err := base.UnpackConfig(&partialConfig) + if err != nil { + return "", false, fmt.Errorf("error unpacking hostfs config: %w", err) + } // if the newer value is set, just use that. if partialConfig.HostFS != "" { - return partialConfig.HostFS, true + return partialConfig.HostFS, true, nil } legacyConfig := MetricbeatHostFSConfig{} - base.UnpackConfig(&legacyConfig) + err = base.UnpackConfig(&legacyConfig) + if err != nil { + return "", false, fmt.Errorf("error unpacking legacy config: %w", err) + } if legacyConfig.HostFS != "" { cfgwarn.Deprecate("8.0.0", "The system.hostfs config value will be removed, use `hostfs` from within the module config.") // Only fallback to this if the user didn't set anything else - return legacyConfig.HostFS, true + return legacyConfig.HostFS, true, nil } - return "/", false + return "/", false, nil }