Skip to content

Commit 8254da5

Browse files
mathieu prigentSkYNewZ
authored andcommitted
fix(nodepool): Bad update due to terraform-sdk bug
1 parent 5c8ef0c commit 8254da5

File tree

2 files changed

+208
-150
lines changed

2 files changed

+208
-150
lines changed

ovh/resource_cloud_project_kube_nodepool_test.go

Lines changed: 95 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -75,100 +75,113 @@ func testSweepCloudProjectKubeNodePool(region string) error {
7575

7676
var testAccCloudProjectKubeNodePoolConfig = `
7777
resource "ovh_cloud_project_kube" "cluster" {
78-
service_name = "%s"
79-
name = "%s"
80-
region = "%s"
81-
version = "%s"
78+
service_name = "%s"
79+
name = "%s"
80+
region = "%s"
81+
version = "%s"
8282
}
8383
8484
resource "ovh_cloud_project_kube_nodepool" "pool" {
85-
service_name = ovh_cloud_project_kube.cluster.service_name
86-
kube_id = ovh_cloud_project_kube.cluster.id
87-
name = ovh_cloud_project_kube.cluster.name
88-
flavor_name = "b2-7"
89-
desired_nodes = 1
90-
min_nodes = 0
91-
max_nodes = 1
92-
template {
93-
metadata {
94-
annotations = {
95-
a1 = "av1"
96-
}
97-
finalizers = ["finalizer.extensions/v1beta1"]
98-
labels = {
99-
l1 = "lv1"
100-
}
101-
}
102-
spec {
103-
unschedulable = false
104-
taints = [
105-
{
106-
effect = "PreferNoSchedule"
107-
key = "t1"
108-
value = "tv1"
109-
}
110-
]
111-
}
112-
}
85+
service_name = ovh_cloud_project_kube.cluster.service_name
86+
kube_id = ovh_cloud_project_kube.cluster.id
87+
name = ovh_cloud_project_kube.cluster.name
88+
flavor_name = "b2-7"
89+
desired_nodes = 1
90+
min_nodes = 0
91+
max_nodes = 1
92+
template {
93+
metadata {
94+
annotations = {
95+
a1 = "av1"
96+
}
97+
finalizers = ["finalizer.extensions/v1beta1"]
98+
labels = {
99+
l1 = "lv1"
100+
}
101+
}
102+
spec {
103+
unschedulable = false
104+
taints = [
105+
{
106+
effect = "PreferNoSchedule"
107+
key = "t1"
108+
value = "tv1"
109+
}
110+
]
111+
}
112+
}
113113
}
114+
114115
`
115116

116117
var testAccCloudProjectKubeNodePoolConfigUpdated = `
117118
resource "ovh_cloud_project_kube" "cluster" {
118-
service_name = "%s"
119-
name = "%s"
120-
region = "%s"
121-
version = "%s"
119+
service_name = "%s"
120+
name = "%s"
121+
region = "%s"
122+
version = "%s"
122123
}
123124
124125
resource "ovh_cloud_project_kube_nodepool" "pool" {
125-
service_name = ovh_cloud_project_kube.cluster.service_name
126-
kube_id = ovh_cloud_project_kube.cluster.id
127-
name = ovh_cloud_project_kube.cluster.name
128-
flavor_name = "b2-7"
129-
desired_nodes = 2
130-
min_nodes = 0
131-
max_nodes = 2
132-
template {
133-
metadata {
134-
annotations = {
135-
a2 = "av2"
136-
}
137-
labels = {
138-
l2 = "lv2"
139-
}
140-
}
141-
}
126+
service_name = ovh_cloud_project_kube.cluster.service_name
127+
kube_id = ovh_cloud_project_kube.cluster.id
128+
name = ovh_cloud_project_kube.cluster.name
129+
flavor_name = "b2-7"
130+
desired_nodes = 2
131+
min_nodes = 0
132+
max_nodes = 2
133+
template {
134+
metadata {
135+
annotations = {
136+
a2 = "av2"
137+
}
138+
finalizers = []
139+
labels = {
140+
l2 = "lv2"
141+
}
142+
}
143+
spec {
144+
unschedulable = false
145+
taints = []
146+
}
147+
}
142148
}
149+
143150
`
144151

145152
var testAccCloudProjectKubeNodePoolConfigUpdatedScaleToZero = `
146153
resource "ovh_cloud_project_kube" "cluster" {
147-
service_name = "%s"
148-
name = "%s"
149-
region = "%s"
150-
version = "%s"
154+
service_name = "%s"
155+
name = "%s"
156+
region = "%s"
157+
version = "%s"
151158
}
152159
153160
resource "ovh_cloud_project_kube_nodepool" "pool" {
154-
service_name = ovh_cloud_project_kube.cluster.service_name
155-
kube_id = ovh_cloud_project_kube.cluster.id
156-
name = ovh_cloud_project_kube.cluster.name
157-
flavor_name = "b2-7"
158-
desired_nodes = 0
159-
min_nodes = 0
160-
max_nodes = 2
161-
template {
162-
metadata {
163-
annotations = {
164-
a2 = "av2"
165-
}
166-
labels = {
167-
l2 = "lv2"
168-
}
169-
}
170-
}
161+
service_name = ovh_cloud_project_kube.cluster.service_name
162+
kube_id = ovh_cloud_project_kube.cluster.id
163+
name = ovh_cloud_project_kube.cluster.name
164+
flavor_name = "b2-7"
165+
desired_nodes = 0
166+
min_nodes = 0
167+
max_nodes = 2
168+
template {
169+
metadata {
170+
annotations = {
171+
a2 = "av2"
172+
}
173+
finalizers = []
174+
labels = {
175+
l2 = "lv2"
176+
}
177+
}
178+
spec {
179+
unschedulable = false
180+
taints = []
181+
}
182+
}
171183
}
184+
172185
`
173186

174187
func TestAccCloudProjectKubeNodePool(t *testing.T) {
@@ -218,9 +231,11 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
218231
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "1"),
219232
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
220233
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "1"),
234+
221235
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a1", "av1"),
222236
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.0", "finalizer.extensions/v1beta1"),
223237
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l1", "lv1"),
238+
224239
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.effect", "PreferNoSchedule"),
225240
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.key", "t1"),
226241
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.value", "tv1"),
@@ -239,10 +254,13 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
239254
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "2"),
240255
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
241256
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "2"),
257+
242258
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a2", "av2"),
243259
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.#", "0"),
244260
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l2", "lv2"),
261+
245262
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.#", "0"),
263+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.unschedulable", "false"),
246264
),
247265
},
248266
{
@@ -257,10 +275,13 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
257275
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "0"),
258276
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
259277
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "2"),
278+
260279
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a2", "av2"),
261280
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.#", "0"),
262281
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l2", "lv2"),
282+
263283
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.#", "0"),
284+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.unschedulable", "false"),
264285
),
265286
},
266287
{

0 commit comments

Comments
 (0)