Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: azurerm_redhat_openshift_cluster #24375

Merged
merged 94 commits into from
Jan 19, 2024

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Jan 3, 2024

supersede #20266

Reference:

  1. https://github.com/Azure/azure-rest-api-specs/blob/main/specification/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-09-04/redhatopenshift.json
  2. https://learn.microsoft.com/en-us/azure/openshift/tutorial-create-cluster

Notes:

  1. For internal server error mentioned in previous PR, it is caused by deletion of Azure Red Hat OpenShift RP app. And resource created in acctest cannot be deleted if the RP app is deleted. From service team, the deletion of RP app is not expected. The app is created when registering Microsoft.RedHatOpenShift resource provider for subscription. To recover the deleted app, re-register the Microsoft.RedHatOpenShift resource provider. In Terraform config, we should NOT use resource for the azuread_service_principal, data source should be used.
   // This is the RedHatOpenShift service principal id
- resource "azuread_service_principal" "redhatopenshift" {
-   application_id = "f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875"
-   use_existing   = true
- }
+ data "azuread_service_principal" "redhatopenshift" {
+  application_id = "f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875"
+ }
  1. For PUT-GET inconsistence issue for workerProfile mentioned in New Resource: azurerm_redhat_openshift_cluster #20266 (review), this is fixed in 2023-09-04 version of API. A new workerProfilesStatus field is added to display seperated workers.

  2. Updated to use hashicorp/go-azure-sdk and typed sdk.

Test:

ARM_TEST_LOCATION="westus" make acctests SERVICE="redhatopenshift" TESTARGS="-parallel 20 -run TestAccOpenShiftCluster_" TESTTIMEOUT='2h'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/redhatopenshift -parallel 20 -run TestAccOpenShiftCluster_ -timeout 2h -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccOpenShiftCluster_basic
=== PAUSE TestAccOpenShiftCluster_basic
=== RUN   TestAccOpenShiftCluster_update
=== PAUSE TestAccOpenShiftCluster_update
=== RUN   TestAccOpenShiftCluster_private
=== PAUSE TestAccOpenShiftCluster_private
=== RUN   TestAccOpenShiftCluster_userDefinedRouting
=== PAUSE TestAccOpenShiftCluster_userDefinedRouting
=== RUN   TestAccOpenShiftCluster_encryptionAtHost
=== PAUSE TestAccOpenShiftCluster_encryptionAtHost
=== RUN   TestAccOpenShiftCluster_basicWithFipsEnabled
=== PAUSE TestAccOpenShiftCluster_basicWithFipsEnabled
=== RUN   TestAccOpenShiftCluster_requiresImport
=== PAUSE TestAccOpenShiftCluster_requiresImport
=== CONT  TestAccOpenShiftCluster_basic
=== CONT  TestAccOpenShiftCluster_requiresImport
=== CONT  TestAccOpenShiftCluster_encryptionAtHost
=== CONT  TestAccOpenShiftCluster_update
=== CONT  TestAccOpenShiftCluster_private
=== CONT  TestAccOpenShiftCluster_userDefinedRouting
=== CONT  TestAccOpenShiftCluster_basicWithFipsEnabled
--- PASS: TestAccOpenShiftCluster_basic (3348.99s)
--- PASS: TestAccOpenShiftCluster_requiresImport (3701.20s)
--- PASS: TestAccOpenShiftCluster_userDefinedRouting (3759.67s)
--- PASS: TestAccOpenShiftCluster_encryptionAtHost (3850.19s)
--- PASS: TestAccOpenShiftCluster_private (3862.10s)
--- PASS: TestAccOpenShiftCluster_basicWithFipsEnabled (3874.02s)
--- PASS: TestAccOpenShiftCluster_update (4961.78s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/redhatopenshift       4961.804s

@katbyte
Copy link
Collaborator

katbyte commented Jan 8, 2024

@teowa - have they resolved the general issue of the service always returning an uninformative "internal server error" that doesn't indicate what the problem is?

@teowa
Copy link
Contributor Author

teowa commented Jan 8, 2024

@katbyte The internal server error still exists for now, if the RedHatOpenShift Service Principal is deleted. From service team, the SP is not expected to be deleted and it is created during RP registration.

Copy link
Contributor

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

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

Hey @teowa,

Thanks for this PR - I've taken a look through and left some comments inline. If we can fix those up, this should be good to go 👍

Thanks!

}

