Skip to content

Conversation

RoseSecurity
Copy link
Contributor

@RoseSecurity RoseSecurity commented Apr 7, 2025

Why

  • Kubernetes API modifies taints dynamically.
  • computed_fields explicitly marks taints as managed by Kubernetes, preventing Terraform from tracking changes while still allowing updates.
  • Avoids Terraform drift issues without completely ignoring changes via ignore_changes.
  • Ensures Karpenter can dynamically manage taints without Terraform interfering.
  • This change addresses the following drift:
 # kubernetes_manifest.node_pool["atomic-low-disk-io"] will be updated in-place
  ~ resource "kubernetes_manifest" "node_pool" {
      ~ object   = {
          ~ spec       = {
              ~ template   = {
                  ~ spec     = {
                      ~ taints        = [
                            {
                                effect    = "NoSchedule"
                                key       = "test.co/atomic-tasks"
                                timeAdded = null
                                value     = "short"
                            },
                          ~ {
                              + value     = (known after apply)
                                # (3 unchanged attributes hidden)
                            },
                        ]
                        # (5 unchanged attributes hidden)
                    }
                    # (1 unchanged attribute hidden)
                }
                # (3 unchanged attributes hidden)
            }
            # (3 unchanged attributes hidden)
        }
        # (1 unchanged attribute hidden)
    }

Important

The first apply after this change will show resources being added to state before no changes are detected in future runs

What

  • Added computed_fields attribute to the kubernetes_manifest resource to mark spec.template.spec.taints as managed by Kubernetes, which helps avoid continual drift detection.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Usage

atmos terraform plan eks/karpenter-node-pool -s <stack>

Testing

  • Validated with atmos validate stacks
  • Performed successful atmos terraform apply on component

References

Summary by CodeRabbit

  • New Features
    • Introduced a new configuration enhancement for Kubernetes-managed resources that improves drift detection by automatically aligning taint settings with Kubernetes’ control. This update offers a more predictable and stable deployment experience.

@RoseSecurity RoseSecurity requested review from a team as code owners April 7, 2025 19:21
Copy link

coderabbitai bot commented Apr 7, 2025

Walkthrough

This change adds a new attribute called computed_fields to the kubernetes_manifest resource for the node_pool in the Terraform configuration. The attribute is used to manage the field spec.template.spec.taints that Kubernetes controls. The update includes comments that clarify the purpose of this attribute and reference an issue related to drift detection in the Terraform Kubernetes provider. No existing logic is modified.

Changes

File Change Summary
src/main.tf Added computed_fields attribute to the kubernetes_manifest resource for node_pool, with accompanying comments and reference.

Poem

I hopped in to make a change so neat,
Adding fields in Terraform, quite a feat!
A little tweak in the manifest file,
Clarifying comments that make us smile.
With computed fields, our cluster's in tune,
Hoppy days, beneath the Terraform moon!
🐰✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

mergify bot commented Apr 7, 2025

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Require terratest

Wonderful, this rule succeeded.

This rule require terratest status

  • check-success = test/terratest

@RoseSecurity
Copy link
Contributor Author

/terratest

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main.tf (1)

82-83: Editorial: Unnecessary Blank Lines Before Computed Fields Block
There are a couple of extraneous blank lines (lines 82–83) right before the newly added comment and computed_fields attribute. Removing these could enhance readability and maintain a consistent style within the resource block.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec1b559 and 48f8f4a.

📒 Files selected for processing (1)
  • src/main.tf (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary
🔇 Additional comments (1)
src/main.tf (1)

84-87: Effective Addition of computed_fields to Mitigate Drift
The addition of the computed_fields = ["spec.template.spec.taints"] attribute, accompanied by inline comments and a reference URL, clearly addresses the drift issue by indicating that Kubernetes manages the taints field. This solution aligns well with the PR's objectives by preventing Terraform from tracking changes that are managed externally. Consider verifying that your provider version supports the computed_fields attribute as expected.

@RoseSecurity
Copy link
Contributor Author

/terratest

@mergify mergify bot added the needs-test Needs testing label Apr 8, 2025
@gberenice
Copy link
Contributor

/terratest

Copy link
Contributor

@gberenice gberenice left a comment

Choose a reason for hiding this comment

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

LGTM

@gberenice gberenice merged commit 025267b into main Apr 8, 2025
26 of 30 checks passed
@gberenice gberenice deleted the address-continual-drift branch April 8, 2025 12:14
Copy link

github-actions bot commented Apr 8, 2025

These changes were released in v1.535.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-test Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants