Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bluesliverx
Copy link
Contributor

@bluesliverx bluesliverx commented Aug 20, 2025

What does this PR do?

Properly close TCP transports to prevent unclosed transport errors as well as task is destroyed but is still pending warnings/errors. I also changed a log line to debug from error to match the same error throughout the file.

What issues does this PR fix or reference?

Fixes #66568. I'm not 100% sure this fixes all issues with the TCP transport, but it at least gets us a lot closer and prevents tons of errors in Salt 3007.6 for us.

Previous Behavior

See #66568 for errors.

New Behavior

Clean highstates with no errors.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

@bluesliverx
Copy link
Contributor Author

Turns out I had tuned some logging and forgotten about it. We still have this issue:

[ERROR   ] Task was destroyed but it is pending!
task: <Task pending name='Task-826' coro=<RequestClient._stream_return() done, defined at /usr/lib64/salt/lib/python3.10/site-packages/salt/transport/tcp.py:1771> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib64/salt/lib/python3.10/asyncio/futures.py:385, Task.task_wakeup()]>>

I'll have to work on this some more.

Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some pre-commit failures that need to be addressed.

@twangboy twangboy added this to the Chlorine v3007.8 milestone Sep 2, 2025
@bluesliverx
Copy link
Contributor Author

Could we get some tests for these changes?

@twangboy, I added some additional checks to existing TCP transport tests

@bluesliverx
Copy link
Contributor Author

@twangboy, any further recommendations for this PR?

yield self.send_id(self.token, self._reconnected)
self.connected = True
self.event.fire_event({"master": self.opts["master"]}, "__master_connected")
if self.event:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When won't there be an event? Is this something that came up in the test suite only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwoz, I'm not sure exactly what triggered it, but we would see an error about self.event being None when running salt-call commands pretty reliably. This prevents the error, but I'm not sure how to even reproduce this in a test to be honest without having it be very contrived.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There won't be an event if the channel is already closed.

    def close(self):
        """
        Close the channel
        """
        self.transport.close()
        if self.event is not None:
            self.event.destroy()
            self.event = None

Is it possible this could get called after the channel is already closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdrx312, not sure if you're asking me or @dwoz. For my part, I'm not sure why the behavior is happening, only that it is happening. And sadly, I lack the deeper knowledge of salt's message bus handling to know exactly what's going on here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asking @dwoz, trying to address his question of a way that there might not be an event. It seems appropriate to handle the case of there not being event here in case reconnect is called on when it was already closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [3007.0] Channels are closed while listened to

4 participants