Kaiede / Bedrockifier

Command-line tools and Service for Minecraft Servers (Bedrock & Java)
MIT License
42 stars 6 forks source link

Encountering an issue when trying to implement the `bedrock-itzg-ssh` example as a backup solution, where rebooting of the system bypasses Docker Compose's `depends_on` conditional validation #95

Open BB-301 opened 3 months ago

BB-301 commented 3 months ago

As described in the title, I'm encountering an issue when trying to implement a backup solution based on the bedrock-itzg-ssh example, where rebooting of the system bypasses Docker Compose's depends_on condition checks, which apparently causes the backup container to enter an unrecoverable state after it "fails to connect SSH channel to host" (see the logs for the backup container at the bottom of this post).

My understanding is that the problem is inherent to Docker Compose itself, and not this project. However, I thought I'd write about it here anyways, since Docker Compose appears to be the recommended way of using this tool. Moreover, I was wondering how others facing this same issue had managed to resolve it.

[09:54:19.087][info    ] Initializing Bedrockifier Daemon
[09:54:19.245][info    ] Configuring Bedrockifier Daemon
[09:54:19.261][info    ] Loading Configuration From: /config/config.yml
[09:54:19.296][info    ] Configuration Loaded, Running Service...
[09:54:19.308][info    ] Starting Container Connection. newline = ssh
[09:54:19.309][info    ] Host PTY Handle Opened: /dev/pts/0  (bedrock_public - 6)
[09:54:19.309][info    ] Child PTY Handle Opened: /dev/pts/0 (bedrock_public - 7)
[09:54:19.327][info    ] Connecting to public:2222
[09:54:19.347][error   ] Failed to connect SSH channel to host. (The operation could not be completed. (NIOPosix.NIOConnectionError error 1.))
[09:54:19.347][error   ] Check that the SSH configuration is correct, and check the minecraft server logs for further errors.
[09:54:19.347][info    ] Checking for servers that might not be cleaned up
[09:54:19.349][info    ] Backup Interval: 10800.0 seconds
[09:54:19.349][info    ] Starting Listeners for Containers
[09:54:19.349][info    ] Backup Minimum Interval is 600.0 seconds
[09:54:19.349][info    ] Service Started Successfully.
[09:54:19.349][info    ] Starting Full Backup
[09:54:19.350][error   ] Docker process didn't start successfully, or has died
[09:54:19.350][error   ] Container bedrock_public failed to backup properly
[09:54:19.350][info    ] Performing Trim Jobs
[09:54:19.398][info    ] Full Backup Completed
Emanon01001 commented 2 months ago

I also experience similar issues. The first backup after deleting the folder on the server succeeds, but from the second time onwards, the backup fails.

