Enable Soft Delete to Recover Deleted Instances OpenStack

Ubah konfigurasi Nova di node semua Controller dan semua node Compute

vim /etc/nova/nova.conf

Cari nilai reclaim_instance_interval

reclaim_instance_interval=0
# * Any positive integer(in seconds) greater than 0 will enable
#   this option.
# * Any value <=0 will disable the option.
#  (integer value)

Ubah nilainya sesuai yang diinginkan misal ingin menahan Instance agar tidak dihapus secara permanent selama 1 hari (24 jam x 3600 = 86400 detik) berarti isikan

reclaim_instance_interval=86400

Muat ulang service nova-api di Node Controller

systemctl restart openstack-nova-api.service
systemctl status openstack-nova-api.service

Muat ulang service nova-compute di Node Compute

systemctl restart openstack-nova-compute.service 
systemctl status openstack-nova-compute.service

List Instances

[[email protected] ~(keystone_admin)]# openstack server list
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+
| ID                                   | Name        | Status | Networks         | Image                                                 | Flavor    |
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+
| 2cffc5b3-feb3-40a6-b6af-62cdde03d69c | soft-delete | ACTIVE | extnet=10.1.1.49 | cirros-0.4.0-x86_64-disk.img                          | ns.1-1-1  |
| 281a9a9b-0fe7-48d7-93e0-3dae7c9db695 | instance-01 | ACTIVE | extnet=10.1.1.2  | ubuntu-16.04-server-cloudimg-amd64-disk1-20180306.img | ns.2-2-20 |
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+

Ujicoba hapus Instance

[[email protected] ~(keystone_admin)]# openstack server delete 2cffc5b3-feb3-40a6-b6af-62cdde03d69c

[[email protected] ~(keystone_admin)]# openstack server list
+--------------------------------------+-------------+--------+-----------------+-------------------------------------------------------+-----------+
| ID                                   | Name        | Status | Networks        | Image                                                 | Flavor    |
+--------------------------------------+-------------+--------+-----------------+-------------------------------------------------------+-----------+
| 281a9a9b-0fe7-48d7-93e0-3dae7c9db695 | instance-01 | ACTIVE | extnet=10.1.1.2 | ubuntu-16.04-server-cloudimg-amd64-disk1-20180306.img | ns.2-2-20 |
+--------------------------------------+-------------+--------+-----------------+-------------------------------------------------------+-----------+

Cek List instance yang sudah di Hapus, jika kita aktifkan Soft Delete maka statusnya akan menjadi SOFT_DELETE sampai batas waktu yang sudah kita tentukan akan berubah menjadi DELETED

[[email protected] ~(keystone_admin)]# openstack server list --deleted
+--------------------------------------+------------------+--------------+------------------+-----------------------------------------+-----------+
| ID                                   | Name             | Status       | Networks         | Image                                   | Flavor    |
+--------------------------------------+------------------+--------------+------------------+-----------------------------------------+-----------+
| 2cffc5b3-feb3-40a6-b6af-62cdde03d69c | soft-delete      | SOFT_DELETED | extnet=10.1.1.49 | cirros-0.4.0-x86_64-disk.img            | ns.1-1-1  |
| 239c18af-3ffc-41aa-9a47-d07e9af4ac52 | test-centos      | DELETED      |                  | CentOS-7-x86_64-GenericCloud-1802.qcow2 | ns.2-4-20 |
| 83448c2a-66fe-4864-8296-253ed4bcb16f | cirros-test      | DELETED      |                  | cirros-0.4.0-x86_64-disk.img            | ns.1-1-1  |
+--------------------------------------+------------------+--------------+------------------+-----------------------------------------+-----------+

Ujicoba Restore Instance

[[email protected] ~(keystone_admin)]# openstack server restore 2cffc5b3-feb3-40a6-b6af-62cdde03d69c

[[email protected] ~(keystone_admin)]# openstack server list
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+
| ID                                   | Name        | Status | Networks         | Image                                                 | Flavor    |
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+
| 2cffc5b3-feb3-40a6-b6af-62cdde03d69c | soft-delete | ACTIVE | extnet=10.1.1.49 | cirros-0.4.0-x86_64-disk.img                          | ns.1-1-1  |
| 281a9a9b-0fe7-48d7-93e0-3dae7c9db695 | instance-01 | ACTIVE | extnet=10.1.1.2  | ubuntu-16.04-server-cloudimg-amd64-disk1-20180306.img | ns.2-2-20 |
+--------------------------------------+-------------+--------+------------------+-------------------------------------------------------+-----------+

Lalu bagaimana jika kita ingin segera memakai resource kita tanpa menunggu 1 hari? bisa gunakan perintah

[[email protected] ~(keystone_admin)]# nova force-delete 2cffc5b3-feb3-40a6-b6af-62cdde03d69c

[[email protected] ~(keystone_admin)]# openstack server list --deleted
+--------------------------------------+------------------+---------+----------+-----------------------------------------+-----------+
| ID                                   | Name             | Status  | Networks | Image                                   | Flavor    |
+--------------------------------------+------------------+---------+----------+-----------------------------------------+-----------+
| 2cffc5b3-feb3-40a6-b6af-62cdde03d69c | soft-delete      | DELETED |          | cirros-0.4.0-x86_64-disk.img            | ns.1-1-1  |
| 239c18af-3ffc-41aa-9a47-d07e9af4ac52 | test-centos      | DELETED |          | CentOS-7-x86_64-GenericCloud-1802.qcow2 | ns.2-4-20 |
| 83448c2a-66fe-4864-8296-253ed4bcb16f | cirros-test      | DELETED |          | cirros-0.4.0-x86_64-disk.img            | ns.1-1-1  |
+--------------------------------------+------------------+---------+----------+-----------------------------------------+-----------+

Sekian dan Terima kasih!

Comments