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: don't erase previous record from /etc/hosts #175

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Conversation

imanenami
Copy link
Contributor

Changes:

  • Preserve other /etc/hosts records on update

@imanenami imanenami linked an issue Dec 5, 2024 that may be closed by this pull request
Copy link
Contributor

@marcoppenheimer marcoppenheimer left a comment

Choose a reason for hiding this comment

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

Great! Blazingly fast too.
Could we add a unit-test for this and fix the failing ones? I'll approve early though 👍🏾
Oh, and open a mirror PR on K8s, but that's lower priority.

@imanenami imanenami requested a review from Batalex December 5, 2024 13:39
Copy link
Contributor

@phvalguima phvalguima left a comment

Choose a reason for hiding this comment

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

I think we are still missing some corner cases such as IP changes. Even converting to a set(), this case would be considered different and, depending on the order, the older ones may end up being prioritized.

I have a quick proposal: we could first check if either fqdn or hostname is present in the host_entries, if yes, then we remove that line.

src/managers/config.py Outdated Show resolved Hide resolved
Copy link
Contributor

@phvalguima phvalguima left a comment

Choose a reason for hiding this comment

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

Thanks @imanenami, I left one last remark but I think other than that, we are good to go.

src/managers/config.py Outdated Show resolved Hide resolved
@imanenami imanenami requested a review from phvalguima December 9, 2024 05:18
@imanenami imanenami merged commit 6ae6bb4 into main Dec 9, 2024
19 checks passed
@imanenami imanenami deleted the fix-issue-174 branch December 9, 2024 09:29
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.

Manage /etc/hosts without erasing previous records
3 participants