Azure / bicep-registry-modules

Bicep registry modules
MIT License
466 stars 316 forks source link

[AVM Module Issue]: Issue when provisioning VNET integrated Container Apps Environment. #3261

Open rpetersson opened 4 days ago

rpetersson commented 4 days ago

Check for previous/existing GitHub issues

Issue Type?

Bug

Module Name

avm/res/app/managed-environment

(Optional) Module Version

No response

Description

There is a bug caused by using the preview API (Microsoft.App/managedEnvironments@2024-02-02-preview) in container apps managed environment AVM module that throws the below error when configured with VNET integration.

The issue is not present using the newer: Microsoft.App/managedEnvironments@2024-03-01 version of the API.

Line |
  34 | New-AzSubscriptionDeploymentStack @inputObject -Force
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 07:44:40 - The deployment 'rsg-shared-24091207a1s2i' failed with
     | error(s). Showing 1 out of 1 error(s). Status Message: At least one
     | resource deployment operation failed. Please list deployment operations
     | for details. Please see https://aka.ms/arm-deployment-operations for
     | usage details. (Code: DeploymentFailed)  - The resource write operation
     | failed to complete successfully, because it reached terminal
     | provisioning state 'Failed'. (Code: ResourceDeploymentFailure)    -
     | ConfigureAllocatedClusterHandler failed for Managed Environment
     | xxxx on cluster happyflower-6a7fbbd5 :
     | k8s.Autorest.HttpOperationException: Operation returned an invalid
     | status code 'Conflict', response body
     | {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"secrets \"kube-environment--secret\" already exists","reason":"AlreadyExists","details":{"name":"kube-environment--secret","kind":"secrets"},"code":409}     at k8s.Kubernetes.SendRequestRaw(String requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)    at k8s.AbstractKubernetes.ICoreV1Operations_CreateNamespacedSecretWithHttpMessagesAsync[T](V1Secret body, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)    at k8s.AbstractKubernetes.k8s.ICoreV1Operations.CreateNamespacedSecretWithHttpMessagesAsync(V1Secret body, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)    at Microsoft.ContainerApps.Common.Services.ManagedClusterService.CreateSecretInClusterAsync(ManagedCluster dbManagedCluster, V1Secret secret, String k8sNameSpace, Boolean recreateOnConflict) in C:\__w\1\s\src\Microsoft.ContainerApps\Microsoft.ContainerApps.Common\Services\ManagedCluster\ManagedClusterService.cs:line 1109    at Microsoft.ContainerApps.Common.Services.ManagedClusterService.CreateSecretInClusterAsync(ManagedCluster dbManagedCluster, V1Secret secret, String k8sNameSpace, Boolean recreateOnConflict) in C:\__w\1\s\src\Microsoft.ContainerApps\Microsoft.ContainerApps.Common\Services\ManagedCluster\ManagedClusterService.cs:line 1127    at Microsoft.ContainerApps.BackgroundJobs.OperationHandlers.ManagedClusters.ConfigureAllocatedClusterHandler.ConfigureCustomSecretAsync(ManagedCluster managedCluster) in C:\__w\1\s\src\Microsoft.ContainerApps\Microsoft.ContainerApps.BackgroundJobs\OperationHandlers\ManagedClusters\ConfigureAllocatedClusterHandler.cs:line 749    at Microsoft.ContainerApps.BackgroundJobs.OperationHandlers.ManagedClusters.ConfigureAllocatedClusterHandler.HandleWaitingOperationForIsolatedManagedClusterAsync(ManagedCluster dbManagedCluster, KubeEnvironment dbManagedEnvironment, KubeOperation operation) in C:\__w\1\s\src\Microsoft.ContainerApps\Microsoft.ContainerApps.BackgroundJobs\OperationHandlers\ManagedClusters\ConfigureAllocatedClusterHandler.cs:line 182 (Code:OperationFailed)    CorrelationId: 2f9bf6aa-813c-48d0-be97-fab0d3944e03

(Optional) Correlation Id

No response

microsoft-github-policy-service[bot] commented 4 days ago

[!IMPORTANT] The "Needs: Triage :mag:" label must be removed once the triage process is complete!

[!TIP] For additional guidance on how to triage this issue/PR, see the BRM Issue Triage documentation.

avm-team-linter[bot] commented 4 days ago

@rpetersson, thanks for submitting this issue for the avm/res/app/managed-environment module!

[!IMPORTANT] A member of the @Azure/avm-res-app-managedenvironment-module-owners-bicep or @Azure/avm-res-app-managedenvironment-module-contributors-bicep team will review it soon!

hundredacres commented 4 days ago

@rpetersson can I see some sample code?