diff --git a/x-pack/elastic-agent/.gitignore b/x-pack/elastic-agent/.gitignore index 22e2de50947c..81ce70aa69b3 100644 --- a/x-pack/elastic-agent/.gitignore +++ b/x-pack/elastic-agent/.gitignore @@ -4,5 +4,6 @@ elastic-agent 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/servicable-1.0-darwin-x86/configurable +pkg/agent/transpiler/tests/exec-1.0-darwin-x86_64/exec pkg/agent/application/fleet.yml -pkg/core/plugin/operation/tests/scripts/configurable/1.0/configurable diff --git a/x-pack/elastic-agent/CHANGELOG.next.asciidoc b/x-pack/elastic-agent/CHANGELOG.next.asciidoc index e1804b614c98..805132d6bdcc 100644 --- a/x-pack/elastic-agent/CHANGELOG.next.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.next.asciidoc @@ -42,6 +42,7 @@ - Fix issues with dynamic inputs and conditions {pull}23886[23886] - Fix bad substitution of API key. {pull}24036[24036] - Fix docker enrollment issue related to Fleet Server change. {pull}24155[24155] +- Improve log on failure of Endpoint Security installation. {pull}24429[24429] ==== New features diff --git a/x-pack/elastic-agent/magefile.go b/x-pack/elastic-agent/magefile.go index 0149e7ea0bd4..2585b7269f24 100644 --- a/x-pack/elastic-agent/magefile.go +++ b/x-pack/elastic-agent/magefile.go @@ -192,16 +192,19 @@ func (Build) Clean() { // TestBinaries build the required binaries for the test suite. func (Build) TestBinaries() error { p := filepath.Join("pkg", "agent", "operation", "tests", "scripts") - + p2 := filepath.Join("pkg", "agent", "transpiler", "tests") configurableName := "configurable" serviceableName := "serviceable" + execName := "exec" if runtime.GOOS == "windows" { configurableName += ".exe" serviceableName += ".exe" + execName += ".exe" } return combineErr( RunGo("build", "-o", filepath.Join(p, "configurable-1.0-darwin-x86_64", configurableName), filepath.Join(p, "configurable-1.0-darwin-x86_64", "main.go")), RunGo("build", "-o", filepath.Join(p, "serviceable-1.0-darwin-x86_64", serviceableName), filepath.Join(p, "serviceable-1.0-darwin-x86_64", "main.go")), + RunGo("build", "-o", filepath.Join(p2, "exec-1.0-darwin-x86_64", execName), filepath.Join(p2, "exec-1.0-darwin-x86_64", "main.go")), ) } diff --git a/x-pack/elastic-agent/pkg/agent/program/supported.go b/x-pack/elastic-agent/pkg/agent/program/supported.go index a6189687b2d8..f584060e1d3a 100644 --- a/x-pack/elastic-agent/pkg/agent/program/supported.go +++ b/x-pack/elastic-agent/pkg/agent/program/supported.go @@ -24,7 +24,7 @@ func init() { // spec/heartbeat.yml // spec/metricbeat.yml // spec/packetbeat.yml - unpacked := packer.MustUnpack("eJzMWltz6jqWfp+fcV57Lr6EdHuq+gGTtrAhzsEklqw3SwLbIBs62ICZmv8+JfmCbUiys8+p3fOQgsiypLW0Lt/6Fv/z22G/ov8V7tP/OKzej6v3/yxT/tt//0ZSK8evu2jhm+7cdznNMKfRfkPg4tEG1oks1QtGjoaRPQuQo4QQx4F+91lGL7sIlnbuLe2DPXHyAI5irPk5hiNlnvpFAJ0DhguDTR0VyzkfzVWPGLwZq4l6CqD7Pof4gKGv2MkpshPVkp9pb/8CA0sJfOPCpg4PoHq53c9hk8xRCfAvL9EusidKFGjGaeUbClGNQ4hcpRofR/bE3DPg5y+JmRLgczZuxxVy2UUhHJ0Y8i6TZFyNA6NAmnskKT6E0FVeErMgmnESz+dLMw/Q+LGdOzVjBqJHG1QyXce7Z6vHJkpEUz8nOuZIy/nqdTe7Pqv+Qs0fvSRmHGgup7q7DpC5l3MXP7VOiZF5pJm3JyntzsntqcMJNDTsG+8Yba/yNH9ArhsFkHGSLWbyHYD3K6u5E+XRnuZGrZM0hGcFI2fNUuvAYFdu84LhmQe6d6Sbe7qu9mFTfsKtjKYWwLOK0XPvXPOlGVOgtGchU4/TzVV2qvkHDF2F6M6N3m/2rdY7MuSdGFr0ddPcZcZ2GD482uDMScqUcBJtVxov6NRXqK7s7aeH6HlixiRdRCGwLkvNH80m3l+J7itiznp5ihzNPwT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6Tqpp/ieqlNOz//bf/CwAA//+Z2yhe") SupportedMap = make(map[string]Spec) for f, v := range unpacked { diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/steps.go b/x-pack/elastic-agent/pkg/agent/transpiler/steps.go index 3d52ccacb34d..7f9d0d9fd7fc 100644 --- a/x-pack/elastic-agent/pkg/agent/transpiler/steps.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/steps.go @@ -253,10 +253,21 @@ func (r *ExecFileStep) Execute(ctx context.Context, rootDir string) error { } if err != nil { exitErr, ok := err.(*exec.ExitError) - if ok && exitErr.Stderr != nil && len(exitErr.Stderr) > 0 { - return fmt.Errorf("operation 'Exec' failed: %s", string(exitErr.Stderr)) + if ok && exitErr.Stderr != nil { + errStr := strings.TrimSpace(string(exitErr.Stderr)) + if len(errStr) > 0 { + return fmt.Errorf("operation 'Exec' failed (return code: %d): %s", exitErr.ExitCode(), errStr) + } + } + exitCode := 1 + if ok { + exitCode = exitErr.ExitCode() + } + outStr := strings.TrimSpace(string(output)) + if len(outStr) == 0 { + outStr = "(command had no output)" } - return fmt.Errorf("operation 'Exec' failed: %s", string(output)) + return fmt.Errorf("operation 'Exec' failed (return code: %d): %s", exitCode, outStr) } return nil } diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go b/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go index d618b1e1993f..7a14e63c00d8 100644 --- a/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go @@ -5,7 +5,9 @@ package transpiler import ( + "context" "fmt" + "os" "runtime" "testing" @@ -69,3 +71,67 @@ func TestIsSubpath(t *testing.T) { }) } } + +func TestExecFile_Success(t *testing.T) { + pwd, err := os.Getwd() + if err != nil { + panic(err) + } + binaryPath := "tests/exec-1.0-darwin-x86_64/exec" + step := ExecFile(10, binaryPath, "-output=stdout", "-exitcode=0") + err = step.Execute(context.Background(), pwd) + if err != nil { + t.Fatal("command should not have errored") + } +} + +func TestExecFile_StdErr(t *testing.T) { + pwd, err := os.Getwd() + if err != nil { + panic(err) + } + binaryPath := "tests/exec-1.0-darwin-x86_64/exec" + step := ExecFile(10, binaryPath, "-output=stderr", "-exitcode=15") + err = step.Execute(context.Background(), pwd) + if err == nil { + t.Fatal("command should have errored") + } + errMsg := "operation 'Exec' failed (return code: 15): message written to stderr" + if err.Error() != errMsg { + t.Fatalf("got unexpected error: %s", err) + } +} + +func TestExecFile_StdOut(t *testing.T) { + pwd, err := os.Getwd() + if err != nil { + panic(err) + } + binaryPath := "tests/exec-1.0-darwin-x86_64/exec" + step := ExecFile(10, binaryPath, "-output=stdout", "-exitcode=16") + err = step.Execute(context.Background(), pwd) + if err == nil { + t.Fatal("command should have errored") + } + errMsg := "operation 'Exec' failed (return code: 16): message written to stdout" + if err.Error() != errMsg { + t.Fatalf("got unexpected error: %s", err) + } +} + +func TestExecFile_NoOutput(t *testing.T) { + pwd, err := os.Getwd() + if err != nil { + panic(err) + } + binaryPath := "tests/exec-1.0-darwin-x86_64/exec" + step := ExecFile(10, binaryPath, "-no-output", "-exitcode=17") + err = step.Execute(context.Background(), pwd) + if err == nil { + t.Fatal("command should have errored") + } + errMsg := "operation 'Exec' failed (return code: 17): (command had no output)" + if err.Error() != errMsg { + t.Fatalf("got unexpected error: %s", err) + } +} diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/tests/exec-1.0-darwin-x86_64/main.go b/x-pack/elastic-agent/pkg/agent/transpiler/tests/exec-1.0-darwin-x86_64/main.go new file mode 100644 index 000000000000..be043c53ac96 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/transpiler/tests/exec-1.0-darwin-x86_64/main.go @@ -0,0 +1,35 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package main + +import ( + "flag" + "fmt" + "io" + "os" +) + +func main() { + noOutput := flag.Bool("no-output", false, "disable output") + output := flag.String("output", "stderr", "output destination") + exitcode := flag.Int("exitcode", 0, "exit code") + flag.Parse() + + if *noOutput { + os.Exit(*exitcode) + } + + var dest io.Writer + if *output == "stdout" { + dest = os.Stdout + } else if *output == "stderr" { + dest = os.Stderr + } else { + panic("unknown destination") + } + + fmt.Fprintf(dest, "message written to %s", *output) + os.Exit(*exitcode) +} diff --git a/x-pack/elastic-agent/spec/endpoint.yml b/x-pack/elastic-agent/spec/endpoint.yml index 7265ba2e693b..b45a3d35648d 100644 --- a/x-pack/elastic-agent/spec/endpoint.yml +++ b/x-pack/elastic-agent/spec/endpoint.yml @@ -11,12 +11,16 @@ check_install: path: "endpoint-security" args: - "verify" + - "--log" + - "stderr" timeout: 30 post_install: - exec_file: path: "endpoint-security" args: - "install" + - "--log" + - "stderr" - "--upgrade" - "--resources" - "endpoint-security-resources.zip" @@ -26,6 +30,8 @@ pre_uninstall: path: "endpoint-security" args: - "uninstall" + - "--log" + - "stderr" timeout: 600 rules: - fix_stream: {}