[Bug]: Windows minions with TCP AutoReusePortRangeStartPort set fail to communicate with the salt master

Đang mở
#70,664 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
networking

Hướng nghiên cứu

Start in salt/transport/tcp.py at the _connect method of the publisher (the trace shows _connect around line 2716), and find the SO_REUSEADDR setsockopt call on self.stream. Run the short socket script from the issue on Windows with AutoReusePortRangeStartPort set to confirm the WinError 10045 failure. Done means a Windows minion with that port range set can return job results to the master, and the option is removed or made conditional without breaking the master side.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug needs-triage
What happened?

Change 02a2c8f8f2b7652879d645027c3f57084f153688 introduced an SO_REUSEADDR to _TCPPubServerPublisher._connect's self.stream, around line 1940 in master.

I'm not sure this serves any real purpose on a client socket, and under specific configurations (see below), it breaks Windows minions reporting job status back to the master.

If you customise TCP's AutoReusePortRangeStartPort for use with SO_REUSE_UNICASTPORT [0] like so:

Set-NetTCPSetting -AutoReusePortRangeStartPort 40000 -AutoReusePortRangeNumberOfPorts 25536

and then reboot, the minion will do something like this on startup:

2026-10-30 14:58:10,378 [asyncio          :1886][ERROR   ][8972] Task exception was never retrieved
future: <Task finished name='Task-11' coro=<PublishServer.publish() done, defined at C:\salt\Lib\site-packages\salt\transport\tcp.py:2319> exception=StreamClosedError('Stream is closed')>
Traceback (most recent call last):
  File "C:\salt\Lib\site-packages\salt\transport\tcp.py", line 2336, in publish
    self.connect()
    ~~~~~~~~~~~~^^
  File "C:\salt\Lib\site-packages\salt\transport\tcp.py", line 2317, in connect
    self.pub_sock.connect(timeout=timeout)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\salt\Lib\site-packages\salt\utils\asynchronous.py", line 292, in wrap
    raise exc_info[1].with_traceback(exc_info[2])
  File "C:\salt\Lib\site-packages\salt\utils\asynchronous.py", line 359, in _target
    result = io_loop.run_sync(lambda: getattr(self.obj, key)(*args, **kwargs))
  File "C:\salt\Lib\site-packages\tornado\ioloop.py", line 547, in run_sync
    return future_cell["future"].result()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\salt\Lib\site-packages\salt\transport\tcp.py", line 2716, in _connect
    await self.stream.connect(sock_addr)
tornado.iostream.StreamClosedError: Stream is closed

When the minion is given a job (as simple as test.ping), it will report the following:

2026-10-30 14:59:25,001 [salt.minion      :3890][WARNING ][6488] The minion failed to return the job information for job 20261030215853033196. This is often due to the master being shut down or overloaded. If the master is running, consider increasing the worker_threads value.
2026-10-30 14:59:43,230 [salt.minion      :3890][WARNING ][13428] The minion failed to return the job information for job 20261030215847990023. This is often due to the master being shut down or overloaded. If the master is running, consider increasing the worker_threads value.

The issue can be highlighted with the following script:

import socket
for reuse in (False, True):
    s = socket.socket()
    if reuse: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    try: s.connect(("127.0.0.1", 4511)); print(reuse, "OK", s.getsockname())
    except OSError as e: print(reuse, "FAIL", e.winerror, e)
    finally: s.close()
False OK ('127.0.0.1', 58715)
True FAIL 10045 [WinError 10045] The attempted operation is not supported for the type of object referenced

We have patched the code on the minion to remove that socket option, and it behaves correctly again.

[0] Window's implementation of this behaviour is quite different from Linux's; you need to specify port ranges for it to use, and they should not overlap with the regular ephemeral port range.

Type of salt install

Official msi

Major version

3006.x, 3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

windows-2025

salt --versions-report output
Salt Version:
          Salt: 3008.5
 
Python Version:
        Python: 3.14.7 (heads/main:856cd2f, Sep 30 2026, 03:24:53) [MSC v.1944 64 bit (AMD64)]
 
Dependency Versions:
          cffi: 2.0.0
      cherrypy: 18.10.0
  cryptography: 50.0.1
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.2.1
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 3.00
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.6
        PyYAML: 6.0.3
         PyZMQ: 27.1.0
        relenv: 0.22.27
         smmap: 5.0.2
       timelib: 0.3.0
       Tornado: 6.5.10
           ZMQ: 4.3.5
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist:   
        locale: utf-8
       machine: AMD64
       release: 2025Server
        system: Windows
       version: 2025Server 10.0.26100 SP0 Multiprocessor Free
Ngôn ngữ chính
Python
Star
15.8k
Fork
5.6k
Merge trung bình
5 ngày 9 giờ
Pull request đã merge (30 ngày)
99

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của saltstack/salt

Tất cả issue của saltstack/salt

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.