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

[WIP] Add HDInsight resource support #924

Closed
wants to merge 11 commits into from

Conversation

jjcollinge
Copy link
Contributor

@jjcollinge jjcollinge commented Mar 2, 2018

This PR adds support for creating Azure HDInsight clusters. The PR is not finished but it is in a working state i.e. clusters can be created, read, updated and deleted. I wanted to create the PR early to get some feedback and to help make it idiomatic whilst I finish it off. Currently, the acceptance tests are failing for 2 reasons:

  1. The request to create the cluster times out and the context is cancelled after about 30 minutes. By manually setting the PollingDuration to 2hr I can mitigate the issue. My understanding is it should be using the 60 minute ARM client context so I'm not sure why it's being cancelled. This issue only effects deployments via the acceptance tests and not using the provider in the example.
  2. The state returned by the Azure ARM API is different to the one used to create the cluster i.e. some fields are changed and some are emptied. I tried making these fields Computed: true but then got an error when trying to set them - as they're effectively required fields.

Some help on addressing the above issues would be great!

I also do some 'experimental' mapping between keys i.e. restCredentialAuth.isEnabled --> rest_credential_auth__is_enabled. This probably needs changing at some point but not sure on the best way to handle dynamic maps. I tried just embedding a JSON string for the configuration but I couldn't get it building.

HDInsight can be configured in a number of ways so I do plan to write some additional tests for Spark, HBase, Hive, etc.

Appreciate any thoughts at this stage.

@jjcollinge jjcollinge changed the title Add HDInsight resource support [WIP] Add HDInsight resource support Mar 3, 2018
@jeanfrancoislelezec
Copy link

@jjcollinge if you plan to support only linux cluster you could simply the structure due to the end of support of window cluster in few month

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jjcollinge

Thanks for this PR - apologies for the delay in reviewing this! I've taken a look through and left some comments in-line, but this is off to a good start :)

Given this is a large resource, I'd suggest it might be worth focusing only on the Required fields/blocks first and then add any Optional fields in a follow up PR?

Thanks!

}, false),
},

//TODO: Add support for Windows
Copy link
Contributor

Choose a reason for hiding this comment

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

given Windows support is EOL'd (and disappearing in a few months) - I think it'd be sensible to just focus on Linux at this point?

"cluster_version": {
Type: schema.TypeString,
Optional: true,
Default: "~3.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

given that (presumably) this changes as a new version is released, I think it'd be sensible to remove this default value and make this required

"Linux",
}, false),
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

(in which case, can we remove this field)

Type: schema.TypeString,
Optional: true,
},
"rest_auth_credential__password": {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we fix the double underscores in these three fields -> a single underscore?

},
"min_instance_count": {
Type: schema.TypeInt,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

does this want some validation and a default value?

}

resource "azurerm_storage_account" "test" {
name = "hdi%d"
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a limit on the number of chars available for a storage account name; could we make this a random string of 4-6 chars + with a acctestsa prefix

}

