question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrations problem with custom logger

See original GitHub issue

Apache Airflow version: 2.0.2

Kubernetes version : v1.19.12

Environment:

  • Cloud provider or hardware configuration: hardware
  • OS (e.g. from /etc/os-release): Debian GNU/Linux 10 (buster)
  • Kernel (e.g. uname -a): 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 GNU/Linux
  • Install tools: Helm
  • Others:

What happened:

We tried to make custom logger like in documentation, because we want redirect task logs to stdout (by default logs writes to file in worker pod). We made code for custom logger, set param logging_config_class = logconfig.task_logs_to_std.LOGGING_CONFIG, set PYTHONPATH in helm chart. After that, we created configMap with logger source and mounted it inside pod with volume+volumeMount to directory logconfig When we installed this chart, there was a error with run-airflow-migrations.

ERROR! Maximum number of retries (20) reached.

 

Last check result:
$ airflow db check
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.7/site-packages/airflow/logging_config.py", line 40, in configure_logging
    logging_config = import_string(logging_class_path)
  File "/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/module_loading.py", line 32, in import_string
    module = import_module(module_path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'logconfig'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):
  File "/home/airflow/.local/bin/airflow", line 5, in <module>
    from airflow.__main__ import main
  File "/home/airflow/.local/lib/python3.7/site-packages/airflow/__init__.py", line 46, in <module>
    settings.initialize()
  File "/home/airflow/.local/lib/python3.7/site-packages/airflow/settings.py", line 434, in initialize
    LOGGING_CLASS_PATH = configure_logging()
  File "/home/airflow/.local/lib/python3.7/site-packages/airflow/logging_config.py", line 49, in configure_logging
    raise ImportError(f'Unable to load custom logging from {logging_class_path} due to {err}')
ImportError: Unable to load custom logging from logconfig.task_logs_to_std.LOGGING_CONFIG due to No module named 'logconfig'

In result, pods with scheduler and webserver does not works.

Logger code:

from copy import deepcopy
from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG
import sys

LOGGING_CONFIG = deepcopy(DEFAULT_LOGGING_CONFIG)
LOGGING_CONFIG["handlers"]["task"] = {
    "class": "logging.StreamHandler",
    "formatter": "airflow",
    "stream": sys.stdout,
}

What you expected to happen: I expected that migration will be ok and we can see task logs in stdout.

Anything else we need to know: If there are any way how to redirect task logs in pods to stdout - please let me know.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
potiukcommented, Jul 12, 2021

Apparently you miss logconfig module in your image. You need to create a custom image and make sure logconfig is instaled there. See https://airflow.apache.org/docs/docker-stack/build.html on how to build your own image with your dependencies.

0reactions
WolfWood72commented, Jul 13, 2021

Thank you for answer!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I connect custom logging to my ef6 migrations?
See my answer for details on how to attach the logger. Seeing your log logic, I'd recommend looking into log enrichers. There is...
Read more >
Custom Log4j Logger Not Working After 10.5 Migration ...
Custom Log4j logging is not working after 10.5 migration from 9.x? You can try below steps. Since 10.5, webMethods has migrated to Log4j2....
Read more >
Logging from within the migration · Issue #680 - GitHub
I would like to be able to log information from inside of the migration. ... what I did was create a custom announcer...
Read more >
USMT common issues - Windows Client | Microsoft Learn
The following sections discuss common issues that you might see when you run the User State Migration Tool (USMT) 10.0 tools. USMT produces...
Read more >
Migrating custom logging configurations to Log4j 2
If you're using custom logging configurations on your remote agents, migrate them to the Log4j 2-compatible format by applying the previous ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found