util: include stderr in cryptsetup errors#6036
Merged
mergify[bot] merged 2 commits intoFeb 16, 2026
Merged
Conversation
| return &result | ||
| } | ||
| // Include stderr if not empty | ||
| baseErr := fmt.Sprintf("an error (%v) occurred while running %s args: %v", err, program, sanitizedArgs) |
Contributor
There was a problem hiding this comment.
Suggested change
| baseErr := fmt.Sprintf("an error (%v) occurred while running %s args: %v", err, program, sanitizedArgs) | |
| baseErr := fmt.Errof("error running %s args: %v: %w", program, sanitizedArgs: err) |
| size, err := strconv.ParseUint(input, 10, 32) | ||
| if err != nil { | ||
| return fmt.Errorf("could not parse number from %q: %w", input, err) | ||
| return stdout, stderr, fmt.Errorf("%s", baseErr) |
Contributor
There was a problem hiding this comment.
Suggested change
| return stdout, stderr, fmt.Errorf("%s", baseErr) | |
| return stdout, stderr, errors.New(baseErr) |
1b4f034 to
221263a
Compare
nixpanic
reviewed
Feb 10, 2026
| @@ -34,6 +34,8 @@ func CreateTempFile(prefix, contents string) (*os.File, error) { | |||
| // In case of error, remove the file if it was created | |||
| defer func() { | |||
| if err != nil { | |||
| //nolint:errcheck // may return file already closed in happy path | |||
| _ = file.Close() | |||
Member
There was a problem hiding this comment.
Instead of closing the file below, sync/flush the contents and always close it in the deferred statement here. The sync/flush error is more important than the close error, which just can be logged.
nixpanic
reviewed
Feb 10, 2026
nixpanic
left a comment
Member
There was a problem hiding this comment.
Both changes look unrelated, it is probably cleaner to split them into their own commits.
This patch includes the stderr when an error is encountered in cryptsetup. Signed-off-by: Niraj Yadav <niryadav@redhat.com>
This patch makes changes which ensure that the content for tempfile is flushed to disk before returning the handle. It also silently ignores errors when closing and removing the file as sync error has more weightage than these. Signed-off-by: Niraj Yadav <niryadav@redhat.com>
221263a to
4e6b633
Compare
Member
Author
Done |
nixpanic
approved these changes
Feb 16, 2026
Madhu-1
approved these changes
Feb 16, 2026
Member
|
@Mergifyio queue |
Contributor
Merge Queue StatusRule:
This pull request spent 3 hours 43 seconds in the queue, including 3 hours 32 seconds running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does
This patch includes the stderr when an error is encountered in cryptsetup.
This patch additionally fixes a potential memory leak which could occur if
WriteStringfails insidefilepackage.