fix(gce): remove the ONLY_DOWN deprecated AutoscalingMode
* feat(gce): remove the deprecated ONLY_UP autoscaling mode
ONLY_SCALE_OUT is the replacement. We'll transform any ONLY_UP we see into ONLY_SCALE_OUT as soon as we find it so that we can pretend ONLY_UP doesn't even exist.
* fix(gce): remove the ONLY_DOWN deprecated AutoscalingMode
MODIFY
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/model/GoogleAutoscalingPolicy.groovy
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/model/GoogleAutoscalingPolicy.groovy
@@ -78,10 +78,6 @@ class GoogleAutoscalingPolicy {
static enum AutoscalingMode {
ON,
OFF,
- ONLY_UP,
- // ONLY_DOWN is being removed as an option from GCE. We can remove this option once we have
- // confirmation that all the autoscaler policies have been migrated away from it (by the GCE
- // team).
- ONLY_DOWN
+ ONLY_SCALE_OUT
}
}

MODIFY
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/AbstractGoogleServerGroupCachingAgent.java
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/AbstractGoogleServerGroupCachingAgent.java
@@ -930,7 +930,7 @@ abstract class AbstractGoogleServerGroupCachingAgent
output.setLoadBalancingUtilization(loadBalancing);
output.setMaxNumReplicas(input.getMaxNumReplicas());
output.setMinNumReplicas(input.getMinNumReplicas());
- output.setMode(valueOf(AutoscalingMode.class, input.getMode()));
+ output.setMode(convertAutoscalingMode(input.getMode()));
output.setScaleInControl(convertScaleInControl(input.getScaleInControl()));
return output;
}
@@ -979,6 +979,16 @@ abstract class AbstractGoogleServerGroupCachingAgent
return output;
}
+ // ONLY_UP is deprecated, but may still be around in existing autoscaling policies
+ // (as of Q4 2020), so we'll just transform it into the replacement ASAP.
+ private static AutoscalingMode convertAutoscalingMode(@Nullable String input) {
+ if (Objects.equals(input, "ONLY_UP")) {
+ return AutoscalingMode.ONLY_SCALE_OUT;
+ } else {
+ return valueOf(AutoscalingMode.class, input);
+ }
+ }
+
private static ScaleInControl convertScaleInControl(
@Nullable AutoscalingPolicyScaleInControl input) {
if (input == null) {

MODIFY
clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/AbstractGoogleServerGroupCachingAgentTest.java
clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/AbstractGoogleServerGroupCachingAgentTest.java
@@ -67,6 +67,7 @@ import com.netflix.spinnaker.clouddriver.google.cache.Keys;
import com.netflix.spinnaker.clouddriver.google.compute.GoogleComputeApiFactory;
import com.netflix.spinnaker.clouddriver.google.deploy.GoogleOperationPoller;
import com.netflix.spinnaker.clouddriver.google.model.GoogleAutoscalingPolicy;
+import com.netflix.spinnaker.clouddriver.google.model.GoogleAutoscalingPolicy.AutoscalingMode;
import com.netflix.spinnaker.clouddriver.google.model.GoogleAutoscalingPolicy.CustomMetricUtilization;
import com.netflix.spinnaker.clouddriver.google.model.GoogleInstance;
import com.netflix.spinnaker.clouddriver.google.model.GoogleServerGroup;
@@ -795,6 +796,32 @@ class AbstractGoogleServerGroupCachingAgentTest {
}
}
+ @Test
+ void serverGroupAutoscalingPolicy_onlyUpIsTransformedToOnlyScaleOut() {
+
+ AutoscalingPolicy input = new AutoscalingPolicy().setMode("ONLY_UP");
+
+ InstanceGroupManager instanceGroupManager =
+ new InstanceGroupManager().setName("myServerGroup").setZone(ZONE_URL);
+ Autoscaler autoscaler =
+ new Autoscaler().setZone(ZONE_URL).setTarget("myServerGroup").setAutoscalingPolicy(input);
+
+ Compute compute =
+ new StubComputeFactory()
+ .setInstanceGroupManagers(instanceGroupManager)
+ .setAutoscalers(autoscaler)
+ .create();
+ AbstractGoogleServerGroupCachingAgent cachingAgent =
+ createCachingAgent(
+ compute, ImmutableList.of(instanceGroupManager), ImmutableList.of(autoscaler));
+
+ CacheResult cacheResult = cachingAgent.loadData(inMemoryProviderCache());
+ GoogleServerGroup serverGroup = getOnlyServerGroup(cacheResult);
+ GoogleAutoscalingPolicy converted = serverGroup.getAutoscalingPolicy();
+
+ assertThat(converted.getMode()).isEqualTo(AutoscalingMode.ONLY_SCALE_OUT);
+ }
+
@Test
void serverGroupAutoscalingPolicy_noFields() {

fix(gce): remove the ONLY_DOWN deprecated AutoscalingMode (#4985)

* feat(gce): remove the deprecated ONLY_UP autoscaling mode

ONLY_SCALE_OUT is the replacement. We'll transform any ONLY_UP we see into ONLY_SCALE_OUT as soon as we find it so that we can pretend ONLY_UP doesn't even exist.

* fix(gce): remove the ONLY_DOWN deprecated AutoscalingMode

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>