`2024-07-26 00:53:12 [00:53:12.389][info ] Initializing Bedrockifier Daemon 2024-07-26 00:53:12 [00:53:12.399][info ] Configuring Bedrockifier Daemon 2024-07-26 00:53:12 [00:53:12.401][info ] Loading Configuration From: /config/config.yml 2024-07-26 00:53:12 [00:53:12.407][info ] Configuration Loaded, Running Service... (main.swift:105) 2024-07-26 00:53:12 [00:53:12.414][debug ] Creating Bedrock Container Connection. (container: mc_server) (ContainerConnection.swift:313) 2024-07-26 00:53:12 [00:53:12.416][info ] Starting Container Connection. newline = ssh (ContainerConnection.swift:113) 2024-07-26 00:53:12 [00:53:12.416][info ] Host PTY Handle Opened: /dev/pts/0 (mc_server - 6) (Terminal.swift:164) 2024-07-26 00:53:12 [00:53:12.416][info ] Child PTY Handle Opened: /dev/pts/0 (mc_server - 7) (Terminal.swift:185) 2024-07-26 00:53:12 [00:53:12.417][debug ] Starting Terminal Process. (container: mc_server, kind: ssh) (ContainerConnection.swift:128) 2024-07-26 00:53:12 [00:53:12.418][info ] Connecting to mc_server:2222 (SSHClient.swift:49) 2024-07-26 00:53:12 [00:53:12.420][error ] Failed to connect SSH channel to host. (The operation could not be completed. (NIOPosix.NIOConnectionError error 1.)) (ContainerChannel.swift:90) 2024-07-26 00:53:12 [00:53:12.420][error ] Check that the SSH configuration is correct, and check the minecraft server logs for further errors. (ContainerChannel.swift:91) 2024-07-26 00:53:12 [00:53:12.420][debug ] Docker Process Window Size Fetched. (cols = 65000, rows = 24 (ContainerConnection.swift:300) 2024-07-26 00:53:12 [00:53:12.420][info ] Checking for servers that might not be cleaned up (BackupActor.swift:91) 2024-07-26 00:53:12 [00:53:12.422][info ] mc_server is dirty, cleaning up (BackupActor.swift:94) 2024-07-26 00:53:12 [00:53:12.422][info ] Backup Interval: 60.0 seconds (Service.swift:156) 2024-07-26 00:53:12 [00:53:12.422][debug ] Starting Terminal Process. (container: mc_server, kind: ssh) (ContainerConnection.swift:128) 2024-07-26 00:53:12 [00:53:12.422][debug ] [interval] Registered (ServiceTimer.swift:102) 2024-07-26 00:53:12 [00:53:12.422][info ] Connecting to mc_server:2222 (SSHClient.swift:49) 2024-07-26 00:53:12 [00:53:12.423][debug ] [interval] Event Fired. Valid Handler: false (ServiceTimer.swift:110) 2024-07-26 00:53:12 [00:53:12.423][debug ] [interval] Scheduled For Jul 26, 2024, 12:53:12 AM, Repeating 60.0 s (ServiceTimer.swift:81) 2024-07-26 00:53:12 [00:53:12.423][info ] Starting Listeners for Containers (Service.swift:199) 2024-07-26 00:53:12 [00:53:12.423][info ] Service Started Successfully. (Service.swift:108) 2024-07-26 00:53:12 [00:53:12.423][error ] Failed to connect SSH channel to host. (The operation could not be completed. (NIOPosix.NIOConnectionError error 1.)) (ContainerChannel.swift:90) 2024-07-26 00:53:12 [00:53:12.424][error ] Check that the SSH configuration is correct, and check the minecraft server logs for further errors. (ContainerChannel.swift:91) 2024-07-26 00:53:12 [00:53:12.424][debug ] Docker Process Window Size Fetched. (cols = 65000, rows = 24 (ContainerConnection.swift:300) 2024-07-26 00:53:12 [00:53:12.424][info ] Cleaning up old backups for mc_server (BackupActor.swift:101) 2024-07-26 00:53:12 [00:53:12.424][error ] Docker process didn't start successfully, or has died (BackupActor.swift:108) 2024-07-26 00:53:12 [00:53:12.425][error ] Failed to clean up container mc_server (BackupActor.swift:109) 2024-07-26 00:54:12 [00:54:12.423][debug ] [interval] Event Fired. Valid Handler: true (ServiceTimer.swift:110) 2024-07-26 00:54:12 [00:54:12.423][info ] Starting Full Backup (BackupActor.swift:174) 2024-07-26 00:54:12 [00:54:12.423][error ] Docker process didn't start successfully, or has died (BackupActor.swift:195) 2024-07-26 00:54:12 [00:54:12.424][error ] Container mc_server failed to backup properly (BackupActor.swift:196) 2024-07-26 00:54:12 [00:54:12.424][info ] Performing Trim Jobs (BackupActor.swift:241) 2024-07-26 00:54:12 [00:54:12.463][debug ] Processing: Ookurar1ku World (Backup.swift:99) 2024-07-26 00:54:12 [00:54:12.469][info ] Full Backup Completed (BackupActor.swift:214)

Kaiede commented 2 months ago

I did mean to update the Wiki after #92 to help catch this sort of problem earlier. But there's a couple approaches that should work here:

  1. Require that the server is healthy to run the backup service. This can introduce issues on multi-server setups (one unhealthy server prevents backups), which is why it isn’t default. You can change your depends_on in the compose file like so:
depends_on:
      minecraft:
        condition: service_healthy
  1. Add a startup delay to the backup service to give the minecraft server(s) time to start up:
schedule:
  startupDelay: 1m
BB-301 commented 2 months ago

@Kaiede,

Thanks for the suggestions! I was already doing (1), which was useful to let the Minecraft server container completely start before the backup container tries to connect, but (2) looks like a nice workaround for when the system boots. I will give it a try when I get a chance.