Use shutil.move instead of os.rename to move config_db.json on place#66
Open
leenr wants to merge 1 commit intosonic-net:masterfrom
Open
Use shutil.move instead of os.rename to move config_db.json on place#66leenr wants to merge 1 commit intosonic-net:masterfrom
shutil.move instead of os.rename to move config_db.json on place#66leenr wants to merge 1 commit intosonic-net:masterfrom
Conversation
|
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 66 in repo sonic-net/sonic-ztp |
Author
|
/azpw run |
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I also encountered the same issue. I think this solution is good, but I'm not sure why it hasn't been merged yet. You also explained the root cause |
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.
What I did
I replaced
os.renamecall withshutil.move.Also, I reordered imports to be in alphabetical order (cosmetic change).
Why I did it
After sonic-net/sonic-buildimage#20640, SONiC systems mount
/tmpas separate tmpfs mount.SONiC ZTP scripts currently prepares
config_dl.jsonfile in/tmpfolder and then tries to rename file to/etc/sonic/config_db.json. Earlier there was no issue with that, as/tmpand/etc/sonicwas residing on the same mount, on the same device. Now (sonic-buildimagemaster, and202505branch - sonic-net/sonic-buildimage@fbd9252),os.renameraises aOSError: [Errno 18] Invalid cross-device link: '/tmp/config_dl.json' -> '/etc/sonic/config_db.json'exception.Such behaviour of
os.renameis documented:I replaced
os.renamecall withshutil.move(docs) one, which should either useos.renameif such operation is possible, or fall back into "manual" course of actions: first copy the file onto new place, then remove the source file.I suspect this change will also solve #54, but I'm not entirely sure that the cause was the similar one there.