resource "azurerm_hdinsight_cluster" "test" {
name = "hdi%d"
Copy link
Contributor

Choose a reason for hiding this comment

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

could we make this acctesthdi%d

"checksumSHA1": "OXG8AijhiNimr1zNSJ85SnfcrI8=",
"path": "github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2015-03-01-preview/hdinsight",
"revision": "7b986a3a0511159a0a7877f0d7d775bdfe916d29",
"revisionTime": "2017-12-16T00:10:16Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we pin to using v12.5.0-beta of the Azure SDK for the moment? we can do that via:

govendor update github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2015-03-01-preview/hdinsight.@=v12.5.0-beta

"checksumSHA1": "0f2bCAIQjO9op810x5LnuZnAmM0=",
"path": "github.com/Azure/azure-sdk-for-go/version",
"revision": "1e334c402ea1460704b0263e5d188f28ad946ce1",
"revisionTime": "2018-02-16T17:41:56Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

(which should mean this isn't needed); although we plan to upgrade in the near future #825

setUserAgent(&hdInsightClustersClient.Client)
hdInsightClustersClient.Authorizer = auth
hdInsightClustersClient.Sender = sender
hdInsightClustersClient.SkipResourceProviderRegistration = c.skipProviderRegistration
Copy link
Contributor

Choose a reason for hiding this comment

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

minor could we switch over to using the new registration format? c.configureClient(&hdInsightClustersClient.Client, auth) (we're doing this gradually for all new resources)

@jjcollinge
Copy link
Contributor Author

Acceptance tests still failing with DIFF errors:

--- FAIL: TestAccAzureRMHDInsightCluster_basic (1473.98s)
        testing.go:459: Step 0 error: After applying this step, the plan was not empty:

                DIFF:

                DESTROY/CREATE: azurerm_hdinsight_cluster.test
                  cluster_definition.#:                                                                       "1" => "1"
                  cluster_definition.0.blueprint:                                                             "https://blueprints.azurehdinsight.net/spark-3.6.1000.0.11683648.json" => "<computed>"
                  cluster_definition.0.component_version.%:                                                   "1" => "<computed>"
                  cluster_definition.0.configurations.#:                                                      "0" => "1"
                  cluster_definition.0.configurations.0.gateway.#:                                            "" => "1"
                  cluster_definition.0.configurations.0.gateway.0.rest_auth_credential_is_enabled:            "" => "true"
                  cluster_definition.0.configurations.0.gateway.0.rest_auth_credential_password:              "" => "AbcAbc123123!"
                  cluster_definition.0.configurations.0.gateway.0.rest_auth_credential_username:              "" => "http-user"
                  cluster_definition.0.kind:                                                                  "spark" => "spark"
                  cluster_version:                                                                            "3.6.1000.0" => "3.6" (forces new resource)
                  compute_profile.#:                                                                          "1" => "1"
                  compute_profile.0.roles.#:                                                                  "3" => "2"
                  compute_profile.0.roles.0.hardware_profile.#:                                               "1" => "1"
                  compute_profile.0.roles.0.hardware_profile.0.vm_size:                                       "Standard_D12_v2" => "Standard_D12_v2"
                  compute_profile.0.roles.0.min_instance_count:                                               "0" => "2"
                  compute_profile.0.roles.0.name:                                                             "headnode" => "headnode"
                  compute_profile.0.roles.0.os_profile.#:                                                     "1" => "1"
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.#:                    "1" => "1"
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.password:           "" => "testPass123!"
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.ssh_key.#:          "0" => "1"
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.ssh_key.0.key_data: "" => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld"
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.username:           "username" => "username"
                  compute_profile.0.roles.0.target_instance_count:                                            "2" => "2"
                  compute_profile.0.roles.1.hardware_profile.#:                                               "1" => "1"
                  compute_profile.0.roles.1.hardware_profile.0.vm_size:                                       "Standard_D13_v2" => "Standard_D13_v2"
                  compute_profile.0.roles.1.min_instance_count:                                               "0" => "2"
                  compute_profile.0.roles.1.name:                                                             "workernode" => "workernode"
                  compute_profile.0.roles.1.os_profile.#:                                                     "1" => "1"
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.#:                    "1" => "1"
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.ssh_key.#:          "0" => "1"
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.ssh_key.0.key_data: "" => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld"
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.username:           "username" => "username"
                  compute_profile.0.roles.1.target_instance_count:                                            "3" => "3"
                  compute_profile.0.roles.2.hardware_profile.#:                                               "1" => "0"
                  compute_profile.0.roles.2.hardware_profile.0.vm_size:                                       "Medium" => ""
                  compute_profile.0.roles.2.min_instance_count:                                               "0" => "2"
                  compute_profile.0.roles.2.name:                                                             "zookeepernode" => ""
                  compute_profile.0.roles.2.os_profile.#:                                                     "1" => "0"
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.#:                    "1" => "0"
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.0.username:           "username" => ""
                  location:                                                                                   "West Europe" => "westeurope"
                  name:                                                                                       "acctesthdi6084705813821869721" => "acctesthdi6084705813821869721"
                  resource_group_name:                                                                        "acctestrg-6084705813821869721" => "acctestrg-6084705813821869721"
                  storage_profile.#:                                                                          "1" => "1"
                  storage_profile.0.storage_accounts.#:                                                       "1" => "1"
                  storage_profile.0.storage_accounts.0.container:                                             "acctestrg-6084705813821869721" => "acctestrg-6084705813821869721"
                  storage_profile.0.storage_accounts.0.is_default:                                            "true" => "true"
                  storage_profile.0.storage_accounts.0.key:                                                   "FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ==" => "FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ=="
                  storage_profile.0.storage_accounts.0.name:                                                  "https://acctestsaddbwp.blob.core.windows.net/" => "https://acctestsaddbwp.blob.core.windows.net/"
                  tags.%:                                                                                     "0" => "<computed>"
                  tier:                                                                                       "standard" => "Standard"

                STATE:

                azurerm_hdinsight_cluster.test:
                  ID = /subscriptions/995c6481-7ddc-4dac-afd4-33545d96cf29/resourceGroups/acctestrg-6084705813821869721/providers/Microsoft.HDInsight/clusters/acctesthdi6084705813821869721
                  cluster_definition.# = 1
                  cluster_definition.0.blueprint = https://blueprints.azurehdinsight.net/spark-3.6.1000.0.11683648.json
                  cluster_definition.0.component_version.% = 1
                  cluster_definition.0.component_version.spark = 2.1
                  cluster_definition.0.configurations.# = 0
                  cluster_definition.0.kind = spark
                  cluster_version = 3.6.1000.0
                  compute_profile.# = 1
                  compute_profile.0.roles.# = 3
                  compute_profile.0.roles.0.data_disks_group.# = 0
                  compute_profile.0.roles.0.hardware_profile.# = 1
                  compute_profile.0.roles.0.hardware_profile.0.vm_size = Standard_D12_v2
                  compute_profile.0.roles.0.min_instance_count = 0
                  compute_profile.0.roles.0.name = headnode
                  compute_profile.0.roles.0.os_profile.# = 1
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.# = 1
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.password =
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.ssh_key.# = 0
                  compute_profile.0.roles.0.os_profile.0.linux_operating_system_profile.0.username = username
                  compute_profile.0.roles.0.target_instance_count = 2
                  compute_profile.0.roles.0.virtual_network_profile.# = 0
                  compute_profile.0.roles.1.data_disks_group.# = 0
                  compute_profile.0.roles.1.hardware_profile.# = 1
                  compute_profile.0.roles.1.hardware_profile.0.vm_size = Standard_D13_v2
                  compute_profile.0.roles.1.min_instance_count = 0
                  compute_profile.0.roles.1.name = workernode
                  compute_profile.0.roles.1.os_profile.# = 1
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.# = 1
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.password =
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.ssh_key.# = 0
                  compute_profile.0.roles.1.os_profile.0.linux_operating_system_profile.0.username = username
                  compute_profile.0.roles.1.target_instance_count = 3
                  compute_profile.0.roles.1.virtual_network_profile.# = 0
                  compute_profile.0.roles.2.data_disks_group.# = 0
                  compute_profile.0.roles.2.hardware_profile.# = 1
                  compute_profile.0.roles.2.hardware_profile.0.vm_size = Medium
                  compute_profile.0.roles.2.min_instance_count = 0
                  compute_profile.0.roles.2.name = zookeepernode
                  compute_profile.0.roles.2.os_profile.# = 1
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.# = 1
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.0.password =
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.0.ssh_key.# = 0
                  compute_profile.0.roles.2.os_profile.0.linux_operating_system_profile.0.username = username
                  compute_profile.0.roles.2.target_instance_count = 3
                  compute_profile.0.roles.2.virtual_network_profile.# = 0
                  location = West Europe
                  name = acctesthdi6084705813821869721
                  resource_group_name = acctestrg-6084705813821869721
                  security_profile.# = 0
                  storage_profile.# = 1
                  storage_profile.0.storage_accounts.# = 1
                  storage_profile.0.storage_accounts.0.container = acctestrg-6084705813821869721
                  storage_profile.0.storage_accounts.0.is_default = true
                  storage_profile.0.storage_accounts.0.key = FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ==
                  storage_profile.0.storage_accounts.0.name = https://acctestsaddbwp.blob.core.windows.net/
                  tags.% = 0
                  tier = standard

                  Dependencies:
                    azurerm_resource_group.test
                    azurerm_storage_account.test
                azurerm_resource_group.test:
                  ID = /subscriptions/995c6481-7ddc-4dac-afd4-33545d96cf29/resourceGroups/acctestrg-6084705813821869721
                  location = westeurope
                  name = acctestrg-6084705813821869721
                  tags.% = 1
                  tags.Source = testAccAzureRMHDInsightCluster_basic
                azurerm_storage_account.test:
                  ID = /subscriptions/995c6481-7ddc-4dac-afd4-33545d96cf29/resourceGroups/acctestrg-6084705813821869721/providers/Microsoft.Storage/storageAccounts/acctestsaddbwp
                  access_tier =
                  account_encryption_source = Microsoft.Storage
                  account_kind = Storage
                  account_replication_type = GRS
                  account_tier = Standard
                  account_type = Standard_GRS
                  enable_blob_encryption = true
                  enable_file_encryption = true
                  enable_https_traffic_only = false
                  location = westeurope
                  name = acctestsaddbwp
                  primary_access_key = FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ==
                  primary_blob_connection_string = DefaultEndpointsProtocol=https;BlobEndpoint=https://acctestsaddbwp.blob.core.windows.net/;AccountName=acctestsaddbwp;AccountKey=FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ==
                  primary_blob_endpoint = https://acctestsaddbwp.blob.core.windows.net/
                  primary_connection_string = DefaultEndpointsProtocol=https;AccountName=acctestsaddbwp;AccountKey=FyCktEIM8KTnwx5wkgEALLxqe8dfovkedcvAahDSa3hZ9XMELrOB6p9/t4Uw818GXKpDHOYA//7jaa2Ihel4tQ==;EndpointSuffix=core.windows.net
                  primary_file_endpoint = https://acctestsaddbwp.file.core.windows.net/
                  primary_location = westeurope
                  primary_queue_endpoint = https://acctestsaddbwp.queue.core.windows.net/
                  primary_table_endpoint = https://acctestsaddbwp.table.core.windows.net/
                  resource_group_name = acctestrg-6084705813821869721
                  secondary_access_key = lOSbtHrZ3sEfE8rRYnpO2BIx7kKG0L83e6fuP1K9CzDxKQ05X5U9pnDaix7w38wJbdGdzTPUqVaRN3Id2EXibA==
                  secondary_connection_string = DefaultEndpointsProtocol=https;AccountName=acctestsaddbwp;AccountKey=lOSbtHrZ3sEfE8rRYnpO2BIx7kKG0L83e6fuP1K9CzDxKQ05X5U9pnDaix7w38wJbdGdzTPUqVaRN3Id2EXibA==;EndpointSuffix=core.windows.net
                  secondary_location = northeurope
                  tags.% = 0

                  Dependencies:
                    azurerm_resource_group.test
FAIL

Current DiffSuppressFunc functions are not adequate - need's further investigation.

@jjcollinge
Copy link
Contributor Author

@tombuildsstuff - any ideas how I can get around the DIFF issue posted above?

@tombuildsstuff
Copy link
Contributor

@jjcollinge apologies - I'd missed I'd not replied to this, I've put some time aside tomorrow to take a look.

@JunyiYi

This comment has been minimized.

@tombuildsstuff
Copy link
Contributor

hey @jjcollinge

Apologies for the delayed response here - I've spent some time looking into HDInsights over the past few days and have taken the learnings from this PR but taken a slightly different approach which has culminated in PR #1267. I hope you don't mind, but I'm going to close this one in favour of that one.

Thanks!

@tombuildsstuff tombuildsstuff modified the milestones: Future, Being Sorted Oct 25, 2018
@ghost
Copy link

ghost commented Mar 6, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
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.

4 participants