If "bosh deploy" fails/canceled before spec.json is created, next deploy will create a new vm
This problem should only happen in Softlayer as we do os-reload. We use
debug:
keep_unreachable_vms: true
to keep the failed/canceled vm in bosh db.
Our Softlayer CPI create_vm action uses the IP value included in the network_settings parameter to determine if we need to do os-reload or create a new vm. If the provided IP exists in Softlayer, we will do os-reload. If the IP doesn't exist or is empty, we will create a new vm.
If bosh deploy fails/canceled before the current vm's spec.json created, bosh director can't get the vm's network information (including IP) from get_state method. So in the next bosh deploy, when bosh director passes the parameters to CPI to do create_vm, no IP value is included in network_settings. This will cause new vm creation which is not expected.
Any ideas on how to fix this issue? Thanks.
/cc @maximilien @jianqiu @mattcui
So if understand this correctly. When this condition happens:
"If bosh deploy fails/canceled before the current vm's spec.json created, bosh director"
the normal behavior would be the director cleaning up the VM. However, due to adding:
debug:
keep_unreachable_vms: true
the director keeps VM around. And next usage of that fails since VM is not reachable.
Correct?
Also, why is this issue happening now? Can you elaborate a bit. Thx
As we are doing os-reload on Softlayer, we need bosh to continue the deploy on the existing vm after it fails/canceled last time instead of create a new vm to replace the failed/canceled one.
If keep_unreachable_vms: true is not set, bosh will delete the failed/canceled vm from bosh db, and next deploy will definitely create a new one to replace it. If we set keep_unreachable_vms: true, the failed/canceled vm record will be kept in bosh db. Next time bosh deploy will depend on the behaviour of CPI create_vm action to either do os-reload or create a new one. But our CPI create_vm action replies on the IP value that bosh director passed to it (valid IP will do os-reload and invalid/empty IP will create a new vm).
The director get the vm IP value through get_state method (retrieve the vm's spec.json to get the network information including IP). If at the point of deploy failed/canceled, the vm's spec.json has not been created yet (for example, failed/canceled at os-reload), director can't get the vm IP value through get_state method, then no IP passed to CPI create_vm action, CPI will create a new vm which is not expected. But although director can't get vm IP value through get_state method, the the vm's spec.json information is actually kept in bosh db. Can director just send the IP value in bosh db to CPI in this situation?
The issue always happens from bosh v1, but we hacked bosh code to workaround the problem.
@gu-bin There is no way for the Director to know the IP address of the machine since agent is not reachable hence we cant ask about the IP. Though if you were using manual networking Director would know the IP before even creating a machine.
@cppforlife Actually the bosh agent is reachable as it shows "running" in bosh vms but no IP. And bosh ssh can login to the vm. Although no spec.json in the vm, user_data.json exists which contains the IP and the content of spec.json is kept in bosh db. When no spec.json, can director try other ways to fetch the IP?
root@gubin-preyf-boshcli:~# bosh vms
RSA 1024 bit CA certificates are loaded due to old openssl compatibility
Acting as user 'admin' on 'bosh'
Deployment 'gubin-preyf2'
Director task 115
Task 115 done
+--------------------------------------------------------------------+---------+-----+----------------+-----------------+
| VM | State | AZ | VM Type | IPs |
+--------------------------------------------------------------------+---------+-----+----------------+-----------------+
...
+--------------------------------------------------------------------+---------+-----+----------------+-----------------+
VMs total: 38
@gu-bin I redacted comment to remove VM info.
We've rewritten some of the code in this part of Director so this behavior may no longer be an issue. If it is, feel free to reopen