-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to not delete stopped agents #27
Comments
@matti-cujo, originally this piece of code was intended to remove preempted instances, so to resolve your use case we need to check whether cloud image has enabled "preemptible instances" and remove terminated instances only if it's true. |
Apparently that's not the only place that causes terminated instances to be deleted, there's also this: Lines 140 to 146 in ac170a0
Where the Lines 24 to 38 in ac170a0
And it turns out that the Lines 79 to 81 in ac170a0
Meaning that |
It turns out that
Which suggests that the |
I tried updating the Google SDK to 0.79.0-alpha and the issue persisted, and I also complained over at googleapis/google-cloud-java#3735, which describes a very similar problem though with a different API. For the record, updating the SDK also required the following patch before it worked (or seemed to work) correctly: diff --git google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/connector/GoogleApiConnectorImpl.kt google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/connector/GoogleApiConnectorImpl.kt
index 5235e58..20e5537 100644
--- a/google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/connector/GoogleApiConnectorImpl.kt
+++ b/google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/connector/GoogleApiConnectorImpl.kt
@@ -461,7 +461,7 @@ class GoogleApiConnectorImpl : GoogleApiConnector {
}
private fun <T : ClientSettings<T>> getResourceId(value: String, settings: T): String {
- return "projects/${value.removePrefix(settings.endpoint)}"
+ return value.removePrefix(settings.endpoint)
}
companion object { |
@matti-cujo, it seems that the problem with resource identifiers was caused by resolution of googleapis/google-cloud-java#3604 where has changed the way to parse resource identifiers withing Google Compute SDK library. Will try upgrading the plugin to latest version and resolve found problems. |
@matti-cujo, regarding this feature request - the same option is currently available in TeamCity Azure cloud agents plugins, it's called "Reuse allocated virtual machines": https://github.com/JetBrains/teamcity-azure-agent/wiki/Managed-Image It removes stopped instances only when source image has changed and instead of removal just stops them. |
Along the lines of caching, being able to reuse stopped instances would also really help for things like Maven or Ivy / SBT cache. When booting from a clean image, these dependencies take quite a while to download. I can snapshot an image from a pre-warmed cache, but that doesn't work too well because dependencies will change over time or we start building different projects, and it's a pain to keep creating new images just to refresh the cache. |
@dtretyakov any chance the new new api library resolves this? |
For the caching the libraries, that's a good idea, but it could an anti-pattern in this scenario. For testing, you really want a clean environment, as results may be invalid. This goes back to the controlled experiment concept. Maybe docker is a good solution, with layered images, and an image built with best packages, such as copying the manifest (pom.xml) on a separate layer, so that package downloads only happen when the manifest changes. |
Setting the idle time after which instances are stopped seems to result in them getting not only stopped, but also deleted. This is unfortunate when you'd like to cache things on the instance's disk, such as large git repositories or intermediate build artifacts.
It would be great to have an option to avoid this deletion, and keep the instances alive but stopped.
Would removing the following code be a safe way of achieving this, preventing the plugin from ever terminating instances? Or is it unable to e.g. restart the stopped instances?
teamcity-google-agent/google-cloud-server/src/main/kotlin/jetbrains/buildServer/clouds/google/connector/GoogleApiConnectorImpl.kt
Lines 380 to 389 in ac170a0
The text was updated successfully, but these errors were encountered: