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

Upgrade CosmosDB SDK to 2019-08-01 from 2015-04-08 #6253

Closed
wants to merge 12 commits into from

Conversation

jackbatzner
Copy link
Contributor

@jackbatzner jackbatzner commented Mar 25, 2020

Upgrade CosmosDB SDK to 2019-08-01 from 2015-04-08 to address @tombuildsstuff comments in PR 6189 about upgrading the remaining resources.

Below is the basic acceptance test results for each resource that was modified:
--- PASS: TestAccAzureRMCosmosDBAccount_basic_global_boundedStaleness (1043.38s)
--- PASS: TestAccAzureRMCosmosDbCassandraKeyspace_basic (1301.73s)
--- PASS: TestAccAzureRMCosmosGremlinDatabase_basic (1254.89s)
--- PASS: TestAccAzureRMCosmosDbGremlinGraph_basic (1371.48s)
--- PASS: TestAccAzureRMCosmosDbMongoCollection_basic (1338.83s)
--- PASS: TestAccAzureRMCosmosDbMongoDatabase_basic (1285.84s)
--- PASS: TestAccAzureRMCosmosDbSqlContainer_basic (1382.01s)
--- PASS: TestAccAzureRMCosmosDbSqlDatabase_basic (1284.77s)
--- PASS: TestAccAzureRMCosmosDbTable_basic (1314.77s)

