Skip to content
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

Remove log file from runc commands #1436

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

helsaawy
Copy link
Contributor

Certain runc commands (eg, Delete, State) do not need to use a log file
since runc does not consume the stdio and pass it to the container.
This PR switches the commands to consume the error directly from stderr,
without needing to parse from a file.

This fixes a bug where the directory containing the runc log file for a
container is deleted before the container itself can be deleted via the
runc command.
Runc errors that the directory containing the logfile does not exist, but since the returned error is errors.Wrapf(runcErr,...), where runcErr is parsed from the logfile, it ends up being nil.
The fix is to read directly from stderr, skipping the log file.
Additionally, even if the runc delete command errors, the container is still deleted from the gcs, since if runc was able to delete successfully delete the container but still errored, future restarts will be successful.

Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com

@helsaawy helsaawy requested a review from a team as a code owner June 18, 2022 00:29
type standardLogEntry struct {
Level logrus.Level `json:"level"`
Message string `json:"msg"`
Err error `json:"error,omitempty"`
}

func (l *standardLogEntry) asError() (err error) {
err = parseRuncError(l.Message)
if l.Err != nil {
err = errors.Wrapf(err, l.Err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

just errors.Wrap?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given we swapped to fmt.Errorf in most other places in this PR, could we continue the tradition here

Copy link
Contributor

Choose a reason for hiding this comment

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

Although I remember the GCS being one of the only places we made use of the stack embedding pkg/errors does, but I'll need to find this..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets see if this breaks nightly (more) ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay here's what I was talking about

if stack := gcserr.BaseStackTrace(errForResponse); stack != nil {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I forgot about that
do we use the line number or stack frame at all in debugging?
Since "github.com/pkg/errors" is on its way out, do we want to switch over to "errors", and hope we add enough context via fmt.Errorf?
Or keep it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm... I'd say lets leave it for now and make shifting away a separate change (if we want).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undid all the errors stuff

Certain runc commands (eg, Delete, State) do not need to use a log file
since they do not pass stdio to the container.
This PR switches the commands to consume the error directly from stderr,
without needing to parse from a file.

This fixes a bug where the directory containing the runc log file for a
container is deleted before the container itself can be deleted via the
runc command.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy merged commit bc3b951 into microsoft:master Jun 22, 2022
@helsaawy helsaawy deleted the he/deletestate branch June 22, 2022 21:22
kiashok pushed a commit to kiashok/hcsshim that referenced this pull request Jul 11, 2022
Certain runc commands (eg, Delete, State) do not need to use a log file
since they do not pass stdio to the container.
This PR switches the commands to consume the error directly from stderr,
without needing to parse from a file.

This fixes a bug where the directory containing the runc log file for a
container is deleted before the container itself can be deleted via the
runc command.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
anmaxvl added a commit that referenced this pull request Feb 7, 2023
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
Certain runc commands (eg, Delete, State) do not need to use a log file
since they do not pass stdio to the container.
This PR switches the commands to consume the error directly from stderr,
without needing to parse from a file.

This fixes a bug where the directory containing the runc log file for a
container is deleted before the container itself can be deleted via the
runc command.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
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.

3 participants