When cleaning up NetworkManager network configuration files, use os.Remove instead of os.RemoveAll - #367
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_922209917
branch
2 times, most recently
from
July 28, 2026 17:40
c2548ed to
95be855
Compare
…s.Remove` instead of `os.RemoveAll` If `NetworkManager` is the primary network manager, and `manage_primary_nic` is set to false, with the current logic, the guest agent will always think it's removed the primary NIC config due to `os.RemoveAll` always returning `nil` when the file doesn't exist. This means that the following logic depending on the `os.ErrNotExist` error is always hit regardless of whether the file actually existed. PiperOrigin-RevId: 955345364
copybara-service
Bot
force-pushed
the
test_922209917
branch
from
July 28, 2026 17:44
95be855 to
0cf1795
Compare
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.
When cleaning up
NetworkManagernetwork configuration files, useos.Removeinstead ofos.RemoveAllIf
NetworkManageris the primary network manager, andmanage_primary_nicis set to false, with the current logic, the guest agent will always think it's removed the primary NIC config due toos.RemoveAllalways returningnilwhen the file doesn't exist. This means that the following logic depending on theos.ErrNotExisterror is always hit regardless of whether the file actually existed.