@@ -386,14 +388,18 @@ func resourceArmCosmosDbGremlinGraphRead(d *schema.ResourceData, meta interface{
d.Set("throughput", nil)
}
} else {
d.Set("throughput", throughputResp.Throughput)
if props := throughputResp.ThroughputSettingsGetProperties; props != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is used in almost every resource I am wondering if we should pull this out to a helper function? Thoughts would be appreciated

Copy link
Contributor

Choose a reason for hiding this comment

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

I could see the benefit of a helper here, returning a default value for this field 👍

@jackbatzner
Copy link
Contributor Author

jackbatzner commented Mar 25, 2020

I will move all of the functions from ./azurerm/helpers/azure/cosmos.go to the respective ./azurerm/internal/services/cosmos/parse/**.go folder, most of the tests above are failing.

@katbyte
Copy link
Collaborator

katbyte commented Mar 25, 2020

Looks like the parse functions need to be updated as the resource IDs have changed:

------ Stdout: -------
=== RUN   TestAccAzureRMCosmosDbCassandraKeyspace_complete
=== PAUSE TestAccAzureRMCosmosDbCassandraKeyspace_complete
=== CONT  TestAccAzureRMCosmosDbCassandraKeyspace_complete
--- FAIL: TestAccAzureRMCosmosDbCassandraKeyspace_complete (836.88s)
    testing.go:640: Step 0 error: errors during apply:
        
        Error: Error: Unable to parse Cosmos Keyspace Resource ID: keyspaces is missing from: /subscriptions/1a6092a6-137e-4025-9a7c-ef77f76f2c02/resourceGroups/acctestRG-cosmos-200325212702140546/providers/Microsoft.DocumentDB/databaseAccounts/acctest-ca-200325212702140546/cassandraKeyspaces/acctest-200325212702140546
 

i think we'll have to handle the IDs changing for existing resources 🤔

- Move parse functionality from /helpers/azure/cosmos.go to individual helper functions.
@jackbatzner
Copy link
Contributor Author

jackbatzner commented Mar 26, 2020

i think we'll have to handle the IDs changing for existing resources 🤔

I've added handling for the new and existing ID parsing so that we can still support parsing existing resources. Not sure if there is something else we should be changing in addition to this?

TestAccAzureRMCosmosDbCassandraKeyspace_basic test is passing with latest parse changes. I've kicked off the remainder basic tests locally as well. I am updating their status in the top level PR Comment

=== RUN TestAccAzureRMCosmosDbCassandraKeyspace_basic
=== PAUSE TestAccAzureRMCosmosDbCassandraKeyspace_basic
=== CONT TestAccAzureRMCosmosDbCassandraKeyspace_basic
--- PASS: TestAccAzureRMCosmosDbCassandraKeyspace_basic (1301.73s)
PASS
ok github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/tests 1301.964s

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 @Brunhil

Thanks for this splitting this out 😃

I've taken a look through and left some comments inline, but this is off to a good start; if we can add the state migrations to update the ID (which'll update the ID in the Statefile for existing users, meaning we can assume everyone's using the updated ID format going forward, as is shown in the documentation) then this should otherwise be good 👍

Thanks!

@jackbatzner
Copy link
Contributor Author

jackbatzner commented Mar 26, 2020

@tombuildsstuff , I've added the state migration changes, but I do believe something is wrong with them. The acceptance test for Cassandra is now failing after the latest changes. I can't seem to find where I've done something wrong, I'm hoping a second set of eyes will make it clear!

=== RUN   TestAccAzureRMCosmosDbCassandraKeyspace_complete
=== PAUSE TestAccAzureRMCosmosDbCassandraKeyspace_complete
=== CONT  TestAccAzureRMCosmosDbCassandraKeyspace_complete
--- FAIL: TestAccAzureRMCosmosDbCassandraKeyspace_complete (1152.96s)
    testing.go:640: Step 0 error: After applying this step, the plan was not empty:

        DIFF:

        DESTROY/CREATE: azurerm_cosmosdb_account.test
          capabilities.#:                               "1" => "1"
          capabilities.0.name:                          "EnableCassandra" => "EnableCassandra"
          connection_strings:                           "" => "<computed>"
          connection_strings.#:                         "8" => ""
          connection_strings.0:                         "AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;" => 
""
          connection_strings.1:                         "AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;" => 
""
          connection_strings.2:                         "AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;" => 
""
          connection_strings.3:                         "AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;" => 
""
          connection_strings.4:                         "HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350" => ""
          connection_strings.5:                         "HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350" => ""
          connection_strings.6:                         "HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350" => ""
          connection_strings.7:                         "HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350" => ""
          consistency_policy.#:                         "1" => "1"
          consistency_policy.0.consistency_level:       "Strong" => "Strong"
          consistency_policy.0.max_interval_in_seconds: "5" => "5"
          consistency_policy.0.max_staleness_prefix:    "100" => "100"
          enable_automatic_failover:                    "false" => "false"
          enable_multiple_write_locations:              "false" => "false"
          endpoint:                                     "https://acctest-ca-200326104554447378.documents.azure.com:443/" => "<computed>"
          geo_location.#:                               "1" => "1" (forces new resource)
          geo_location.0.failover_priority:             "0" => "0" (forces new resource)
          geo_location.0.id:                            "acctest-ca-200326104554447378-eastus" => "<computed>" (forces new resource)
          geo_location.0.location:                      "eastus" => "eastus" (forces new resource)
          geo_location.0.prefix:                        "acctest-ca-200326104554447378-eastus" => "" (forces new resource)
          id:                                           "/subscriptions/********/resourceGroups/acctestRG-cosmos-200326104554447378/providers/Microsoft.DocumentDB/databaseAccounts/acctest-ca-200326104554447378" => "<computed>"
          ip_range_filter:                              "" => ""
          is_virtual_network_filter_enabled:            "false" => "false"
          kind:                                         "GlobalDocumentDB" => "GlobalDocumentDB"
          location:                                     "eastus" => "eastus"
          name:                                         "acctest-ca-200326104554447378" => "acctest-ca-200326104554447378"
          offer_type:                                   "Standard" => "Standard"
          primary_master_key:                           "********" => "<computed>"
          primary_readonly_master_key:                  "********" => "<computed>"
          read_endpoints:                               "" => "<computed>"
          read_endpoints.#:                             "1" => ""
          read_endpoints.0:                             "https://acctest-ca-200326104554447378-eastus.documents.azure.com:443/" => ""
          resource_group_name:                          "acctestRG-cosmos-200326104554447378" => "acctestRG-cosmos-200326104554447378"
          secondary_master_key:                         "********" => "<computed>"
          secondary_readonly_master_key:                "********" => "<computed>"
          virtual_network_rule.#:                       "0" => "0"
          write_endpoints:                              "" => "<computed>"
          write_endpoints.#:                            "1" => ""
          write_endpoints.0:                            "https://acctest-ca-200326104554447378-eastus.documents.azure.com:443/" => ""



        STATE:

        azurerm_cosmosdb_account.test:
          ID = /subscriptions/********/resourceGroups/acctestRG-cosmos-200326104554447378/providers/Microsoft.DocumentDB/databaseAccounts/acctest-ca-200326104554447378
          provider = provider.azurerm
          capabilities.# = 1
          capabilities.0.name = EnableCassandra
          connection_strings.# = 8
          connection_strings.0 = AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;
          connection_strings.1 = AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;
          connection_strings.2 = AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;
          connection_strings.3 = AccountEndpoint=https://acctest-ca-200326104554447378.documents.azure.com:443/;AccountKey=********;
          connection_strings.4 = HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350
          connection_strings.5 = HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350
          connection_strings.6 = HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350
          connection_strings.7 = HostName=acctest-ca-200326104554447378.cassandra.cosmos.azure.com;Username=acctest-ca-200326104554447378;Password=********;Port=10350
          consistency_policy.# = 1
          consistency_policy.0.consistency_level = Strong
          consistency_policy.0.max_interval_in_seconds = 5
          consistency_policy.0.max_staleness_prefix = 100
          enable_automatic_failover = false
          enable_multiple_write_locations = false
          endpoint = https://acctest-ca-200326104554447378.documents.azure.com:443/
          geo_location.# = 1
          geo_location.0.failover_priority = 0
          geo_location.0.id = acctest-ca-200326104554447378-eastus
          geo_location.0.location = eastus
          geo_location.0.prefix = acctest-ca-200326104554447378-eastus
          ip_range_filter =
          is_virtual_network_filter_enabled = false
          kind = GlobalDocumentDB
          location = eastus
          name = acctest-ca-200326104554447378
          offer_type = Standard
          primary_master_key = ********
          primary_readonly_master_key = ********
          read_endpoints.# = 1
          read_endpoints.0 = https://acctest-ca-200326104554447378-eastus.documents.azure.com:443/
          resource_group_name = acctestRG-cosmos-200326104554447378
          secondary_master_key = ********
          secondary_readonly_master_key = ********
          write_endpoints.# = 1
          write_endpoints.0 = https://acctest-ca-200326104554447378-eastus.documents.azure.com:443/

          Dependencies:
            azurerm_resource_group.test
        azurerm_cosmosdb_cassandra_keyspace.test:
          ID = /subscriptions/********/resourceGroups/acctestRG-cosmos-200326104554447378/providers/Microsoft.DocumentDB/databaseAccounts/acctest-ca-200326104554447378/cassandraKeyspaces/acctest-200326104554447378
          provider = provider.azurerm
          account_name = acctest-ca-200326104554447378
          name = acctest-200326104554447378
          resource_group_name = acctestRG-cosmos-200326104554447378
          throughput = 700

          Dependencies:
            azurerm_cosmosdb_account.test
        azurerm_resource_group.test:
          ID = /subscriptions/********/resourceGroups/acctestRG-cosmos-200326104554447378
          provider = provider.azurerm
          location = eastus
          name = acctestRG-cosmos-200326104554447378
FAIL
FAIL    github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/tests        1166.916s
FAIL

@ghost ghost removed the waiting-response label Mar 26, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.4.0, v2.5.0, v2.6.0 Apr 2, 2020
@katbyte katbyte added this to the v2.9.0 milestone Apr 30, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.9.0, v2.10.0 May 7, 2020
@katbyte katbyte modified the milestones: v2.10.0, v2.11.0 May 14, 2020
@katbyte katbyte modified the milestones: v2.11.0, v2.12.0, v2.13.0 May 22, 2020
@antempus
Copy link

I'm going to look at it over the course of the day as it takes 20min to run a test

I've noticed issues with normal provision behavior, creating DB accounts can take > 10 mins in many cases; this may be the source of test lengths.

@katbyte
Copy link
Collaborator

katbyte commented Jul 9, 2020

hey @Brunhil - i'm going to close this in favour of #7597 which is both a new api version and actively being worked on

@katbyte katbyte closed this Jul 9, 2020
@ghost
Copy link

ghost commented Jul 10, 2020

This has been released in version 2.18.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.18.0"
}
# ... other configuration ...

katbyte pushed a commit that referenced this pull request Jul 20, 2020
Forked from #6253 and brings the Cosmos DB API up to 2020-04-01

Closes #6253
@ghost
Copy link

ghost commented Aug 9, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 9, 2020
@jackbatzner jackbatzner deleted the upgrade_cosmos_sdk branch March 2, 2021 02:27
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.

5 participants