Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .buildkite/pipeline.trigger.integration.tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions .buildkite/scripts/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
4 changes: 1 addition & 3 deletions internal/stack/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions internal/stack/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,27 @@ 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use profile as parameter instead of using snapshotFile as parameter.
Having the profile as parameter, allows us:

  • obtain the snapshot file path
  • get the needed Environment variables from the Profile for the docker-compose logs command

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")
}

opts := compose.CommandOptions{
Env: newEnvBuilder().
withEnvs(appConfig.StackImageRefs(install.DefaultStackVersion).AsEnv()).
withEnv(stackVariantAsEnv(install.DefaultStackVersion)).
withEnvs(profile.ComposeEnvVars()).
build(),
Services: []string{serviceName},
}
Expand All @@ -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")
}
Expand Down