Provisioning a new server doesn't always go as expected. So far, Fuse hasn’t provided any feedback when an error occurs or if provisioning fails, which can cause the provisioning status to hang indefinitely. It’s time to address this issue.
First, Fuse shouldn't attempt to provision a server that has already been provisioned. When a server is successfully provisioned, it completes the task by sending a callback to Fuse, which updates the server status from "provisioning" to "provisioned." Using an accessor, Fuse checks if the server has already been provisioned. If it has, the Laravel server provisioner job is deleted.
If the server is still provisioning, its status remains "provisioning," indicating that the provisioning script has not finished. In this case, the server provisioner job is released for 30 seconds before checking the server status again.
We also need to handle servers that have been stuck in the provisioning state for too long. Fuse checks the server’s creation time, and if it is older than 15 minutes, this suggests something has gone wrong. The task is then marked as failed.
To control how long we wait before failing a provisioning job, I have set a maximum of 40 tries, which equals a total of 20 minutes for provisioning a server.
When provisioning fails, the server is automatically deleted. However, the server itself remains active, allowing you to review the server logs and debug the provisioning script. Hopefully, this situation will be rare.
First, Fuse shouldn't attempt to provision a server that has already been provisioned. When a server is successfully provisioned, it completes the task by sending a callback to Fuse, which updates the server status from "provisioning" to "provisioned." Using an accessor, Fuse checks if the server has already been provisioned. If it has, the Laravel server provisioner job is deleted.
If the server is still provisioning, its status remains "provisioning," indicating that the provisioning script has not finished. In this case, the server provisioner job is released for 30 seconds before checking the server status again.
We also need to handle servers that have been stuck in the provisioning state for too long. Fuse checks the server’s creation time, and if it is older than 15 minutes, this suggests something has gone wrong. The task is then marked as failed.
To control how long we wait before failing a provisioning job, I have set a maximum of 40 tries, which equals a total of 20 minutes for provisioning a server.
When provisioning fails, the server is automatically deleted. However, the server itself remains active, allowing you to review the server logs and debug the provisioning script. Hopefully, this situation will be rare.