diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index fcfb55a783..157bbd30eb 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -25,7 +25,7 @@ for test in ${STACK_COMMAND_TESTS[@]}; do echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/stack/*/logs/*.log" - echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/*.log" + echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/**/*" echo " - build/elastic-stack-status/*/*" done @@ -43,7 +43,7 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do echo " artifact_paths:" echo " - build/test-results/*.xml" echo " - build/elastic-stack-dump/stack/check-*/logs/*.log" - echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/*.log" + echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*" echo " - build/elastic-stack-status/*/*" if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" @@ -63,7 +63,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " artifact_paths:" echo " - build/test-results/*.xml" echo " - build/elastic-stack-dump/stack/check-*/logs/*.log" - echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/*.log" + echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*" done popd > /dev/null diff --git a/.buildkite/scripts/integration_tests.sh b/.buildkite/scripts/integration_tests.sh index eedb363b13..0436950e74 100755 --- a/.buildkite/scripts/integration_tests.sh +++ b/.buildkite/scripts/integration_tests.sh @@ -121,8 +121,14 @@ if [[ "${TARGET}" == "${PARALLEL_TARGET}" ]]; then if [[ "${UPLOAD_SAFE_LOGS}" -eq 1 ]] ; then upload_safe_logs \ "${JOB_GCS_BUCKET_INTERNAL}" \ - "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/*" \ - "insecure-logs/${PACKAGE}/" + "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/*.*" \ + "insecure-logs/${PACKAGE}/elastic-agent-logs/" + + # required for <8.6.0 + upload_safe_logs \ + "${JOB_GCS_BUCKET_INTERNAL}" \ + "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/default/*" \ + "insecure-logs/${PACKAGE}/elastic-agent-logs/default/" upload_safe_logs \ "${JOB_GCS_BUCKET_INTERNAL}" \ diff --git a/internal/stack/dump.go b/internal/stack/dump.go index 7a80a27077..abe088a806 100644 --- a/internal/stack/dump.go +++ b/internal/stack/dump.go @@ -52,12 +52,10 @@ func dumpStackLogs(options DumpOptions) error { return errors.Wrapf(err, "can't create output location (path: %s)", logsPath) } - snapshotPath := options.Profile.Path(profileStackPath, SnapshotFile) - for _, serviceName := range observedServices { logger.Debugf("Dump stack logs for %s", serviceName) - content, err := dockerComposeLogs(serviceName, snapshotPath) + content, err := dockerComposeLogs(serviceName, options.Profile) if err != nil { logger.Errorf("can't fetch service logs (service: %s): %v", serviceName, err) } else { diff --git a/internal/stack/logs.go b/internal/stack/logs.go index 961350bc22..41f10c4561 100644 --- a/internal/stack/logs.go +++ b/internal/stack/logs.go @@ -12,9 +12,17 @@ import ( "github.com/elastic/elastic-package/internal/compose" "github.com/elastic/elastic-package/internal/docker" "github.com/elastic/elastic-package/internal/install" + "github.com/elastic/elastic-package/internal/profile" ) -func dockerComposeLogs(serviceName string, snapshotFile string) ([]byte, error) { +func dockerComposeLogs(serviceName string, profile *profile.Profile) ([]byte, error) { + appConfig, err := install.Configuration() + if err != nil { + return nil, errors.Wrap(err, "can't read application configuration") + } + + snapshotFile := profile.Path(profileStackPath, SnapshotFile) + p, err := compose.NewProject(DockerComposeProjectName, snapshotFile) if err != nil { return nil, errors.Wrap(err, "could not create docker compose project") @@ -22,7 +30,9 @@ func dockerComposeLogs(serviceName string, snapshotFile string) ([]byte, error) opts := compose.CommandOptions{ Env: newEnvBuilder(). + withEnvs(appConfig.StackImageRefs(install.DefaultStackVersion).AsEnv()). withEnv(stackVariantAsEnv(install.DefaultStackVersion)). + withEnvs(profile.ComposeEnvVars()). build(), Services: []string{serviceName}, } @@ -48,7 +58,7 @@ func copyDockerInternalLogs(serviceName, outputPath string) error { outputPath = filepath.Join(outputPath, serviceName+"-internal") serviceContainer := p.ContainerName(serviceName) - err = docker.Copy(serviceContainer, "/usr/share/elastic-agent/state/data/logs/default", outputPath) + err = docker.Copy(serviceContainer, "/usr/share/elastic-agent/state/data/logs/", outputPath) if err != nil { return errors.Wrap(err, "docker copy failed") }