From 007c1d4a4b56bebfe3b872f188df9f67a8ef5292 Mon Sep 17 00:00:00 2001 From: Olaf Klischat Date: Wed, 4 Dec 2024 05:45:46 +0100 Subject: [PATCH] K8s-11784 fix node deployment min/max replicas handling --- go.mod | 2 +- go.sum | 4 ++-- metakube/resource_node_deployment_structure.go | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 776324a..51d02c4 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/syseleven/go-metakube v0.0.0-20241203225354-74465a218b83 + github.com/syseleven/go-metakube v0.0.0-20241209175334-b03f742212c2 go.uber.org/zap v1.19.0 golang.org/x/mod v0.14.0 k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 diff --git a/go.sum b/go.sum index 67b1b9c..1d4e140 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/syseleven/go-metakube v0.0.0-20241203225354-74465a218b83 h1:bp3I3hfrknpnJlZKVbG9APJfemhCFt7nBcMx1oAOoVE= -github.com/syseleven/go-metakube v0.0.0-20241203225354-74465a218b83/go.mod h1:KJB8m9a51Dcci9ee2pLwKetFm9MUrOAjDPAm5ZnOnHI= +github.com/syseleven/go-metakube v0.0.0-20241209175334-b03f742212c2 h1:KfPt3bgBgMa9/9VzuwVoIjmLRkg9mjGBaeRL88VPPb4= +github.com/syseleven/go-metakube v0.0.0-20241209175334-b03f742212c2/go.mod h1:KJB8m9a51Dcci9ee2pLwKetFm9MUrOAjDPAm5ZnOnHI= github.com/syseleven/terraform-plugin-sdk/v2 v2.31.0-sys11-2 h1:vywVVW9AnKcEiqgbZe16wwuaQaZ8VtMe+xmNBdvdMnU= github.com/syseleven/terraform-plugin-sdk/v2 v2.31.0-sys11-2/go.mod h1:i2C41tszDjiWfziPQDL5R/f3Zp0gahXe5No/MIO9rCE= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= diff --git a/metakube/resource_node_deployment_structure.go b/metakube/resource_node_deployment_structure.go index 043f186..aee5887 100644 --- a/metakube/resource_node_deployment_structure.go +++ b/metakube/resource_node_deployment_structure.go @@ -17,12 +17,12 @@ func metakubeNodeDeploymentFlattenSpec(in *models.NodeDeploymentSpec) []interfac att["replicas"] = *in.Replicas } - if in.MinReplicas >= 0 && in.MaxReplicas > 0 { - att["min_replicas"] = in.MinReplicas + if in.MinReplicas != nil { + att["min_replicas"] = *in.MinReplicas } - if in.MaxReplicas > 0 { - att["max_replicas"] = in.MaxReplicas + if in.MaxReplicas != nil { + att["max_replicas"] = *in.MaxReplicas } if in.Template != nil { @@ -304,20 +304,20 @@ func metakubeNodeDeploymentExpandSpec(p []interface{}, isCreate bool) *models.No if v, ok := in["min_replicas"]; ok { if vv, ok := v.(int); ok { - obj.MinReplicas = int32(vv) + obj.MinReplicas = ptr.To(int32(vv)) if isCreate { - obj.Replicas = int32ToPtr(obj.MinReplicas) + obj.Replicas = int32ToPtr(*obj.MinReplicas) } } } if v, ok := in["max_replicas"]; ok { if vv, ok := v.(int); ok { - obj.MaxReplicas = int32(vv) + obj.MaxReplicas = ptr.To(int32(vv)) } } - if v, ok := in["replicas"]; ok && obj.MinReplicas == 0 { + if v, ok := in["replicas"]; ok && *obj.MinReplicas == 0 { if vv, ok := v.(int); ok { obj.Replicas = int32ToPtr(int32(vv)) }