nuvo / cain

Backup and restore tool for Cassandra on Kubernetes
Apache License 2.0
32 stars 21 forks source link

Cassandra data dir test fails when directory exists #10

Open alexbarta opened 5 years ago

alexbarta commented 5 years ago

Hi Maor,

I'm running into this error. Cain fails saying that data directory does not exists, when actually it exists.

kubectl run cassandra-restore  --rm --labels='app=cassandra' --serviceaccount='cassandra-backup' -i --tty --restart=Never --image-pull-policy=IfNotPresent --image nuvo/cain:0.5.1 --env 'AWS_ACCESS_KEY_ID=admin' --env 'AWS_SECRET_ACCESS_KEY=******' --env 'AWS_S3_NO_SSL=true' --env 'AWS_S3_FORCE_PATH_STYLE=true' --env 'AWS_S3_ENDPOINT=http://minio-svc.default.svc.cluster.local:9000' --command -- sh
If you don't see a command prompt, try pressing enter.
~ $ export CAIN_CASSANDRA_DATA_DIR="/var/lib/cassandra/data"
~ $ cain restore --src 's3://db-backup/cassandra/default/tb-cluster' -n default -k tb -l 'app=cassandra' -t 20190112212203 --schema e9bce4
2019/01/12 22:06:46 Restore started!
2019/01/12 22:06:46 Getting clients
2019/01/12 22:06:46 Getting pods
2019/01/12 22:06:46 Testing existence of data dir
2019/01/12 22:06:46 /var/lib/cassandra/data does not exist. error in Stream: container cassandra is not valid for pod cassandra-restore

my cassandra-0 pod path

$ kubectl exec -it cassandra-0 -- ls /var/lib/cassandra
commitlog  data  hints  saved_caches

when running older versions I'm not getting the cassandra data dir error..

Regards

maorfr commented 5 years ago

Hey Alex,

It seems that the restore process tried to restore in to itself. Try doing the same, but run the restore pod with different labels from the cassandra pod. For example:

kubectl run cassandra-restore  --rm --labels='app=cassandra-cain' --serviceaccount='cassandra-backup' -i --tty --restart=Never --image-pull-policy=IfNotPresent --image nuvo/cain:0.5.1 --env 'AWS_ACCESS_KEY_ID=admin' --env 'AWS_SECRET_ACCESS_KEY=******' --env 'AWS_S3_NO_SSL=true' --env 'AWS_S3_FORCE_PATH_STYLE=true' --env 'AWS_S3_ENDPOINT=http://minio-svc.default.svc.cluster.local:9000' --command -- sh
alexbarta commented 5 years ago

Yes, I'm an idiot :( Thanks Maor

maorfr commented 5 years ago

Not at all! In fact, this can and should be more visible to the user.

For example, if cain printed out the list of pods that it found, you would have seen this right away!

Would you like to submit a PR to implement this behavior? ;)

cc @HagaiBarel, do you approve?

alexbarta commented 5 years ago

Sure why not! At moment I'm struggling with backup/restore of more complex schemas.. I have found other cryptic error messages.. I will raise separate issues for those