WeblateOrg / helm

Helm Chart for Weblate
https://docs.weblate.org/en/latest/admin/install/kubernetes.html
Apache License 2.0
31 stars 43 forks source link

Command failed: ValueError: Invalid IPv6 URL when trying to use existing redis #479

Closed AurimasNav closed 1 month ago

AurimasNav commented 1 month ago

Describe the issue

I'm unable to successfully configure values.yaml to use existing redis instance.

I already tried

Steps to reproduce the behavior

configure values.yaml

values.yaml

redis:
  redisHost: "redis-master.redis"
  enabled: false
  db: 1
  auth:
    enabled: true
    existingSecret: redis
    existingSecretPasswordKey: password

I have redis chart installed in namespace redis

Expected behavior

weblate connects to existing redis instance

Screenshots

No response

Exception traceback

Refreshing stats...
[2024-10-04 11:48:43,501: WARNING/136] Command failed: ValueError: Invalid IPv6 URL
Traceback (most recent call last):
  File "/app/venv/bin/weblate", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/app/venv/lib/python3.12/site-packages/weblate/runner.py", line 19, in main
    utility.execute()
  File "/app/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/management/base.py", line 29, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/management/commands/ensure_stats.py", line 18, in handle
    all_strings = GlobalStats().all
                  ^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 284, in __getattr__
    self.calculate_by_name(name)
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 295, in calculate_by_name
    self.calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 369, in calculate_basic
    self._calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 1281, in _calculate_basic
    super()._calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 853, in _calculate_basic
    stats_obj.calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 369, in calculate_basic
    self._calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 1262, in _calculate_basic
    super()._calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 853, in _calculate_basic
    stats_obj.calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 369, in calculate_basic
    self._calculate_basic()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 854, in _calculate_basic
    stats_obj.save()
  File "/app/venv/lib/python3.12/site-packages/weblate/utils/stats.py", line 473, in save
    update_translation_stats_parents.delay_on_commit(pk)
  File "/app/venv/lib/python3.12/site-packages/celery/contrib/django/task.py", line 17, in delay_on_commit
    return transaction.on_commit(functools.partial(self.delay, *args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/django/db/transaction.py", line 134, in on_commit
    get_connection(using).on_commit(func, robust)
  File "/app/venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 750, in on_commit
    func()
  File "/app/venv/lib/python3.12/site-packages/celery/app/task.py", line 444, in delay
    return self.apply_async(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/task.py", line 594, in apply_async
    return app.send_task(
           ^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/base.py", line 797, in send_task
    with self.producer_or_acquire(producer) as P:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/base.py", line 932, in producer_or_acquire
    producer, self.producer_pool.acquire, block=True,
              ^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/base.py", line 1354, in producer_pool
    return self.amqp.producer_pool
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/amqp.py", line 591, in producer_pool
    self.app.connection_for_write()]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/base.py", line 829, in connection_for_write
    return self._connection(url or self.conf.broker_write_url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/celery/app/base.py", line 880, in _connection
    return self.amqp.Connection(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/kombu/connection.py", line 200, in __init__
    transport = transport or urlparse(hostname).scheme
                             ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/urllib/parse.py", line 395, in urlparse
    splitresult = urlsplit(url, scheme, allow_fragments)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/urllib/parse.py", line 497, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

Additional context

If I change redisHost to redis-master I can see in the logs that it is trying to connect to redis-master:6379 and facing error due to unknown host, which is expected as it resides in another namespace, but when I specify full hostname with namespace included it produces the error above.

helm chart version: 0.5.16

Mart-Kuc commented 1 month ago

Hi @AurimasNav, the connection name (redisHost) you provided is incorrect. When connecting between namespaces in Kubernetes, you need to specify the fully-qualified DNS name (service name, hostname, and local cluster directly). For example: redis-master.redis.svc.cluster.local

AurimasNav commented 1 month ago

Hi, thanks for the clarification. Somehow the thought to test with fqdn escaped my mind since I could ping redis-master.redis from the weblate pod, test that the port is listening etc., also most of other services I've used had no problem accepting this hostname format, but as long as fqdn works the problem is solved.

github-actions[bot] commented 1 month ago

The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.

AurimasNav commented 1 month ago

I was to quick to mark it as resolved without testing. The redis-master.redis.svc.cluster.local produces exactly the same error. Once again I've tested the name from neighbouring pod in weblate namespace, I can resolve the name and verify that redis port is listening for redis-master.redis.svc.cluster.local.

Mart-Kuc commented 1 month ago

I don't think it is related to helm issue. But at this moment I don't have time to reproduce this issue. Maybe do you have special characters in your databases user's password (e.g [ or similar)? In same situation urllib3 parser treating the password as an IPv6 address

nijel commented 1 month ago

It might be caused by special chars somewhere, the Redis URL is built naively, see https://github.com/WeblateOrg/weblate/blob/3c5dc2a805251404778737acedd64c2447396ebe/weblate/settings_docker.py#L1173-L1178 and https://github.com/WeblateOrg/weblate/blob/3c5dc2a805251404778737acedd64c2447396ebe/weblate/settings_docker.py#L1319-L1325

AurimasNav commented 1 month ago

I've regenerated the password to include no special characters and it is working now.

github-actions[bot] commented 1 month ago

The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.