Skip to content

{AKS}: fix BlockingIOError by setting stdout to non-blocking#9473

Merged
yanzhudd merged 4 commits intoAzure:mainfrom
mainred:set-read-buff
Dec 19, 2025
Merged

{AKS}: fix BlockingIOError by setting stdout to non-blocking#9473
yanzhudd merged 4 commits intoAzure:mainfrom
mainred:set-read-buff

Conversation

@mainred
Copy link
Copy Markdown
Member

@mainred mainred commented Dec 14, 2025


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copilot AI review requested due to automatic review settings December 14, 2025 14:07
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Dec 14, 2025

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Dec 14, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a BlockingIOError that occurs when writing to a full pipe buffer on macOS, and improves connection error handling for the AKS agent extension. The version is bumped from 1.0.0b13 to 1.0.0b14.

Key Changes:

  • Implemented chunked writing for stdout with retry logic to handle BlockingIOError when pipe buffers are full
  • Added helper functions for terminal mode management, error detection, and proper cleanup
  • Enhanced signal handling and resource cleanup with a centralized cleanup function

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 14 comments.

File Description
src/aks-agent/setup.py Version bump to 1.0.0b14
src/aks-agent/HISTORY.rst Added release notes for version 1.0.0b14 documenting the fixes
src/aks-agent/azext_aks_agent/agent/k8s/pod_exec.py Major refactoring: added terminal mode helpers, centralized cleanup, chunked stdout writing with BlockingIOError handling, improved error detection, and Windows console UTF-8 configuration
Comments suppressed due to low confidence (1)

src/aks-agent/azext_aks_agent/agent/k8s/pod_exec.py:453

  • stderr handling uses sys.stderr.write() which can also encounter BlockingIOError on full pipe buffers, but it lacks the chunking and error handling that stdout has (lines 429-447). For consistency and to prevent similar blocking issues, stderr should use the same chunked writing approach with os.write().
                # Handle stderr
                if resp.peek_stderr():
                    stderr_data = resp.read_stderr()
                    sys.stderr.write(stderr_data)
                    sys.stderr.flush()

@mainred mainred force-pushed the set-read-buff branch 2 times, most recently from 8469721 to 52983ab Compare December 15, 2025 00:57
@mainred mainred changed the title {AKS}: fix BlockingIOError for writing on full pipe buffer {AKS}: fix BlockingIOError by setting stdout to non-blocking Dec 16, 2025
Copy link
Copy Markdown
Member

@gossion gossion left a comment

Choose a reason for hiding this comment

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

lgtm

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@yanzhudd yanzhudd merged commit fc543c4 into Azure:main Dec 19, 2025
24 checks passed
@azclibot
Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ aks-agent-1.0.0b14 ] : https://dev.azure.com/msazure/One/_build/results?buildId=147198073&view=results

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

Labels

AKS Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants