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

kubernetes_node_taint: fix warning when node is missing #2402

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

partcyborg
Copy link
Contributor

@partcyborg partcyborg commented Jan 13, 2024

Description

Move the check for errors.IsNotFound to the correct err so nodes that have been turned down do not cause existing resources to error.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccKubernetesResourceNodeTaint'
==> Checking that code complies with gofmt requirements...
go vet ./...
TF_ACC=1 go test "/home/mwilder/src/go/src/github.com/partcyborg/terraform-provider-kubernetes/kubernetes" -v -vet=off -run=TestAccKubernetesResourceNodeTaint -parallel 8 -timeout 3h
=== RUN   TestAccKubernetesResourceNodeTaint_basic
--- PASS: TestAccKubernetesResourceNodeTaint_basic (8.82s)
=== RUN   TestAccKubernetesResourceNodeTaint_MultipleBasic
--- PASS: TestAccKubernetesResourceNodeTaint_MultipleBasic (22.61s)
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/kubernetes	31.460s

There does not appear to be a way to test this with the existing test infrastructure, as we would need a state file that contains a node that doesn't exist in the context used.

As an alternative, I tested this change manually with existing terraform state using a dev_override. While it fails with the upstream provider, with the dev version it warns as expected:

╷
│ Warning: Node has been deleted
│
│   with module.retired_taints.kubernetes_node_taint.this["ip-10-252-229-82.ca-central-1.compute.internal"],
│   on ../../../../../tf_modules/k8s/node_taints/main.tf line 11, in resource "kubernetes_node_taint" "this":
│   11: resource "kubernetes_node_taint" "this" {
│
│ The underlying node "ip-10-252-229-82.ca-central-1.compute.internal" has
│ been deleted. You should remove it from your configuration.
│
│ (and 11 more similar warnings elsewhere)

Release Note

Release note for CHANGELOG:

`resource/kubernetes_node_taint`: Fix the error check for nonexistant nodes so that terraform does not fail if there is a taint in the state file for a node that has been deleted.

References

Closes #2466

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Move the check for `errors.IsNotFound` to the correct err so nodes that have been turned down do not cause the resource to error.
@partcyborg partcyborg requested a review from a team as a code owner January 13, 2024 02:35
@partcyborg
Copy link
Contributor Author

partcyborg commented Feb 14, 2024

Friendly ping @jrhouston @alexsomesan @arybolovlev.

Apologies for messing up the error check before. This is the last blocker keeping us from migrating off of from our custom provider fork sdb-cloud-ops/kubernetes to the official upstream one, so I would love to get it checked in.

Thanks in advance!

Copy link
Contributor

@arybolovlev arybolovlev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this, @partcyborg! 👍🏻

EDIT: This fix will be available in the next release.

@arybolovlev arybolovlev merged commit 235a119 into hashicorp:main Apr 18, 2024
16 of 17 checks passed
@partcyborg partcyborg deleted the fix-node-gone-warn branch April 25, 2024 19:35
dduportal referenced this pull request in jenkins-infra/azure May 10, 2024
<Actions>
<action
id="bcd9b70d7c1eb1e07eb5ad8a958f18dc1bbd81461ee1a2604adeea46e3148a47">
        <h3>Bump Terraform `kubernetes` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>changes detected:&#xA;&#x9;&#34;hashicorp/kubernetes&#34; updated
from &#34;2.29.0&#34; to &#34;2.30.0&#34; in file
&#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>2.30.0</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-kubernetes/releases/tag/v2.30.0&#xA;BUG
FIXES:&#xD;&#xA;&#xD;&#xA;* `data_source/kubernetes_resources`: fix an
issue where the provider exit with an error when the data source
`kubernetes_resources` receives multiple Kubernetes objects containing
tuples with different numbers of elements.
[[GH-2372](https://github.com/hashicorp/terraform-provider-kubernetes/issues/2372)]&#xD;&#xA;*
`kubernetes_manifest`: fix issue preventing KUBE_PROXY_URL environment
variable from being used in client configuration (#1733)
[[GH-2485](https://github.com/hashicorp/terraform-provider-kubernetes/issues/2485)]&#xD;&#xA;*
`resource/kubernetes_node_taint`: Fix the error check for nonexistant
nodes so that terraform does not fail if there is a taint in the state
file for a node that has been deleted.
[[GH-2402](https://github.com/hashicorp/terraform-provider-kubernetes/issues/2402)]&#xD;&#xA;&#xD;&#xA;DOCS:&#xD;&#xA;&#xD;&#xA;*
Migrate legacy structure to new tfplugindocs template structure
[[GH-2470](https://github.com/hashicorp/terraform-provider-kubernetes/issues/2470)]&#xD;&#xA;</pre>
            </details>
        </details>
<a
href="https://infra.ci.jenkins.io/job/updatecli/job/azure/job/main/161/">Jenkins
pipeline link</a>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <60776566+jenkins-infra-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubernetes_node_taint: can't apply if a tainted node has been removed from the cluster
2 participants