Skip to content

fix: avoid SnapCtl pipe deadlock - #26

Merged
albertodonato merged 3 commits into
openstack-charmers:mainfrom
zhhuabj:pip_overflow_2162621
Sep 24, 2026
Merged

albertodonato merged 3 commits into
openstack-charmers:mainfrom
zhhuabj:pip_overflow_2162621

Conversation

@zhhuabj

@zhhuabj zhhuabj commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Use Popen.communicate() to consume stdout and stderr while snapctl runs.

Calling wait() before reading either pipe can deadlock when snapctl output exceeds the OS pipe buffer: the child blocks while writing, while the parent waits for the child to exit.

Preserve stderr for non-zero exits by passing the captured output to SnapCtlError, and add a regression test that writes large data to both streams.

LP: #2162621
Closes: #25

@zhhuabj

zhhuabj commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Here is self-test result - https://pastebin.com/Qwv1ELmE

@zhhuabj
zhhuabj force-pushed the pip_overflow_2162621 branch from a0778f9 to 7be2d89 Compare August 24, 2026 08:19
Use Popen.communicate() to consume stdout and stderr while snapctl runs.

Calling wait() before reading either pipe can deadlock when snapctl output
exceeds the OS pipe buffer: the child blocks while writing, while the parent
waits for the child to exit.

Preserve stderr for non-zero exits by passing the captured output to
SnapCtlError, and add a regression test that writes large data to both streams.

LP: #2162621
Closes: openstack-charmers#25
CI-blocked by openstack-charmers#27
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
@zhhuabj
zhhuabj force-pushed the pip_overflow_2162621 branch from 7be2d89 to 4ca1f1e Compare August 31, 2026 03:12
@zhhuabj

zhhuabj commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @albertodonato The CI checks for this PR are currently blocked by #30. Could you pls first merge #30, then I will update this branch from main and rerun CI.

@albertodonato
albertodonato merged commit 76f8166 into openstack-charmers:main Sep 24, 2026
8 of 10 checks passed
johnramsden pushed a commit to canonical/microceph that referenced this pull request Sep 29, 2026
Update snap-helpers from 46803aa9 to 76f8166 to stay in sync with the
upstream SnapCtl pipe deadlock fix (openstack-charmers/snap-helpers#26).

microceph-orch only uses Snap().paths and does not call SnapCtl, so it
is not affected by the deadlock; this is a dependency hygiene bump.

Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
hemanthnakkina pushed a commit to canonical/snap-openstack-hypervisor that referenced this pull request Sep 30, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

The configure hook calls snap.config.get_options() and snap.services,
which can deadlock when snapctl output exceeds the OS pipe buffer.

Partial-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
gboutry pushed a commit to canonical/snap-cinder-volume that referenced this pull request Oct 7, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

The configure hook calls snap.config.get_options(), which deadlocks when
snapctl output exceeds the OS pipe buffer (e.g. a large base64 CA during
TLS CA renewal), leaving the hook killed by SIGKILL and the backend
config unwritten.

Closes-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
gboutry pushed a commit to canonical/snap-openstack-network-agents that referenced this pull request Oct 7, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

The configure hook reads snap config via snaphelpers, which can deadlock
when snapctl output exceeds the OS pipe buffer.

Partial-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
zhhuabj added a commit to zhhuabj/snap-openstack that referenced this pull request Oct 9, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

sunbeam's configure hook and checks call snap.config.get_options() and
SnapCtl, which can deadlock when snapctl output exceeds the OS pipe
buffer.

Partial-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
zhhuabj added a commit to zhhuabj/microceph that referenced this pull request Nov 5, 2026
Update snap-helpers from 46803aa9 to 76f8166 to stay in sync with the
upstream SnapCtl pipe deadlock fix (openstack-charmers/snap-helpers#26).

microceph-orch only uses Snap().paths and does not call SnapCtl, so it
is not affected by the deadlock; this is a dependency hygiene bump.

Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
(cherry picked from commit 5df62e1)
himax16 pushed a commit to canonical/snap-openstack that referenced this pull request Nov 5, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

sunbeam's configure hook and checks call snap.config.get_options() and
SnapCtl, which can deadlock when snapctl output exceeds the OS pipe
buffer.

Partial-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
(cherry picked from commit 5f72ac1)
johnramsden pushed a commit to canonical/microceph that referenced this pull request Nov 5, 2026
Update snap-helpers from 46803aa9 to 76f8166 to stay in sync with the
upstream SnapCtl pipe deadlock fix (openstack-charmers/snap-helpers#26).

microceph-orch only uses Snap().paths and does not call SnapCtl, so it
is not affected by the deadlock; this is a dependency hygiene bump.

(cherry picked from commit 5df62e1)

Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
hemanthnakkina pushed a commit to canonical/snap-cinder-volume that referenced this pull request Nov 17, 2026
Update snap-helpers from 46803aa9 to 76f8166 to pull in the upstream
fix for the SnapCtl.run() pipe deadlock (openstack-charmers/snap-helpers#26).

The configure hook calls snap.config.get_options(), which deadlocks when
snapctl output exceeds the OS pipe buffer (e.g. a large base64 CA during
TLS CA renewal), leaving the hook killed by SIGKILL and the backend
config unwritten.

Closes-bug: #2162621
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
(cherry picked from commit 46cbd9e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SnapCtl.run deadlocks when snapctl output exceeds the pipe buffer

2 participants