Use shutil.move instead of os.rename to move config_db.json on place#66
Merged
saiarcot895 merged 2 commits intosonic-net:masterfrom Apr 14, 2026
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 66 in repo sonic-net/sonic-ztp |
Contributor
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 |
|
close pr and reopen pr to trigger pr test. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
saiarcot895
approved these changes
Apr 14, 2026
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Could this be double committed to 202511 branch? |
|
Cherry-pick PR to 202511: #76 |
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.