Skip to content

Commit

Permalink
[CCE] skip predefined taints for `resource/opentelekomcloud_cce_node_…
Browse files Browse the repository at this point in the history
…v3` (#2380)

[CCE] skip predefined taints for `resource/opentelekomcloud_cce_node_v3`

Summary of the Pull Request
If CCE nodes are stopped and you're running terraform apply/plan, two taints will give you a "force replacement".
  # opentelekomcloud_cce_node_v3.node-1 must be replaced
-/+ resource "opentelekomcloud_cce_node_v3" "node-1" {

...

      - taints { # forces replacement
          - effect = "NoSchedule" -> null
          - key    = "node.kubernetes.io/unreachable" -> null
        }
      - taints { # forces replacement
          - effect = "NoSchedule" -> null
          - key    = "node.cloudprovider.kubernetes.io/shutdown" -> null
        }
    }
PR Checklist

 Refers to: #xxx
 Tests added/passed.
 Documentation updated.
 Schema updated.
 Release notes added.

Acceptance Steps Performed
=== RUN   TestAccCCENodesV3Basic
=== PAUSE TestAccCCENodesV3Basic
=== CONT  TestAccCCENodesV3Basic
--- PASS: TestAccCCENodesV3Basic (4276.41s)
=== RUN   TestAccCCENodesV3Agency
=== PAUSE TestAccCCENodesV3Agency
=== CONT  TestAccCCENodesV3Agency
--- PASS: TestAccCCENodesV3Agency (1307.36s)
=== RUN   TestAccCCENodesV3Multiple
=== PAUSE TestAccCCENodesV3Multiple
=== CONT  TestAccCCENodesV3Multiple
--- PASS: TestAccCCENodesV3Multiple (5339.57s)
=== RUN   TestAccCCENodesV3Timeout
=== PAUSE TestAccCCENodesV3Timeout
=== CONT  TestAccCCENodesV3Timeout
--- PASS: TestAccCCENodesV3Timeout (1387.04s)
=== RUN   TestAccCCENodesV3BandWidthResize
=== PAUSE TestAccCCENodesV3BandWidthResize
=== CONT  TestAccCCENodesV3BandWidthResize
--- PASS: TestAccCCENodesV3BandWidthResize (1483.01s)
=== RUN   TestAccCCENodesV3_eipIds
=== PAUSE TestAccCCENodesV3_eipIds
=== CONT  TestAccCCENodesV3_eipIds
--- PASS: TestAccCCENodesV3_eipIds (2329.20s)
=== RUN   TestAccCCENodesV3IpSetNull
=== PAUSE TestAccCCENodesV3IpSetNull
=== CONT  TestAccCCENodesV3IpSetNull
--- PASS: TestAccCCENodesV3IpSetNull (1899.44s)
=== RUN   TestAccCCENodesV3IpCreate
=== PAUSE TestAccCCENodesV3IpCreate
=== CONT  TestAccCCENodesV3IpCreate
--- PASS: TestAccCCENodesV3IpCreate (1695.46s)
=== RUN   TestAccCCENodesV3IpNulls
=== PAUSE TestAccCCENodesV3IpNulls
=== CONT  TestAccCCENodesV3IpNulls
--- PASS: TestAccCCENodesV3IpNulls (1022.68s)
=== RUN   TestAccCCENodesV3EncryptedVolume
=== PAUSE TestAccCCENodesV3EncryptedVolume
=== CONT  TestAccCCENodesV3EncryptedVolume
--- PASS: TestAccCCENodesV3EncryptedVolume (1336.78s)
=== RUN   TestAccCCENodesV3TaintsK8sTags
=== PAUSE TestAccCCENodesV3TaintsK8sTags
=== CONT  TestAccCCENodesV3TaintsK8sTags
--- PASS: TestAccCCENodesV3TaintsK8sTags (1341.82s)
=== RUN   TestAccCCENodesV3_extendParams
=== PAUSE TestAccCCENodesV3_extendParams
=== CONT  TestAccCCENodesV3_extendParams
--- PASS: TestAccCCENodesV3_extendParams (1349.84s)
PASS

Process finished with exit code 0

Reviewed-by: Anton Sidelnikov
Reviewed-by: Vladimir Vshivkov
Reviewed-by: Artem Lifshits
  • Loading branch information
Nemental authored Nov 30, 2023
1 parent 9165e86 commit 260a3d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ var (
"topology.kubernetes.io/region",
"topology.kubernetes.io/zone",
}

predefinedTaints = []string{
"node.kubernetes.io/unreachable",
"node.cloudprovider.kubernetes.io/shutdown",
}
)

func ResourceCCENodeV3() *schema.Resource {
Expand Down Expand Up @@ -812,13 +817,16 @@ func setK8sNodeFields(d *schema.ResourceData, config *cfg.Config, clusterID, pri
log.Printf("[WARN] error retrieving CCE node: %s", err.Error())
return nil
}
taints := make([]interface{}, len(k8Node.Spec.Taints))
for i, v := range k8Node.Spec.Taints {
taints[i] = map[string]interface{}{
"key": v.Key,
"value": v.Value,
"effect": v.Effect,
taints := make([]interface{}, 0)
for _, value := range k8Node.Spec.Taints {
if com.IsSliceContainsStr(predefinedTaints, value.Key) {
continue
}
taints = append(taints, map[string]interface{}{
"key": value.Key,
"value": value.Value,
"effect": value.Effect,
})
}
if err := d.Set("taints", taints); err != nil {
return fmt.Errorf("error setting taints for CCE Node: %w", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
**[CCE]** skip predefined taints for ``resource/opentelekomcloud_cce_node_v3`` (`#2380 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2380>`_)

0 comments on commit 260a3d6

Please sign in to comment.