func NewClient(o *common.ClientOptions) (*Client, error) {
openshiftClustersClient, err := openshiftclusters.NewOpenShiftClustersClientWithBaseURI(o.Environment.ResourceManager)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
openshiftClustersClient, err := openshiftclusters.NewOpenShiftClustersClientWithBaseURI(o.Environment.ResourceManager)
openShiftClustersClient, err := openshiftclusters.NewOpenShiftClustersClientWithBaseURI(o.Environment.ResourceManager)


type WorkerProfile struct {
VmSize string `tfschema:"vm_size"`
DiskSizeGb int64 `tfschema:"disk_size_gb"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DiskSizeGb int64 `tfschema:"disk_size_gb"`
DiskSizeGb int `tfschema:"disk_size_gb"`

Copy link
Contributor

Choose a reason for hiding this comment

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

(just passing through) but FWIW these should be int64 and not int - since we're expecting int64's everywhere else (SDK etc) even if that's downcast to a smaller variable size

type WorkerProfile struct {
VmSize string `tfschema:"vm_size"`
DiskSizeGb int64 `tfschema:"disk_size_gb"`
NodeCount int64 `tfschema:"node_count"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NodeCount int64 `tfschema:"node_count"`
NodeCount int `tfschema:"node_count"`

ForceNew: true,
Default: false,
},
"pull_secret": {
Copy link
Contributor

Choose a reason for hiding this comment

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

should pull_secret be a sensitive value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this is sensitive


parameters := openshiftclusters.OpenShiftCluster{
Name: pointer.To(id.OpenShiftClusterName),
Location: azure.NormalizeLocation(config.Location),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Location: azure.NormalizeLocation(config.Location),
Location: location.Normalize(config.Location),


* `client_id` - (Required) The Client ID for the Service Principal. Changing this forces a new resource to be created.

* `client_secret` - (Required) The Client Secret for the Service Principal. Changing this forces a new resource to be created.
Copy link
Contributor

Choose a reason for hiding this comment

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

is client_secret forcenew?


* `encryption_at_host_enabled` - (Optional) Whether main virtual machines are encrypted at host. Defaults to `false`. Changing this forces a new resource to be created.

**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.
**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.


* `encryption_at_host_enabled` - (Optional) Whether worker virtual machines are encrypted at host. Defaults to `false`. Changing this forces a new resource to be created.

**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.
**NOTE:** `encryption_at_host_enabled` is only available for certain VM sizes and the `EncryptionAtHost` feature must be enabled for your subscription. Please see the [Azure documentation](https://learn.microsoft.com/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell) for more information.


A `api_server_profile` block supports the following:

* `visibility` - (Optional) Cluster API server visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `visibility` - (Optional) Cluster API server visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.
* `visibility` - (Required) Cluster API server visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.


A `ingress_profile` block supports the following:

* `visibility` - (Optional) Cluster Ingress visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `visibility` - (Optional) Cluster Ingress visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.
* `visibility` - (Required) Cluster Ingress visibility. Supported values are `Public` and `Private`. Defaults to `Public`. Changing this forces a new resource to be created.

@katbyte
Copy link
Collaborator

katbyte commented Jan 10, 2024

@teowa - the issue we were seeing was that all errors returned an internal server error and we would have to reach out to the service team to figure out each one, there were multiple different causes iirc

@teowa
Copy link
Contributor Author

teowa commented Jan 17, 2024

Hi @katbyte , I have confirmed with service team, currently there are two cases will lead to InternalServerError:

  1. Cluster operation after Red Hat OpenShift RP service principal is removed.
  2. Cluster create with CMK, but the subscription has not been registered with EncryptionAtHost feature.

They are working on the fix at backend. On the other hand, they think these cases are more like user errors (customers should have not tampered with the first party sp in their tenant), so they hope we can go ahead.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @teowa, thanks for taking ownership of this and confirming some of those Internal Server Errors. I believe this PR is good to go unless you think there is anything else that needs to be done while it's in draft

@teowa teowa marked this pull request as ready for review January 19, 2024 05:45
@teowa
Copy link
Contributor Author

teowa commented Jan 19, 2024

image

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @teowa!

@mbfrahry mbfrahry changed the title New Resource azurerm_redhat_openshift_cluster New Resource: azurerm_redhat_openshift_cluster Jan 19, 2024
@mbfrahry mbfrahry merged commit 4215c4e into hashicorp:main Jan 19, 2024
39 checks passed
@mbfrahry mbfrahry added this to the v3.89.0 milestone Jan 19, 2024
mbfrahry added a commit that referenced this pull request Jan 19, 2024
puneetsarna added a commit to puneetsarna/terraform-provider-azurerm that referenced this pull request Jan 21, 2024
It looks like the SDK was updated on Jan 18th 2024 (3 days ago),
and Openshift changes with vendor landed on Jan 19th. It was very
likely the case that the openshift vendor changes were not
regenerated when the SDK changed and the new resource was merged
here hashicorp#24375.

This commit updates the vendors directory with latest changes.
puneetsarna added a commit to puneetsarna/terraform-provider-azurerm that referenced this pull request Jan 21, 2024
It looks like the SDK was updated on Jan 18th 2024 (3 days ago),
and Openshift changes with vendor landed on Jan 19th. It was very
likely the case that the openshift vendor changes were not
regenerated when the SDK changed and the new resource was merged
here hashicorp#24375.

This commit updates the vendors directory with latest changes.
Copy link

This functionality has been released in v3.89.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

dduportal added a commit to jenkins-infra/azure that referenced this pull request Jan 25, 2024
<Actions>
<action
id="f410411e63aff4bb73a81c2aec1d373cf8a903e63b30dee2006b0030d8a94cc8">
        <h3>Bump Terraform `azurerm` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>changes detected:&#xA;&#x9;&#34;hashicorp/azurerm&#34; updated from
&#34;3.88.0&#34; to &#34;3.89.0&#34; in file
&#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>3.89.0</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/v3.89.0&#xA;FEATURES:&#xA;&#xA;*
New Data Source: `azurerm_data_factory_trigger_schedule`
([#24572](https://github.com/hashicorp/terraform-provider-azurerm/issues/24572))&#xA;*
New Data Source: `azurerm_data_factory_trigger_schedules`
([#24572](https://github.com/hashicorp/terraform-provider-azurerm/issues/24572))&#xA;*
New Data Source: `azurerm_ip_groups`
([#24540](https://github.com/hashicorp/terraform-provider-azurerm/issues/24540))&#xA;*
New Data Source: `azurerm_nginx_certificate`
([#24577](https://github.com/hashicorp/terraform-provider-azurerm/issues/24577))&#xA;*
New Resource: `azurerm_chaos_studio_target`
([#24580](https://github.com/hashicorp/terraform-provider-azurerm/issues/24580))&#xA;*
New Resource: `azurerm_elastic_san_volume_group`
([#24166](https://github.com/hashicorp/terraform-provider-azurerm/issues/24166))&#xA;*
New Resource: `azurerm_netapp_account_encryption`
([#23733](https://github.com/hashicorp/terraform-provider-azurerm/issues/23733))&#xA;*
New Resource: `azurerm_redhat_openshift_cluster`
([#24375](https://github.com/hashicorp/terraform-provider-azurerm/issues/24375))&#xA;&#xA;ENHANCEMENTS:&#xA;&#xA;*
dependencies: updating to `v0.66.1` of
`github.com/hashicorp/go-azure-helpers`
([#24561](https://github.com/hashicorp/terraform-provider-azurerm/issues/24561))&#xA;*
dependencies: updating to `v0.20240124.1115501` of
`github.com/hashicorp/go-azure-sdk`
([#24619](https://github.com/hashicorp/terraform-provider-azurerm/issues/24619))&#xA;*
`bot`: updating to API Version `2021-05-01-preview`
([#24555](https://github.com/hashicorp/terraform-provider-azurerm/issues/24555))&#xA;*
`containerservice`: the SDK Clients now support logging
([#24564](https://github.com/hashicorp/terraform-provider-azurerm/issues/24564))&#xA;*
`cosmosdb`: updating to API Version `2023-04-15`
([#24541](https://github.com/hashicorp/terraform-provider-azurerm/issues/24541))&#xA;*
`loadtestservice`: updating to use the base layer from
`hashicorp/go-azure-sdk` rather than `Azure/go-autorest` (and support
logging)
([#24578](https://github.com/hashicorp/terraform-provider-azurerm/issues/24578))&#xA;*
`managedidentity`: updating to use the base layer from
`hashicorp/go-azure-sdk` rather than `Azure/go-autorest` (and support
logging)
([#24578](https://github.com/hashicorp/terraform-provider-azurerm/issues/24578))&#xA;*
`azurerm_api_management_api` - change the `id` format so specific
`revision`s can be managed by Terraform
([#23031](https://github.com/hashicorp/terraform-provider-azurerm/issues/23031))&#xA;*
`azurerm_data_protection_backup_vault` - the `redundancy` propety can
now be set to `ZoneRedundant`
([#24556](https://github.com/hashicorp/terraform-provider-azurerm/issues/24556))&#xA;*
`azurerm_data_factory_integration_runtime_azure_ssis` - support for the
`credential_name` property
([#24458](https://github.com/hashicorp/terraform-provider-azurerm/issues/24458))&#xA;*
`azurerm_orchestrated_virtual_machine_scale_set` - support
`2022-datacenter-azure-edition-hotpatch` and
`2022-datacenter-azure-edition-hotpatch-smalldisk` hotpatching images
([#23500](https://github.com/hashicorp/terraform-provider-azurerm/issues/23500))&#xA;*
`azurerm_stream_analytics_job` - support for the `sku_name` property
([#24554](https://github.com/hashicorp/terraform-provider-azurerm/issues/24554))&#xA;&#xA;BUG
FIXES:&#xA;&#xA;* Data Source: `azurerm_app_service` - parsing the API
Response for `app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
Data Source: `azurerm_function_app` - parsing the API Response for
`app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
`azurerm_app_configuration_key` - the value for the `value` property can
now be removed/emptied
([#24582](https://github.com/hashicorp/terraform-provider-azurerm/issues/24582))&#xA;&#xA;*
`azurerm_app_service` - parsing the API Response for
`app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
`azurerm_app_service_plan` - fix casing in `serverFarms` due to ID
update
([#24562](https://github.com/hashicorp/terraform-provider-azurerm/issues/24562))&#xA;*
`azurerm_app_service_slot` - parsing the API Response for
`app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
`azurerm_automation_schedule` - only one `monthly_occurence` block can
now be specified
([#24614](https://github.com/hashicorp/terraform-provider-azurerm/issues/24614))&#xA;*
`azurerm_cognitive_deployment` - the `model.version` property is no
longer required
([#24264](https://github.com/hashicorp/terraform-provider-azurerm/issues/24264))&#xA;*
`azurerm_container_app` - multiple `custom_scale_rule` can not be
updated
([#24509](https://github.com/hashicorp/terraform-provider-azurerm/issues/24509))&#xA;*
`azurerm_container_registry_task_schedule_run_now` - prevent issue where
the incorrect scheduled run in tracked if there have been multiple
([#24592](https://github.com/hashicorp/terraform-provider-azurerm/issues/24592))&#xA;*
`azurerm_function_app` - parsing the API Response for
`app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
`azurerm_function_app_slot` - parsing the API Response for
`app_service_plan_id` case-insensitively
([#24626](https://github.com/hashicorp/terraform-provider-azurerm/issues/24626))&#xA;*
`azurerm_logic_app_standard` - now will parse the app service ID
insensitively
([#24562](https://github.com/hashicorp/terraform-provider-azurerm/issues/24562))&#xA;*
`azurerm_logic_app_workflow` - the `workflow_parameters` will now
correctly handle information specified by `$connections`
([#24141](https://github.com/hashicorp/terraform-provider-azurerm/issues/24141))&#xA;*
`azurerm_mssql_managed_instance_security_alert_policy` - can not update
empty storage attributes
([#24553](https://github.com/hashicorp/terraform-provider-azurerm/issues/24553))&#xA;*
`azurerm_network_interface` - the `ip_configuration` properties are no
longer added to a Load Balancer Backend if one of those
`ip_configurations` is associated with a backend
([#24470](https://github.com/hashicorp/terraform-provider-azurerm/issues/24470))&#xA;&#xA;&#xA;</pre>
            </details>
        </details>
<a
href="https://infra.ci.jenkins.io/job/terraform-jobs/job/azure/job/main/1052/">Jenkins
pipeline link</a>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <60776566+jenkins-infra-bot@users.noreply.github.com>
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants