rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
263 stars 228 forks source link

[BUG] rke2 machineSelectorFiles.fileSources have multiple duplicate entries #1426

Closed kinarashah closed 1 day ago

kinarashah commented 1 month ago

Rancher Server Setup

Information about the Cluster

Provider Information

Describe the bug

  1. The default value of dynamic field using terraform provider should be consistent with Rancher API. dynamic is false when editing cluster object using API/UI but set to true using terraform.
  2. Multiple duplicate entries for fileSources are added to the cluster object under machineSelectorFiles. Only one entry is expected for the same secret and hash value.

To Reproduce

Expected Result

Only one unique fileSource is added to the machineSelectorFiles on cluster edits if the secret or the hash value doesn't change.

SURE-9071

nicgrobler commented 1 month ago

We got bitten by this during the upgrade of downstream cluster (rancher 2.9.2, rke2 1.28.13) - the issue is that it creates a new entry, with a different hash (in our case), and this then causes the upgrade to stall as it then complains that the psact secret ‘doesn’t contain the expected contents’ - the fix is to remove the duplicate block from the cluster object / ensure the new hash matches the existing entries. The moment you do this, the error goes away and the upgrade progresses

kinarashah commented 2 weeks ago

@nicgrobler This was using terraform as well, correct? I wanted to verify as my fix is scoped to terraform. If you see multiple entries being added via API/UI lmk as that'd be a different issue.

Josh-Diamond commented 1 day ago

Ticket #1426 - Test Results - ✅

Verified on Rancher v2.10.0 with Rancher2 v6.0.0-rc3:

Scenario Test Result Result
1. Provision downstream RKE2 AWS Node driver cluster => edit cluster and force reconciliation => confirm no duplicate entries are seen in machineSelectorFiles.fileSources

Scenario 1 - ✅

  1. Provision a downstream RKE2 AWS Node driver cluster
  2. Once active, modify snapshot_retention and apply changes
  3. Once cluster updates and is active, edit YAML of cluster object and verify machineSeletorFiles.fileSources
  4. Verified - No duplicates seen in machineSelectorFiles.fileSources after cluster update; as expected