Skip to content

Commit 80e8520

Browse files
authored
kubernetes_node_taint: don't fail if node is missing (#2099)
Show a warning instead of an error if a tainted node is missing. Otherwise, taints for deleted nodes can only be removed via `terraform state rm`.
1 parent 7196986 commit 80e8520

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changelog/2099.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:bug
2+
`resource/kubernetes_node_taint`: Don't fail when there is a taint in the state file for a node that no longer exists.
3+
4+
```

kubernetes/resource_kubernetes_node_taint.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ func resourceKubernetesNodeTaintRead(ctx context.Context, d *schema.ResourceData
100100

101101
conn, err := m.(KubeClientsets).MainClientset()
102102
if err != nil {
103+
if statusErr, ok := err.(*errors.StatusError); ok && errors.IsNotFound(statusErr) {
104+
// The node is gone so the resource should be deleted.
105+
return diag.Diagnostics{{
106+
Severity: diag.Warning,
107+
Summary: "Node has been deleted",
108+
Detail: fmt.Sprintf("The underlying node %q has been deleted. You should remove it from your configuration.", nodeName),
109+
}}
110+
}
103111
return diag.FromErr(err)
104112
}
105113
nodeApi := conn.CoreV1().Nodes()

0 commit comments

Comments
 (0)