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

Chaos Studio Context Deadline Exceeded #27452

Open
1 task done
theangrytech-git opened this issue Sep 20, 2024 · 1 comment
Open
1 task done

Chaos Studio Context Deadline Exceeded #27452

theangrytech-git opened this issue Sep 20, 2024 · 1 comment
Labels

Comments

@theangrytech-git
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.9.5

AzureRM Provider Version

4.0.1

Affected Resource(s)/Data Source(s)

azurerm_chaos_studio_capability, azurerm_chaos_studio_target

Terraform Configuration Files

/*******************************************************************************
********************************************************************************
                          CHAOS STUDIO SECTION
/*******************************************************************************
*******************************************************************************/

/*******************************************************************************
                      REGISTER AZURE CHAOS PROVIDER
*******************************************************************************/

resource "null_resource" "register_chaos_provider" {
  provisioner "local-exec" {
    command = "az provider register --namespace Microsoft.Chaos"
  }

  # Ensure this runs only once by using a trigger
    triggers = {
    always_run = "${timestamp()}"
  }
}

/********************************************************************************
                            CREATE SERVICE PRINCIPAL
********************************************************************************/
resource "azuread_application" "cs_app" {
  display_name = "chaos-studio-sp"
}

resource "azuread_service_principal" "cs_sp" {
  client_id = azuread_application.cs_app.client_id
  use_existing = true
}

resource "azuread_service_principal_password" "cs_sp_pw" {
  service_principal_id = azuread_service_principal.cs_sp.id
  end_date             = local.expiration_date
}

output "client_id" {
  value = azuread_service_principal.cs_sp.client_id
}
output "client_secret" {
  value = azuread_service_principal_password.cs_sp_pw.value
  sensitive = true
}

/********************************************************************************
                           SERVICE PRINCIPAL ROLES
********************************************************************************/
resource "azurerm_role_assignment" "chaos_contributor_sp" {
  principal_id   = azuread_service_principal.cs_sp.id
  role_definition_name = "Chaos Contributor"
  scope = azurerm_resource_group.uks.id
  #scope          = data.azurerm_subscription.primary.id
}

# resource "azurerm_role_assignment" "vm_reader" {
#   principal_id   = azuread_service_principal.example.id
#   role_definition_name = "Reader"
#   scope          = azurerm_windows_virtual_machine.uks-vmsa[0].id  # Replace with your VM's ID
# }



/********************************************************************************
                 ADD AGENT-BASED TARGETS TO CHAOS STUDIO
********************************************************************************/
resource "azurerm_chaos_studio_target" "tgt-uks_vmsa" {
  count               = var.servercounta
  location            = azurerm_resource_group.uks.location
  target_resource_id  = azurerm_windows_virtual_machine.uks-vmsa[count.index].id
  target_type         = "Microsoft-Agent"
}

# resource "azurerm_chaos_studio_target" "tgt-uks_vmsa_1" {
#   location            = azurerm_resource_group.uks.location
#   target_resource_id  = azurerm_windows_virtual_machine.uks-vmsa[1].id
#   target_type         = "Microsoft-Agent"
# }

# resource "azurerm_chaos_studio_target" "tgt-uks_vmsa_2" {
#   location            = azurerm_resource_group.uks.location
#   target_resource_id  = azurerm_windows_virtual_machine.uks-vmsa[2].id
#   target_type         = "Microsoft-Agent"
# }

/********************************************************************************
                 ADD SERVICE-BASED TARGETS TO CHAOS STUDIO
********************************************************************************/
resource "azurerm_chaos_studio_target" "tgt-key_vault_target" {
  location            = azurerm_resource_group.uks.location
  target_resource_id  = azurerm_key_vault.kv1.id
  target_type         = "Microsoft-Service"
}

resource "azurerm_chaos_studio_target" "tgt-app_service_target" {
  location            = azurerm_resource_group.uks.location
  target_resource_id  = azurerm_service_plan.uks-asp.id
  target_type         = "Microsoft-Service"
}

/********************************************************************************
                     ADD CHAOS STUDIO CAPABILITIES
********************************************************************************/

resource "azurerm_chaos_studio_capability" "cap_net_disconnect" {
  count                  = var.servercounta
  capability_type        = "NetworkDisconnect-1.1"
  chaos_studio_target_id = azurerm_chaos_studio_target.tgt-uks_vmsa[count.index].id
}

resource "azurerm_chaos_studio_capability" "cap_cpupressure" {
  count                  = var.servercounta
  capability_type        = "CPUPressure-1.0"
  chaos_studio_target_id = azurerm_chaos_studio_target.tgt-uks_vmsa[count.index].id
}

Debug Output/Panic Output

Error: retrieving list of chaos target types: loading results: Get "": context deadline exceeded

with azurerm_chaos_studio_target.tgt-uks_vmsa[0],
on main.tf line 1453, in resource "azurerm_chaos_studio_target" "tgt-uks_vmsa":
1453: resource "azurerm_chaos_studio_target" "tgt-uks_vmsa" {

retrieving list of chaos target types: loading results: Get "": context deadline exceeded

Error: retrieving list of chaos target types: loading results: Get "": context deadline exceeded

with azurerm_chaos_studio_target.tgt-key_vault_target,
on main.tf line 1475, in resource "azurerm_chaos_studio_target" "tgt-key_vault_target":
1475: resource "azurerm_chaos_studio_target" "tgt-key_vault_target" {

retrieving list of chaos target types: loading results: Get "": context deadline exceeded

Error: retrieving list of chaos target types: loading results: Get "": context deadline exceeded

with azurerm_chaos_studio_target.tgt-app_service_target,
on main.tf line 1481, in resource "azurerm_chaos_studio_target" "tgt-app_service_target":
1481: resource "azurerm_chaos_studio_target" "tgt-app_service_target" {

retrieving list of chaos target types: loading results: Get "": context deadline exceeded

Expected Behaviour

The Chaos Studio target and capability azurerm resources should be created, as the Microsoft.Chaos resource provider is registered in the target subscription.

Actual Behaviour

Terraform apply timeouts after 30 minutes, citing the context deadline has exceeded. This occurs regardless how long you set the deadline for, and the target and capability azurerm resources are not created.

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

@github-actions github-actions bot added the v/4.x label Sep 20, 2024
@neil-yechenwei
Copy link
Contributor

Thanks for raising this issue. Seems the List API to retrieve target types would time out. The issue Azure/azure-rest-api-specs#30673 is filed for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants