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

Evenhub Disaster Recovery Config with alternate name cannot be deleted #5893

Closed
katbyte opened this issue Sep 26, 2019 · 20 comments
Closed

Evenhub Disaster Recovery Config with alternate name cannot be deleted #5893

katbyte opened this issue Sep 26, 2019 · 20 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@katbyte
Copy link

katbyte commented Sep 26, 2019

Bug Report

  • import path of package in question, e.g. .../services/compute/mgmt/2018-06-01/compute
    "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub"
  • SDK version e.g. master, latest, 18.1.0
    • Specify the exact commit if possible; one way to get this is the REVISION
      column output by dep status "github.com/Azure/azure-sdk-for-go.
github.com/Azure/azure-sdk-for-go v33.2.0+incompatible
github.com/hashicorp/go-azure-helpers v0.7.0
  • output of go version
    go version go1.12.6 darwin/amd64
  • What happened?
    Once an alternate name has been assigned to an eventhub DRC it doesn't seem possible to delete it via the SDK:
    Error: errors during apply: Error issuing delete request for EventHub Namespace Disaster Recovery Configs "acctest-EHN-190925153556128780-a" (Namespace "acctest-EHN-190925153556128780-a" / Resource Group "acctestRG-190925153556128780"): eventhub.DisasterRecoveryConfigsClient#Delete: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Cannot delete as Alias and Primary Namespace are same. CorrelationId: 7ec915de-1460-8a33-edc2-0e4e16faa34b"

And removing the alternative name doesn't seem to be possible:
Error: Error creating/updating EventHub Namespace Disaster Recovery Configs "acctest-EHN-190925181808103471-a" (Namespace "acctest-EHN-190925181808103471-a" / Resource Group "acctestRG-190925181808103471"): eventhub.DisasterRecoveryConfigsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="LinkedInvalidPropertyId" Message="Property id '' at path 'properties.partnerNamespace' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."

  • What did you expect or want to happen?
    the DRC to be deleted

  • How can we reproduce it?
    assign a alternative name to a DRC and attempt to delete it (after breaking the pair)

  • Anything we should know about your environment.

@loarabia loarabia added customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs Mgmt This issue is related to a management-plane library. labels Sep 26, 2019
@ArcturusZhang ArcturusZhang added the Service Attention Workflow: This issue is responsible by Azure service team. label Oct 14, 2019
@ArcturusZhang
Copy link
Member

ArcturusZhang commented Oct 14, 2019

This seems to be a problem with the service side, I tagged this issue with Service Attention to notify the service team about this.

@jfggdl
Copy link

jfggdl commented Oct 14, 2019

@katbyte, we are looking at this issue and we will share our findings/request for more information.

@jfggdl
Copy link

jfggdl commented Nov 6, 2019

@katbyte,

Would you be able to provide the code snippet you are using? Please do not share anything sensitive. Are you setting up an alias with the primary and secondary pointing to the same namespace?

@AliMohsen
Copy link

@katbyte This is actually by design. If you set your alias to be the same as your primary namespace name, the alias/DRC cannot be deleted. This is because the DNS entry is cleaned up as part of the delete and this will make the namespace inaccessible if a delete was done in this particular case.

What was the reason for setting the alias name to be the same as the primary namespace?

@katbyte
Copy link
Author

katbyte commented Nov 6, 2019

@jfggdl, The terraform config that trigger it is:

resource "azurerm_resource_group" "test" {
  name     = "acctestRG-%[1]d"
  location = "%[2]s"
}

resource "azurerm_eventhub_namespace" "testa" {
  name                = "acctest-EHN-%[1]d-a"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  sku                 = "Standard"
}

resource "azurerm_eventhub_namespace" "testb" {
  name                = "acctest-EHN-%[1]d-b"
  location            = "%[3]s"
  resource_group_name = "${azurerm_resource_group.test.name}"
  sku                 = "Standard"
}

