Skip to content

bug:fix runc delete run before delete exec.fifo #4735

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 1 commit into
base: main
Choose a base branch
from

Conversation

ningmingxiao
Copy link
Contributor

@ningmingxiao ningmingxiao commented Apr 21, 2025

if runc delete run before delete exec.fifo
runc delete will container root dir "delete /runc/nmx003"

func handleFifoResult(result openResult) error {
	if result.err != nil {
		return result.err
	}
	f := result.file
	defer f.Close()
	if err := readFromExecFifo(f); err != nil {
		return err
	}
	return os.Remove(f.Name())
}

os.remove will reurn a error
ERRO[0030] remove /run/runc/nmx003/exec.fifo: no such file or directory

@kolyshkin
Copy link
Contributor

@ningmingxiao can you provide a reproducer?

@ningmingxiao
Copy link
Contributor Author

ningmingxiao commented Apr 21, 2025

I add some sleep at

func handleFifoResult(result openResult) error {
	if result.err != nil {
		return result.err
	}
	f := result.file
	defer f.Close()
	if err := readFromExecFifo(f); err != nil {
		return err
	}
        time.Sleep(time.Second*30)
	return os.Remove(f.Name())
}

runc create nmx001
runc start nmx001
when it is running at time.Sleep(time.Second*30)
runc delete nmx001 it will happen. @kolyshkin
It's not easy to reproduce unless a delay is added

@ningmingxiao ningmingxiao force-pushed the fix_start branch 2 times, most recently from d1560e6 to 4446f72 Compare April 22, 2025 01:38
@ningmingxiao
Copy link
Contributor Author

I think RemoveAll is better

@kolyshkin
Copy link
Contributor

I think RemoveAll is better

In its current implementation, and if path points to a non-directory (or an empty directory) -- yes, it's essentially does the same as I suggested above, i.e.

        err := os.Remove(path)
        if err == nil || os.IsNotExist(err) {
                  return nil
        }

but in a (theoretically possible) case when path is a non-empty directory, it will go ahead and remove it recursively, which is probably not what we really want here. I would prefer an error in such a case (even if it doesn't look like it's practically possible).

@ningmingxiao
Copy link
Contributor Author

done, thanks @kolyshkin

@ningmingxiao
Copy link
Contributor Author

ping @kolyshkin can this pr be merged ?

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@Copilot 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 bug related to the improper deletion of exec.fifo, which causes issues when runc delete is executed before deleting exec.fifo.

  • Updated error handling in handleFifoResult to ignore os.IsNotExist errors during file removal.
  • Prevents an error from being returned when exec.fifo is already removed, ensuring smooth deletion of the container's root directory.

@@ -290,7 +290,11 @@ func handleFifoResult(result openResult) error {
if err := readFromExecFifo(f); err != nil {
return err
}
return os.Remove(f.Name())
err := os.Remove(f.Name())
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

The updated error handling correctly ignores errors when exec.fifo does not exist, which fixes the bug. Consider adding a debug log when an unexpected error occurs to help diagnose issues in production environments.

Copilot uses AI. Check for mistakes.

@lifubang
Copy link
Member

Pull Request Overview

This PR fixes a bug related to the improper deletion of exec.fifo, which causes issues when runc delete is executed before deleting exec.fifo.

  • Updated error handling in handleFifoResult to ignore os.IsNotExist errors during file removal.
  • Prevents an error from being returned when exec.fifo is already removed, ensuring smooth deletion of the container's root directory.

@Copilot Do you think this is really a bug.
If the container is deleted by other process, I think runc start / run should return the exact error and have a non-zero exit code, but not to ignore some errors. Or else the users may wrongly think that we start/run the container successfully, but the result is opposite.

@lifubang lifubang requested a review from Copilot May 28, 2025 02:26
Copy link

@Copilot 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 addresses a bug where deleting the container's exec.fifo file causes an error if the file no longer exists.

  • Modified the error handling in handleFifoResult to ignore os.IsNotExist errors when removing the exec.fifo file.
  • Ensures os.Remove is checked before returning any errors, preventing spurious failures.

@lifubang
Copy link
Member

Do you think this is really a bug.
If the container is deleted by other process, I think runc start / run should return the exact error and have a non-zero exit code, but not to ignore some errors. Or else the users may wrongly think that we start/run the container successfully, but the result is opposite.

I think Copilot can't talk with us here.

@ningmingxiao @kolyshkin WDYT

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