|
34 | 34 | get_k8s_version_prefix,
|
35 | 35 | get_provider_config_block_name,
|
36 | 36 | load_yaml,
|
| 37 | + update_tfstate_file, |
37 | 38 | yaml,
|
38 | 39 | )
|
39 | 40 | from _nebari.version import __version__, rounded_ver_parse
|
@@ -1649,8 +1650,61 @@ def _version_specific_upgrade(
|
1649 | 1650 | https://www.nebari.dev/docs/how-tos/kubernetes-version-upgrade
|
1650 | 1651 | """
|
1651 | 1652 | )
|
1652 |
| - |
1653 | 1653 | rich.print(text)
|
| 1654 | + |
| 1655 | + # If the Nebari provider is Azure, we must handle a major version upgrade |
| 1656 | + # of the Azure Terraform provider (from 3.x to 4.x). This involves schema changes |
| 1657 | + # that can cause validation issues. The following steps will attempt to migrate |
| 1658 | + # your state file automatically. For details, see: |
| 1659 | + # https://github.com/nebari-dev/nebari/issues/2964 |
| 1660 | + |
| 1661 | + if config.get("provider", "") == "azure": |
| 1662 | + rich.print("\n ⚠️ Azure Provider Upgrade Notice ⚠️") |
| 1663 | + rich.print( |
| 1664 | + textwrap.dedent( |
| 1665 | + """ |
| 1666 | + In this Nebari release, the Azure Terraform provider has been upgraded |
| 1667 | + from version 3.97.1 to 4.7.0. This major update includes internal schema |
| 1668 | + changes for certain resources, most notably the `azurerm_storage_account`. |
| 1669 | +
|
| 1670 | + Nebari will attempt to update your Terraform state automatically to |
| 1671 | + accommodate these changes. However, if you skip this automatic migration, |
| 1672 | + you may encounter validation errors during redeployment. |
| 1673 | +
|
| 1674 | + For detailed information on the Azure provider 4.x changes, please visit: |
| 1675 | + https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide |
| 1676 | + """ |
| 1677 | + ) |
| 1678 | + ) |
| 1679 | + |
| 1680 | + # Prompt user for confirmation |
| 1681 | + continue_ = kwargs.get("attempt_fixes", False) or Confirm.ask( |
| 1682 | + "Nebari can automatically apply the necessary state migrations. Continue?", |
| 1683 | + default=False, |
| 1684 | + ) |
| 1685 | + |
| 1686 | + if not continue_: |
| 1687 | + rich.print( |
| 1688 | + "You have chosen to skip the automatic state migration. This may lead " |
| 1689 | + "to validation errors during deployment.\n\nFor instructions on manually " |
| 1690 | + "updating your Terraform state, please refer to:\n" |
| 1691 | + "https://github.com/nebari-dev/nebari/issues/2964" |
| 1692 | + ) |
| 1693 | + exit |
| 1694 | + else: |
| 1695 | + # In this case the full path in the tfstate file is |
| 1696 | + # resources.instances.attributes.enable_https_traffic_only |
| 1697 | + MIGRATION_STATE = { |
| 1698 | + "enable_https_traffic_only": "https_traffic_only_enabled" |
| 1699 | + } |
| 1700 | + state_filepath = ( |
| 1701 | + config_filename.parent |
| 1702 | + / "stages/01-terraform-state/azure/terraform.tfstate" |
| 1703 | + ) |
| 1704 | + |
| 1705 | + # Perform the state file update |
| 1706 | + update_tfstate_file(state_filepath, MIGRATION_STATE) |
| 1707 | + |
1654 | 1708 | rich.print("Ready to upgrade to Nebari version [green]2025.2.1[/green].")
|
1655 | 1709 |
|
1656 | 1710 | return config
|
|
0 commit comments