Skip to content

Conversation

krunalhinguu
Copy link
Contributor

@krunalhinguu krunalhinguu commented Sep 17, 2025

Issue

Problem

Currently, the imported_config block is only processed when the driver is explicitly set to "imported".
This causes updates to fail or silently ignore imported_config settings (e.g., private_registry_url) for hosted imported clusters, since they use their respective driver blocks (aks_config_v2, eks_config_v2, gke_config_v2) instead of the "imported" driver.

Solution

The handling of imported_config has been pulled out of the driver switch block and is now applied independently of driver type.
This ensures imported_config is always processed when defined, including for hosted imported clusters during updates.

Testing

  • Import an existing AKS/EKS/GKE cluster into Rancher using Terraform.
  • Apply an update that adds an imported_config block (e.g., setting private_registry_url).
  • Confirm that the update succeeds and the imported config is applied in Rancher.
  • Validate that clusters without imported_config remain unaffected.

Engineering Testing

Manual Testing

  • Imported an AKS cluster (aks_config_v2 with imported = true) into Rancher.
  • Applied an update with imported_config defined and verified the changes were applied correctly.
  • Imported an EKS cluster and repeated the above validation.
  • Confirmed that "imported" driver clusters still accept imported_config.

Automated Testing

  • No automated tests added at this stage.
  • Regression risk is limited to update handling for clusters with imported_config.

QA Testing Considerations

  • Import AKS/EKS/GKE clusters into Rancher, then update them with imported_config to ensure changes apply.
  • Validate that "imported" driver clusters continue to work.
  • Ensure updates to non-imported hosted clusters (AKS/EKS/GKE without imported_config) succeed without errors.

Regressions Considerations

  • Regression risk: updates to "imported" driver clusters.
  • Probability: low, as logic was only refactored to run before driver-specific handling.

}

// imported_config is special because it applies to *any imported cluster*,
// including hosted providers (AKS, EKS, GKE) where `imported = true` is set.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure, if we are mixing here settings. For hosted providers imported flag is set inside hosted_provider_spec, e.g. https://github.com/rancher/aks-operator/blob/main/pkg/apis/aks.cattle.io/v1/types.go#L43

Even if hosted provider imported cluster is set, then it should be managed by hoster provider operator

Copy link
Contributor Author

@krunalhinguu krunalhinguu Sep 17, 2025

Choose a reason for hiding this comment

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

We got this example from customer

So do you mean that this is incorrect way of initialising it? And it should be inside the aks_config_v2?

resource "rancher2_cluster" "aks_imported" {
  name        = var.aks_cluster_name
  description = "Imported AKS cluster via Terraform"
  aks_config_v2 {
    cloud_credential_id = rancher2_cloud_credential.aks.id
    resource_group      = var.resource_group_name
    resource_location   = var.azure_location
    imported            = true
  }
  imported_config {
      private_registry_url = "registry.suse.com"
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, it looks good to me, I had to understand bug description 👍

@matttrach
Copy link
Collaborator

This looks good from a general Terraform point of view, but we still need approval from the responsible team to merge.

}

// imported_config is special because it applies to *any imported cluster*,
// including hosted providers (AKS, EKS, GKE) where `imported = true` is set.
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, it looks good to me, I had to understand bug description 👍

@matttrach matttrach merged commit bc8d237 into rancher:main Sep 19, 2025
6 checks passed
matttrach pushed a commit to matttrach/terraform-provider-rancher2 that referenced this pull request Sep 19, 2025
Process imported_code flag outside of switch statement.

(cherry picked from commit bc8d237)
matttrach pushed a commit to matttrach/terraform-provider-rancher2 that referenced this pull request Sep 19, 2025
Process imported_code flag outside of switch statement.

(cherry picked from commit bc8d237)
matttrach pushed a commit to matttrach/terraform-provider-rancher2 that referenced this pull request Sep 19, 2025
Process imported_code flag outside of switch statement.

(cherry picked from commit bc8d237)
matttrach added a commit that referenced this pull request Sep 22, 2025
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.

3 participants