UpCloudLtd / upcloud-cli

UpCloud command line client (upctl)
https://upcloudltd.github.io/upcloud-cli/
MIT License
29 stars 7 forks source link

Server delete `--delete-storages` not fully working #148

Closed Davincible closed 2 years ago

Davincible commented 2 years ago

I've been deleting servers with --delete-storages, but somehow ended up with a massive list of storages. Only noticed after I got a storage limit reached message.

I could be related to the creation of extra storages on server creation, but I'm not sure, I haven't tested that thoroughly.

--storage action=create,address=virtio,title=$DISK_TITLE,size=$DISK_SIZE,tier=maxiops,type=disk"

kangasta commented 2 years ago

Hi! I tried to reproduce this, but at least following script seems to delete all created storages:

#!/bin/bash -xe
prefix=server-storage-delete-test-
N=2
servers=""

for i in $(seq 1 ${N}); do
    name=${prefix}server-${i}
    servers="${servers} ${name}"
    upctl server create \
        --zone pl-waw1 \
        --hostname ${name} \
        --ssh-keys ~/.ssh/*.pub \
        --storage action=create,address=virtio,title=${name}-disk-1,size=10,tier=maxiops,type=disk \
        --storage action=create,address=virtio,title=${name}-disk-2,size=10,tier=maxiops,type=disk \
        --wait
done

# Check that storages are created
upctl storage list

# Let server be in started state for a moment before stopping it
sleep 15

upctl server stop ${servers} --wait
upctl server delete --delete-storages ${servers}

# Check that storages are deleted
upctl storage list

Were any of the servers storages deleted?

Davincible commented 2 years ago

Hmm. Could you try with a custom template, and see if that works?

Another thing that I noticed, is that the OS storage tends to be in the "syncing" state for quite a long time. If in my experiments I delete the server before that perhaps it fails to delete it without any error.

Davincible commented 2 years ago

I think it has to do with the latter. If storages are not finished syncing before the delete call they never get deleted.

Now it seems like my storages sync quite fast, and it's not an issue. But yesterday I created/deleted a bunch of servers and syncing took forever

kangasta commented 2 years ago

That could be a possible reason.

When I tried to reproduce this the syncing was done in some seconds, with both private and public templates, and thus the storages were always in online state when the script deleted them.