Skip to content
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

K8s-11784 fix node deployment min/max replicas handling #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
16 changes: 8 additions & 8 deletions metakube/resource_node_deployment_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
Expand Down
Loading