resource "azurerm_eventhub_namespace_disaster_recovery_config" "test" {
  name                 = "${azurerm_eventhub_namespace.testa.name}"
  resource_group_name  = "${azurerm_resource_group.test.name}"
  namespace_name       = "${azurerm_eventhub_namespace.testa.name}"
  partner_namespace_id = "${azurerm_eventhub_namespace.testb.id}"
  alternate_name       = "acctest-EHN-DRC-%[1]d-alt"
}

So it is two separate namespaces. And there seems to be no way to "unset" an alternate name

@AliMohsen
Copy link

@katbyte Based on your config, it looks like you are setting the DR config name to the primary namespace name. Which is why you are unable to delete it, as explained in my previous comment.

If you don't actually need your alias connection string to be the same as your primary connection string, you should set the DR config name (AKA alias) to something other than the primary namespace name. In this case, you will be able to delete the DR config.

@katbyte
Copy link
Author

katbyte commented Nov 7, 2019

@AliMohsen,

I'm not sure i follow. If i set the name to something other than the primary namespace's name i'm not allowed to set an alternate name. And if i set an alternate name i can no longer delete the namespace...

=== RUN   TestAccAzureRMEventHubNamespaceDisasterRecoveryConfig_complete
=== PAUSE TestAccAzureRMEventHubNamespaceDisasterRecoveryConfig_complete
=== CONT  TestAccAzureRMEventHubNamespaceDisasterRecoveryConfig_complete
--- FAIL: TestAccAzureRMEventHubNamespaceDisasterRecoveryConfig_complete (160.90s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error creating/updating EventHub Namespace Disaster Recovery Configs "acctest-EHN-191107062939488559-a-alias" (Namespace "acctest-EHN-191107062939488559-a" / Resource Group "acctestRG-191107062939488559"): eventhub.DisasterRecoveryConfigsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Alternate name is supported only if alias and primary namespace are same. CorrelationId: 44aeeaf3-8e55-7586-3fd2-45511fbb1ac1"

and if i try to change the name to something else:

    testing.go:569: Step 1 error: errors during apply:

        Error: Error issuing delete request for EventHub Namespace Disaster Recovery Configs "acctest-EHN-191107070438461451-a" (Namespace "acctest-EHN-191107070438461451-a" / Resource Group "acctestRG-191107070438461451"): eventhub.DisasterRecoveryConfigsClient#Delete: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Cannot delete as Alias and Primary Namespace are same. CorrelationId: 336d3056-fa42-0c6e-89a4-0a3c72d8f647"


    testing.go:630: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during apply: Error issuing break pairing request for EventHub Namespace Disaster Recovery Configs "acctest-EHN-191107070438461451-a" (Namespace "acctest-EHN-191107070438461451-a" / Resource Group "acctestRG-191107070438461451"): eventhub.DisasterRecoveryConfigsClient#BreakPairing: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="BreakPairing operation is only allowed on primary namespace with valid secondary namespace. CorrelationId: 336d3056-fa42-0c6e-89a4-0a3c72d8f647"

Maybe i am doing things in the wrong order or missing something?

@AliMohsen
Copy link

AliMohsen commented Nov 7, 2019

@katbyte That's correct, the alternate name is only supported when the alias and primary namespace are the same. Do not set the alternate name if you want to be able to delete your DR config (along with setting a different alias than the primary namespace name).

The alternate name is basically there to allow you to make requests to your formerly primary namespace post-failover in the case where the alias and primary namespace name were the same. It would not be required if your alias is different than your primary namespace name.

@katbyte
Copy link
Author

katbyte commented Nov 7, 2019

@AliMohsen,

But that is the problem, how does one delete an EH DRC once you've set an alternate name? I don't understand why that workflow can't be made possible?

@AliMohsen
Copy link

AliMohsen commented Nov 8, 2019

@katbyte Unfortunately it's just not something that's currently possible, for the reasons I mentioned in my first comment. Once you've set up a DR config where the alias (config name) is the same as the primary name, it cannot be deleted.

Can I ask what you're trying to achieve? Why do you want to delete the DR config in this particular case?

@katbyte
Copy link
Author

katbyte commented Nov 8, 2019

@AliMohsen, that seems like a bug.. if i understand correctly once you provision this resource and then add an alternate name then there is no way to remove the alternate name or delete it? - what is the reason the alternate name cannot be removed?

We are personally testing it so users of our tool (terraform) can provision, update, and delete resources.

@ShubhaVijayasarathy
Copy link

@katbyte , you can delete the alias if it is not associated with any secondary. Make sure that no dependencies exist and deleting the primary namespace will delete the alias as well

@katbyte
Copy link
Author

katbyte commented Nov 9, 2019

@ShubhaVijayasarathy, could youj elaborate on the steps to delete a DRC with an alternate name then?

Lets say i have created one and added a alternate name, what are the next steps to delete the DRC?

@jfggdl jfggdl added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Dec 12, 2019
@AliMohsen
Copy link

AliMohsen commented Dec 19, 2019

Hi @katbyte ,

What Shubha is saying is that you can delete the namespace itself, and as a result, the DR Config for that namespace will also be deleted.

You will not be able to delete the DR Config alone, if you have set the DR Config name (alias) to be the same as the primary namespace name. The only way is to delete the namespace itself.

@katbyte
Copy link
Author

katbyte commented Dec 23, 2019

@AliMohsen,

I'm not setting the alias to the same name as the primary? Actually i'm not sure what the alias is because the API doesn't have any property called alias - just alternate name. we set that to something different: acctest-EHN-DRC-12345-alt and the primary namespace is acctest-EHN-12345-a. If i don't set the alternate name to anything it deletes just fine.

For clarification what API property sets the alias? because afaik i'm not setting it to the same thing.

@AliMohsen
Copy link

AliMohsen commented Dec 23, 2019

Hi @katbyte

Sorry for the confusion. When you create a disaster recovery config through the SDK, you pass in an alias parameter. See here: https://godoc.org/github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus#DisasterRecoveryConfigsClient.CreateOrUpdate

This basically just maps to the DR Config name, this is the name parameter you've referenced here:

resource "azurerm_eventhub_namespace_disaster_recovery_config" "test" {
  name                 = "${azurerm_eventhub_namespace.testa.name}"
  resource_group_name  = "${azurerm_resource_group.test.name}"
  namespace_name       = "${azurerm_eventhub_namespace.testa.name}"
  partner_namespace_id = "${azurerm_eventhub_namespace.testb.id}"
  alternate_name       = "acctest-EHN-DRC-%[1]d-alt"
}

Here you have this set as the primary namespace name referenced by "testa".

@katbyte
Copy link
Author

katbyte commented Dec 26, 2019

@AliMohsen,

Sorry that is my mistake, i am not entirely familiar with the terms of this API. So it appears i have to set the alias to the same name as the primary because otherwise i cannot set an alternate name. You get the error Alternate name is supported only if alias and primary namespace are same.. So this comes back to my original problem & question: how does one delete a DRC when the alternate name has been set? It doesn't seem possible.

@AliMohsen
Copy link

@katbyte

You can go back to my original answer for the answer to that question :). The alternate name is only there as a workaround for cases where the alias and primary namespace name are the same. If you do set the primary namespace and alias to be the same, then it is impossible to delete the DRC and this is by design. The reason for this is in my reply here.

The only way the DRC can be deleted in this case, is if you deleted the primary namespace itself.

If you were to set up your DRC the recommended way, which is to use a different alias name than the primary namespace name and not set the alternate name. You can delete the DRC.

@katbyte
Copy link
Author

katbyte commented Dec 28, 2019

@AliMohsen,

And this is what I see as a bug in the API :) I would expect to be able to delete the DRC without having to delete the primary namespace, IE remove this resource without having to remove an entirely separate one. Not be able able to remove a DRC sounds like a bug to me. As it appears the code to detect this condition exists, should the API not just conditionally remove the DNS entry? if they are the same preserve the DNS entry, and if different delete. This would allow users to remove the DRC from a namespace rather then forcing them to delete it.

@samuelkoppes
Copy link

As mentioned in the commentary, this issue is by design. Thank you for bringing this issue to our attention, and in the future we will consider altering our internal design to decouple deletion of the DRC from the lifecycle of the primary namespace in this scenario. Unfortunately we cannot commit to a timeline at present due to resource constraints.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

8 participants