override fun terminateInstance()

in google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/GoogleCloudImage.kt [134:154]


    override fun terminateInstance(instance: GoogleCloudInstance) {
        instance.status = InstanceStatus.SCHEDULED_TO_STOP

        launch {
            try {
                if (myImageDetails.behaviour.isDeleteAfterStop) {
                    LOG.info("Removing virtual machine ${instance.name} due to cloud image settings")
                    myApiConnector.deleteVm(instance)
                } else {
                    LOG.info("Stopping virtual machine ${instance.name}")
                    myApiConnector.stopVm(instance)
                }
                instance.status = InstanceStatus.STOPPED
                LOG.info("Virtual machine ${instance.name} has been successfully terminated")
            } catch (e: Throwable) {
                LOG.warnAndDebugDetails(e.message, e)
                instance.status = InstanceStatus.ERROR
                instance.updateErrors(TypedCloudErrorInfo.fromException(e))
            }
        }
    }