在 Airflow 中为 postgres 创建默认用户时出错

时间:2021-07-29 12:03:03

标签: postgresql airflow

我在运行创建新 postgres 用户的命令时遇到以下错误。任何可能导致此问题的想法 - 该错误似乎与我运行的 create bash 命令无关。

(sandbox) airflow@airflowvm:~/airflow$ airflow users create -u admin -p admin -r Admin -f admin -l admin -e admin@airflow.com

Traceback (most recent call last):
  File "/home/airflow/sandbox/bin/airflow", line 8, in <module>
    sys.exit(main())
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/__main__.py", line 40, in main
    args.func(args)
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 47, in command
    func = import_string(import_path)
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/utils/module_loading.py", line 32, in import_string
    module = import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/cli/commands/user_command.py", line 29, in <module>
    from airflow.www.app import cached_app
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/www/app.py", line 38, in <module>
    from airflow.www.extensions.init_views import (
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/www/extensions/init_views.py", line 29, in <module>
    from airflow.www.views import lazy_add_provider_discovered_options_to_connection_form
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/www/views.py", line 2836, in <module>
    class ConnectionFormWidget(FormWidget):
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/www/views.py", line 2839, in ConnectionFormWidget
    field_behaviours = json.dumps(ProvidersManager().field_behaviours)
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/providers_manager.py", line 397, in field_behaviours
    self.initialize_providers_manager()
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/providers_manager.py", line 129, in initialize_providers_manager
    self._discover_all_providers_from_packages()
  File "/home/airflow/sandbox/lib/python3.8/site-packages/airflow/providers_manager.py", line 149, in _discover_all_providers_from_packages
    self._provider_schema_validator.validate(provider_info)
  File "/home/airflow/sandbox/lib/python3.8/site-packages/jsonschema/validators.py", line 353, in validate
    raise error
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('logo' was unexpected)

Failed validating 'additionalProperties' in schema['properties']['integrations']['items']:
    {'additionalProperties': False,
     'properties': {'external-doc-url': {'description': 'URL to external '
                                                        'documentation for '
                                                        'the integration.',
                                         'type': 'string'},
                    'how-to-guide': {'description': 'List of paths to '
                                                    'how-to-guide for the '
                                                    'integration. The path '
                                                    'must start with '
                                                    "'/docs/'",
                                     'items': {'type': 'string'},
                                     'type': 'array'},
                    'integration-name': {'description': 'Name of the '
                                                        'integration.',
                                         'type': 'string'},
                    'tags': {'description': 'List of tags describing the '
                                            "integration. While we're "
                                            'using RST, only one tag is '
                                            'supported per integration.',
                             'items': {'enum': ['apache',
                                                'aws',
                                                'azure',
                                                'gcp',
                                                'gmp',
                                                'google',
                                                'protocol',
                                                'service',
                                                'software',
                                                'yandex'],
                                       'type': 'string'},
                             'maxItems': 1,
                             'minItems': 1,
                             'type': 'array'}},
     'required': ['integration-name', 'external-doc-url', 'tags'],
     'type': 'object'}

On instance['integrations'][0]:
    {'external-doc-url': 'https://www.postgresql.org/',
     'how-to-guide': ['/docs/apache-airflow-providers-postgres/operators/postgres_operator_howto_guide.rst'],
     'integration-name': 'PostgreSQL',
     'logo': '/integration-logos/postgres/Postgres.png',
     'tags': ['software']}

预期结果:

Admin user admin created

当我运行命令 airflow db check 时,我可以成功连接到 INFO - Connection successful.

1 个答案:

答案 0 :(得分:1)

我相信您将 Airflow 2.0.0 与不兼容的提供程序一起使用(可能在您安装时强制使用)。如果您想使用具有 >= 2.1 限制的 Postgres Provider,请将 Airflow 升级到 2.1+。

在此处查看更改日志中的评论:https://airflow.apache.org/docs/apache-airflow-providers-postgres/stable/index.html#id1

相关问题