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

Fix bug that threw an error while searching for linux headers through a symlink #1821

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

kpattaswamy
Copy link
Member

@kpattaswamy kpattaswamy commented Jan 18, 2024

Summary: This PR removes a condition which checks to see if a host path exists in the filesystem of a process when trying to resolve symlinks.

The function fs::Exists() returned false for a broken symlink when the expectation was to return true because the path existed although it was a broken symlink. This function would later on fix the broken symlink path by reading its target host and converting the broken path into the actual path. This makes the code removal safe as the next check: is_symlink will return an error code if there is no file.

Type of change: /kind bug

Test Plan: Existing tests pass and deployed the PEM with the updated fix and saw that the Linux header files were found.

@kpattaswamy kpattaswamy marked this pull request as ready for review January 18, 2024 22:52
@kpattaswamy kpattaswamy requested a review from a team as a code owner January 18, 2024 22:52
@etep
Copy link

etep commented Jan 20, 2024

We should update the error message when is_symlink returns an error. Something like:

return error::NotFound(absl::Substitute("Did not find host headers at path: $0, $1.", p.string(), ec.message()));

Copy link

@etep etep left a comment

Choose a reason for hiding this comment

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

Can we try a PR description along the lines of:

Method fs::Exists returned false for a broken symlink, but its expected behavior was to return true, i.e. because something existed (even if that something was a broken symlink). This function later fixes the broken symlink by reading its target and converting that target into a host path.

Removing the fs::Exists check solves the bug where the function early exits before resolving a symlink (see above explanation) and is safe because the next check, is_symlink will return an error code if there is no file.

@etep
Copy link

etep commented Jan 20, 2024

Also, we can update the test plan, something like:

deployed pem with bug fix and observed correct behavior.

@etep
Copy link

etep commented Jan 23, 2024

My own comment:

The condition, removed in this PR, was fully redundant to the next check is_symlink. Not only was it redundant, but it was also wrong in the case of a broken symlink.

@kpattaswamy kpattaswamy changed the title Fix a condition that checks to see if a symlink path can be found in the file system Fix bug that threw an error while searching for linux headers through a symlink Jan 25, 2024
Signed-off-by: Kartik Pattaswamy <kpattaswamy@pixielabs.ai>
Signed-off-by: Kartik Pattaswamy <kpattaswamy@pixielabs.ai>
@kpattaswamy kpattaswamy requested a review from a team January 25, 2024 22:16
@oazizi000 oazizi000 merged commit e633c50 into pixie-io:main Feb 16, 2024
34 checks passed
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