Skip to content

chore: kbagent log stdout on error #9454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cjc7373
Copy link
Contributor

@cjc7373 cjc7373 commented Jun 16, 2025

Log kbagent command's stdout on error so that users would have more context to debug.

One more thing. Action command is executed by os/exec. If the command A has created a subprocess B, and A exits before B exits, the command's timeout, which is included in the context, is not respected. (the exact same problem described in golang/go#23019) That is because B shares stdout/stderr fd with A, and go will wait for the fd to close before cmd.Wait() returns. This PR adds cmd.WaitDelay to handle this.

The timeout parameter seems like not used currently, but it makes the test slow.

@apecloud-bot
Copy link
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.0

@github-actions github-actions bot added the size/M Denotes a PR that changes 30-99 lines. label Jun 16, 2025
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Project coverage is 59.93%. Comparing base (1d711bd) to head (38c9185).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/kbagent/service/action.go 0.00% 5 Missing ⚠️
pkg/kbagent/service/command.go 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9454      +/-   ##
==========================================
+ Coverage   59.63%   59.93%   +0.30%     
==========================================
  Files         500      517      +17     
  Lines       54384    55678    +1294     
==========================================
+ Hits        32431    33370     +939     
- Misses      19033    19336     +303     
- Partials     2920     2972      +52     
Flag Coverage Δ
unittests 59.93% <64.70%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjc7373 cjc7373 marked this pull request as ready for review June 24, 2025 09:30
@cjc7373 cjc7373 requested a review from a team as a code owner June 24, 2025 09:30
@cjc7373 cjc7373 added the pick-1.0 Auto cherry-pick to release-1.0 when PR merged label Jun 24, 2025
@cjc7373 cjc7373 force-pushed the support/action-log-stdout-on-error branch from 8d3c46e to 38c9185 Compare June 25, 2025 07:06
@apecloud-bot apecloud-bot added the approved PR Approved Test label Jun 26, 2025
return nil, (*result).err
}
return (*result).stdout.Bytes(), nil
return (*result).stdout.Bytes(), wrapExecError((*result).err, (*result).stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not operate on stdout when a failure occurs. This is the behavior defined by the API.

return nil, errors.Wrapf(proto.ErrFailed, errMsg)
}
return nil, err
return result.stdout.Bytes(), wrapExecError(result.err, result.stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved PR Approved Test pick-1.0 Auto cherry-pick to release-1.0 when PR merged size/M Denotes a PR that changes 30-99 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants