k8up-io / wrestic

Restic Backup Kubernetes and OpenShift Wrapper - Part of K8up
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

[Bug] wrestic fails to initialize a repository #70

Closed ccremer closed 3 years ago

ccremer commented 3 years ago

Describe the bug

Running wrestic v0.2.1 ends up in a container crashloop

Additional context

I think the current implementation fails for any command, it may not be limited to repository inializing only. It looks something fundamentally is bugged with command handling.

Logs

If applicable, add logs to help explain your problem.

I0304 16:39:04.419767       1 main.go:43] wrestic "level"=0 "msg"="Wrestic Version: unreleased"  
I0304 16:39:04.420154       1 main.go:44] wrestic "level"=0 "msg"="Operator Build Date: now"  
I0304 16:39:04.420167       1 main.go:45] wrestic "level"=0 "msg"="Go Version: go1.15.8"  
I0304 16:39:04.420174       1 main.go:46] wrestic "level"=0 "msg"="Go OS/Arch: linux/amd64"  
I0304 16:39:04.420181       1 main.go:194] wrestic "level"=0 "msg"="setting up a signal handler"  
E0304 16:39:04.420533       1 main.go:82] wrestic "msg"="failed to inialise the repository" "error"="cmd.Wait() err: exec: not started"  

Expected behavior

Wrestic should be able to initialize the repository.

To Reproduce

Steps to reproduce the behavior:

  1. git checkout https://github.com/vshn/k8up
  2. run export WRESTIC_IMAGE=quay.io/vshn/wrestic:v0.2.1
  3. run make e2e-test
  4. See logs with kubectl -n k8up-e2e-subject logs -l job-name=k8up-k8up-backup

Environment (please complete the following information):

ccremer commented 3 years ago

btw, it says also Version: unreleased and Build Date: now ;)

Kidswiss commented 3 years ago

This seems to happen if wrestic is run in a container. Wrestic's own integration test works without issues. Although wrestic's test checks a slightly different case, but the command handling seems to be working there.

Maybe there's some race condition if started in a container. Because cmd.Start() is definitely called before cmd.Wait() https://github.com/vshn/wrestic/blob/master/restic/command.go#L43. The docs only stated that Wait() should only be called after Start() but it doesn't state if the actual process already needs to be running. I assume the process hasn't started yet so cmd.Wait() fails.

Kidswiss commented 3 years ago

chmod +x /usr/local/bin/restic 🤦

But I wonder why cmd.Start() doesn't return an error that the binary can't be started...

I'll open a PR later to address this. Also including an additional check to catch this.