Skip to content

Commit ba95d99

Browse files
committed
Let's print more container logs to figure out what is happening.
1 parent ce078c3 commit ba95d99

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

.buildkite/scripts/e2e-pipeline/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ pip install -r .buildkite/scripts/e2e-pipeline/requirements.txt
4444
### Run on local
4545
Run the following command from the repo dir:
4646
```bash
47-
python3 .buildkite/scripts/e2e-pipeline/main.py --skip-setup=true --integrations='apache','nginx'
47+
python3 .buildkite/scripts/e2e-pipeline/main.py --skip-setup --integrations='apache','nginx'
4848
```
4949

5050
This will run entire ELK docker containers.
51-
Remove `--skip-setup` or use `--skip-setup=true` if you are running the script for the first time, where it needs to set up elastic-package and integrations.
51+
Do not use `--skip-setup` if you are running the script for the first time, where it needs to set up elastic-package and integrations.
5252

5353
## Troubleshooting
5454
- The project retries on some operations to overcome timeout issues, uses [`retry` tool](https://formulae.brew.sh/formula/retry). If you get `retry` undefined error, make sure to install it.

.buildkite/scripts/e2e-pipeline/bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ def run_elastic_stack(self, skip_setup=False) -> None:
197197
self.__scan_for_unsupported_processors()
198198
self.__setup_elastic_package_profile()
199199
self.__spin_stack()
200-
self.__install_plugin()
201-
self.__reload_container()
200+
#self.__install_plugin()
201+
#self.__reload_container()
202202
self.__update_pipeline_config()
203203

204204
def stop_elastic_stack(self) -> None:

.buildkite/scripts/e2e-pipeline/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def main(skip_setup=False, integrations=[]):
4141
with BootstrapContextManager(skip_setup) as bootstrap:
4242
working_dir = os.getcwd()
4343
test_plugin = PluginTest()
44+
45+
util.show_container_logs("logstash-")
46+
util.show_container_logs("elasticsearch-")
47+
util.show_container_logs("elastic-agent-")
48+
4449
packages = integrations or INTEGRATION_PACKAGES_TO_TEST
4550
for package in packages:
4651
try:
@@ -50,9 +55,9 @@ def main(skip_setup=False, integrations=[]):
5055
print(f"Test failed for {package} with {e}.")
5156
failed_packages.append(package)
5257

53-
util.show_container_logs("elastic-package-stack-e2e-logstash-1")
54-
util.show_container_logs("elastic-package-stack-e2e-elasticsearch-1")
55-
util.show_container_logs("elastic-package-stack-e2e-elastic-agent-1")
58+
util.show_container_logs("logstash-")
59+
util.show_container_logs("elasticsearch-")
60+
util.show_container_logs("elastic-agent-")
5661

5762
if len(failed_packages) > 0:
5863
raise Exception(f"Following packages failed: {failed_packages}")

.buildkite/scripts/e2e-pipeline/util.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,26 @@ def call_url_with_retry(url: str, max_retries: int = 5, delay: int = 1) -> reque
1818
session.mount(schema, HTTPAdapter(max_retries=retries))
1919
return session.get(url)
2020

21-
def show_container_logs(container_name: str):
21+
def show_container_logs(container_prefix: str):
2222
client = docker.from_env()
23-
container = client.containers.get(container_name)
23+
containers = client.containers.list(all=True)
24+
print(f"Available container names: {[c.name for c in containers]}")
25+
matching_containers = [c for c in containers if container_prefix in c.name]
2426

25-
# pretty printing
26-
print(f"{container_name} docker container logs..")
27-
container_logs = container.logs().decode('utf-8')
28-
for log_line in container_logs.splitlines():
29-
print(log_line)
27+
if not matching_containers:
28+
print(f"No containers found with prefix '{container_prefix}'")
29+
return
30+
31+
for container in matching_containers:
32+
# pretty printing with clear separators
33+
separator = "=" * 80
34+
print(f"\n{separator}")
35+
print(f"Container: {container.name}")
36+
print(f"{separator}")
37+
container_logs = container.logs().decode('utf-8')
38+
for log_line in container_logs.splitlines():
39+
print(f" {log_line}")
40+
print(f"{separator}\n")
3041

3142
def run_or_raise_error(commands: list, error_message):
3243
result = subprocess.run(commands, universal_newlines=True, stdout=subprocess.PIPE)

0 commit comments

Comments
 (0)