Skip to content

Ignore rke_config.etcd_snapshot_create to prevent plan drift#221

Open
Akini98 wants to merge 1 commit into
wso2:terraformfrom
Akini98:fix/220-etcd-snapshot-create-ignore-changes
Open

Ignore rke_config.etcd_snapshot_create to prevent plan drift#221
Akini98 wants to merge 1 commit into
wso2:terraformfrom
Akini98:fix/220-etcd-snapshot-create-ignore-changes

Conversation

@Akini98

@Akini98 Akini98 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Purpose

Resolves #220. On-demand etcd snapshots taken via the Rancher UI/API ("Snapshot Now") set rke_config.etcd_snapshot_create.generation on the provisioning cluster object. The k8s-cluster module does not manage that field, so every subsequent terraform plan shows spurious in-place drift trying to null it (e.g. etcd_snapshot_create { generation = 1 -> null }).

Goals

Stop the drift while keeping scheduled snapshots Terraform-managed.

Approach

Add rke_config[0].etcd_snapshot_create to the cluster resource's existing lifecycle { ignore_changes = [...] } (alongside chart_values / machine_selector_config). On-demand snapshots stay a UI/API action; the schedule remains managed via the etcd_s3 input.

Release note

Fix: k8s-cluster no longer shows plan drift after an on-demand etcd snapshot is taken from the Rancher UI.

Documentation

The behavior is noted in the backups guide (#219, examples/BACKUPS.md §A.6).

Automation tests

N/A. Observed and reproduced on a live cluster: after a UI "Snapshot Now", terraform plan repeatedly proposed nulling etcd_snapshot_create; with this change the plan is clean. terraform fmt -check passes on the changed file.

Security checks

  • No secrets committed? yes — single-line ignore_changes addition, no values.

Compatibility

Non-breaking — additive to ignore_changes, no variable/output surface change.

Related PRs

Other template sections (Training, Certification, Marketing, Migrations, Samples): N/A.

Summary by CodeRabbit

  • Bug Fixes
    • Reduced unexpected Terraform plan drift for Kubernetes clusters after using the manual Snapshot Now action.
    • Subsequent applies should now stay stable while scheduled snapshot settings remain managed as expected.

On-demand etcd snapshots taken via the Rancher UI/API set etcd_snapshot_create.generation on the cluster object. The module does not manage that field, so every subsequent plan showed spurious in-place drift trying to null it. Add it to ignore_changes; scheduled snapshots remain Terraform-managed via etcd_s3. Non-breaking (additive to ignore_changes).
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4479af40-a295-4ae6-bfee-370fed109e23

📥 Commits

Reviewing files that changed from the base of the PR and between bb7138b and 6bbe281.

📒 Files selected for processing (1)
  • modules/tenancy/k8s-cluster/main.tf

📝 Walkthrough

Walkthrough

This change updates the rancher2_cluster_v2.this resource in modules/tenancy/k8s-cluster/main.tf, adding rke_config[0].etcd_snapshot_create to the lifecycle.ignore_changes list, with inline comments explaining that on-demand "Snapshot Now" actions mutate this field and previously caused plan drift.

Changes

Terraform Drift Fix

Layer / File(s) Summary
Ignore on-demand snapshot drift
modules/tenancy/k8s-cluster/main.tf
Adds rke_config[0].etcd_snapshot_create to the lifecycle.ignore_changes list on the cluster resource, with comments explaining that UI/API "Snapshot Now" actions mutate etcd_snapshot_create.generation, causing recurring plan drift; scheduled snapshots remain Terraform-managed via etcd_s3.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Related Issues: #220

Suggested Labels: bug, terraform

Suggested Reviewers: (none identified)

Poem
A rabbit hopped through Terraform's plan,
Found drift where a snapshot began,
"Ignore it now," it softly said,
"Let schedules stay, let noise be dead."
One tidy line, and calm again. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: ignoring etcd snapshot creation to stop Terraform drift.
Description check ✅ Passed The description covers purpose, approach, testing, compatibility, and related work, so it is mostly complete despite using different headings.
Linked Issues check ✅ Passed The change satisfies #220 by adding rke_config[0].etcd_snapshot_create to ignore_changes while leaving scheduled snapshots managed.
Out of Scope Changes check ✅ Passed No unrelated changes are apparent; the diff is limited to the requested ignore_changes adjustment and explanatory comments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant