Skip to content

Commit

Permalink
Merge pull request #251 from perfectsense/feature/allow-node-pool-siz…
Browse files Browse the repository at this point in the history
…e-change

Allow modifying the node size of a node pool
  • Loading branch information
deepanjan90 authored Jun 6, 2023
2 parents 1bae682 + 5692561 commit 7c050b0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/gyro/google/gke/GkeNodePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.container.v1beta1.GetNodePoolRequest;
import com.google.container.v1beta1.NodePool;
import com.google.container.v1beta1.SetNodePoolAutoscalingRequest;
import com.google.container.v1beta1.SetNodePoolSizeRequest;
import com.google.container.v1beta1.UpdateNodePoolRequest;
import gyro.core.GyroUI;
import gyro.core.Wait;
Expand Down Expand Up @@ -112,6 +113,7 @@ public void setConfig(GkeNodeConfig config) {
* The initial node count for the pool.
*/
@Required
@Updatable
public Integer getInitialNodeCount() {
return initialNodeCount;
}
Expand Down Expand Up @@ -329,6 +331,21 @@ protected void doUpdate(GyroUI ui, State state, Resource current, Set<String> ch

UpdateNodePoolRequest.Builder builder = UpdateNodePoolRequest.newBuilder();

if (changedFieldNames.contains("initial-node-count")) {
client.setNodePoolSize(SetNodePoolSizeRequest.newBuilder()
.setName(getNodePoolId())
.setNodeCount(getInitialNodeCount())
.build());

Wait.atMost(30, TimeUnit.MINUTES)
.checkEvery(5, TimeUnit.MINUTES)
.until(() -> {
NodePool nodePool = getNodePool(client);
return nodePool.getStatus().equals(NodePool.Status.RUNNING)
&& nodePool.getInitialNodeCount() == getInitialNodeCount();
});
}

if (changedFieldNames.contains("config")) {
if (getConfig().getWorkloadMetadataConfig() != null) {
builder.setWorkloadMetadataConfig(getConfig().getWorkloadMetadataConfig()
Expand Down

0 comments on commit 7c050b0

Please sign in to comment.