-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Backups Fail on Docker Desktop for Windows #48
Comments
This looks like there might be some permissions related error at play here, where the file is created and written to, but cannot be read from. It's not throwing because the file isn't a directory, but because it can't determine if it is a directory. i.e. something's blocking reading the file's attributes. Can you share your docker-compose.yml, and |
I also first suspected access rights. Since the world data is large, I will try to make the minimum configuration that can be confirmed to be reproduced.
<docker-compose.yml>
|
I can also make changes so that the underlying error is more completely reported, and push that out to the test tag which will give us more details and help diagnose similar issues in the future. I’ll do that tomorrow. And yes, it does look like the backup is being made okay. But somehow the file then can’t be checked to confirm we got a valid backup afterwards. Strange. It’s possible that something about the size of the backup is somehow triggering a bug in Swift on Linux that will need to be worked around. |
I found successful case... <docker-compose.yml>
It may be a problem due to the permissions of Windows local folder! |
I am not understand swift.
|
Very possibly. I don't have any experience with Docker Desktop on Windows. I wonder if it uses WSL, and if it doesn't, if Docker in WSL behaves any better.
That was close to my intent yes, but it was close to midnight local time, so I wasn't going to jump into it until I had gotten some sleep. :) I've made the change, and merged it into main, so it will be available on the |
[error detail]
[console in aaa-backup-1]
|
Yeah, this clearly suggests something is weird with fetching attributes from files in this specific scenario. What’s not clear is if this is a problem in Apple’s Foundation library, WSL or Docker. Because you mentioned named containers work, I’ve been trying to research what the difference is between named volumes and bound mount points on Windows, but haven’t had much luck so far. Not being able to read the file attributes is going to be messy as it’s key to how backup trimming works, and it’s not clear at the moment how to work around this issue. So unfortunately, I can’t say there will be a quick resolution. But I do want to keep this open so I can track this issue and update the title to make it easier for other folks to see this information. |
One last thing I want to confirm, if you would. What is the location of your docker-compose.yml? Is it entirely in the Linux filesystem in WSL? Or is it hosted on a Windows drive? |
It hosted on a Windows drive.
start up command:
stop down command:
|
Yeah, I wonder if you’ve uncovered an issue when bind-mounting to the Windows filesystem which has a couple known limitations. Docker themselves recommend bind-mounting to the Linux filesystem in WSL instead: https://docs.docker.com/desktop/windows/wsl/. There might also be some differences depending on if your setup using WSL 1 or 2 as well. Do you happen to know which version of WSL is being used? Since named volumes are part of the Linux filesystem, I suspect the recommendation of bind-mounting to the Linux filesystem will also work. Could you try it? |
I'm using WSL 2.
Yes. I installed Ubuntu with Docker on WSL2. [Ubuntu shell on Linux filesystem]
But, In the following case has other trouble occurred. [PowerShell on Linux volume via windows filesystem]
[log]
Process terminated... I will switch to WSL + docker soon... (T-T) |
Hello @Kaiede, I'm not much of a programmer but I think I've made some headway resolving this. I too ran into the same problem that @nakanotti ran into. First, with respect to this code in world.swift (Line 36):
I changed it to:
This passed the initial hangup that @nakanotti mentioned. Specifically, the url.resourceValues(forKeys: [.isDirectoryKey] function in line 50 always threw an error (because the URL passed was a file, not a folder). No idea why but this always problematic.
However I encountered another problem after that. I narrowed it down to an issue with the .part file extension. I just disabled that temporary by commenting out lines 147 and 160 respectively: After that, everything seemed to begin working correctly... or at least it no longer gave me errors. I haven't determined if the .part file extension was somehow related to the first problem (maybe there needs to be a case for .part in the init?). However, this suggests that the overall problem is not likely related to a Docker Desktop WSL/WSL2, Windows, or a permissions problem. It feels more like a race condition and/or a problem with the .part file extension not being handled properly. Once again, I'm not much of a programmer (never touched Swift until now) but I'm pretty good at mashing keys and doing Google searches. This is my first time posting on GitHub. I guess I really, really wanted your backup system to work for me. LOL. I hope this can provide some guidance on where to go next. BTW, now that I have this working, wow this is awesome. I absolutely love having my Bedrock worlds backup after exiting my server. Way better than crappy batch file scripts I put together for daily backups. Thanks a ton!!! |
That's a bug in the Swift Foundation library, or WSL. It shouldn't be throwing, but instead just set the key to false like Linux and MacOS does. By moving it, it does work around the issue, but it also means that if I have a folder I've called "foo.zip" then the logic breaks in new ways as it tries to unzip a folder. Fun. But this could make it easier to look up the issue and see if there might be fixes in newer versions of Swift, or if it is fixed in the upcoming 5.7 release. Do you have the error from the part file issue? It sounds a lot like WSL doesn't like the move of the temporary file to the final location, but the error would be valuable in understanding why. |
Hi @Kaiede - I have messed with the code a bit more to resolve your file/folder concern. So far, this seems to work:
With respect to errors after this change, I get the following (after I log out of my server):
I was digging deeper into this last weekend. I seem to recall removing the .part file extension naming/renaming stuff and it resolved the problem. The good thing is, the file seems to back up fine regardless of the error. I'll try diving deeper in the next few days to pinpoint what specifically is triggering the erroneous error. Thanks! |
Oh, my attempt to determine if the file/folder is a file might not have worked. I reverted to the code in the first post (without using resourceValue), I get the following:
Slightly different results. Makes me think that .isRegularFileKey doesn't work either. At least this method pointed to the .part file extension problem I mentioned earlier. Seems clear that the ability to distinguish between a file and folder (or how it's handled in Docker) is the culprit. Maybe there's another way around this... |
Hmm, ideally, I'd love to be able to attack this with some form of unit testing, but it requires a pretty specific environment: Linux container being run on Windows, with the files being accessed from the host. So it's more a big integration test that requires setup to perform. Maybe I could setup a Dockerfile specifically to run the test suite from within a docker container, but it'd take some work. Out of curiosity, how did you setup this environment on Windows? While I don't currently have something setup, I could probably setup a Windows VM to replicate this, and then start playing around with possible solutions using a swift development docker container. So long as the POSIX APIs work correctly, it should be possible to drop down to the C APIs and call them directly to check for file vs directory. At least as long as the Zip framework doesn't have issues of its own. |
Well, my setup isn't probably the most efficient by any means. I've been running your build-docker.sh script on my mid-2015 Macbook Pro to build the image. From there I tag it and push to docker hub. Then I hop over to my Windows box where I've got a quick-and-dirty docker-compose configuration which spins up the minecraft-bedrock-backup (obviously pulling the latest version of my own hackery) and a single instance of the itzg/minecraft-bedrock-server. Lastly, I jump into the Minecraft server long enough to trigger the backup event and begin troubleshooting. I know, not great but it's working. The Windows box is where my servers will ultimately reside once this is resolved. |
Hi @Kaiede - I think I've got a decent solve for this. In World.swift (starting at line 31), the following change resolved the problem with distinguishing between a folder and file on my system:
With that resolved, I also found a work-around with the ".part" file problem. For some reason FileManager.default.moveItem doesn't play nice. Maybe the newly renamed file isn't ready to be opened right after it was renamed. Regardless, in World.swift around line 160 I did the following which solved that problem:
So with those two changes, everything appears to be working correctly on my setup. I haven't had a chance to see if there's errors during the trim process yet. I'll have to figure out a way to simulate that. For now, I'm off to look at my eyelids.
|
I guess my question was more: Are you just using Docker Desktop on Windows or something else?
Aha, this might explain the issue. Windows tends to be a bit more picky about when you can manipulate a file on disk, and will usually lock it from being renamed so long as it remains open. Something I just re-learned the last time I was playing with Windows a few days ago. Because the Archive is not closed until the object deallocates, then the file cannot be moved until that happens. Linux/BSD/Mac will let you rename the file while it is still open. So the full fix here is to ensure the Archive is deallocated before we rename. So let's see if that works before falling back to copies, as a copy will be more expensive in time and disk space, especially on Java. As for the URL fix, that does generally work so long as the URLs properly act the same way all the time. hasDirectoryPath is really only checking for the presence of a trailing slash, which in this case may be working, but could cause problems down the road. I still suspect I'll need to implement something at the POSIX layer. But thanks for digging into this so far, it has been a huge help narrowing things down while I've been distracted by real life and a separate (large) side project. |
Yes, just running docker desktop for windows. |
Initially, I used the same approach as Mr. @farmertip. ex) start up script file from Windows: \\wsl$\Ubuntu\opt\docker\bedrock\up.ps1
We can also add the following message to the error message, as another approach... By the way, I hope that the image size will be smaller.. (^_^; |
I've made changes to ensure the Archive is closed before @farmertip This hopefully should fix half of the problem, leaving just the
According to Docker Hub, it looks like a good chunk of the image is actually from installing docker.io bits into the container so I can access the Minecraft container. I could probably remove the docker.io dependency and shave off around 100-120MB if I make folks map in the docker binary and socket file (which then throws Windows compatibility clear out the window, possibly). That would be a breaking change though.
I'll call that plan B for now. Since I think with farmertip's help identifying the core areas where things go wrong, they can be fixed and Windows Docker supported. |
Describe the bug or issue being faced
I had an error occured every backup time.
ex)
Why throw exception always here?
<Sources/Bedrockifier/Model/World.swift>
The url is '/backups/world.20220425-141732.mcworld'.
These backup files will seem to successful...
But, throw exception "not a directory" to failure process.
Configuration and Verbose Logs
config.yml:
Additional context
Log:
Thank you for your help.
The text was updated successfully, but these errors were encountered: