microsoft / coe-starter-kit

Other
721 stars 212 forks source link

[CoE Starter Kit - BUG] Environment Creation and CleanUp not accounting for provisionState:Deleted #1632

Closed binaryjam closed 2 years ago

binaryjam commented 2 years ago

Describe the issue

In the Flows to clean up environments, it fetches all the environments and then checks against those that are existing.

However it doesnt filter for those environments that are returned in the environments action but marked as deleted.

I have an environment that is deleted, it cannot be seen in the Admin Centre, but in this action it is returned, and its "provisionState" is set to "Deleted". But as its returned the flow thinks its really there and proceeds to fail as well, as not removing it. This causes a cascade of later problems for me when every other flow fails to gather data on it.

Also check the Correlating flow that creates environments, because, that too does not check this provisioningState and this environment also appears in the gathered environments, so that too needs to check.

This is an example flow run showing the properties of a deleted env. image

Expected Behavior

The Creation Flow should be checking for provisionState, deleted environments can appear in the result set, I cannot find the code in them to check this.

The Cleanup flow should be checking the provisionState also, it relies on the the environment being missing from the resultset in order to delete but environments can appear in the result set marked as deleted.

What solution are you experiencing the issue with?

Core

What solution version are you using?

3.13

What app or flow are you having the issue with?

Admin - Sync Template v3 / Cleanup Admin - Sync Template v3 (Check Deleted)

Steps To Reproduce

You would need an environment that returns in the Get Environments (powerPlatform admin action) a deleted environment with this status.

Anything else?

No response

Jenefer-Monroe commented 2 years ago

Can you please tell me what state this environment is in? Is it just in the process of being deleted? Meaning this will be clean next time you run it?

When an environment is deleted I do not see it returned from the call to Get Environments.

I am hesitant to make a change here without understanding the state of the environment due to the ramifications of it actually deleting all the objects from the inventory

binaryjam commented 2 years ago

This environment has been deleted for a few days now, it was a support environment. This fails daily so isnt going away right now. So I cant ignore it as a tempory bug that will eventually go away.

As an Admin I cannot see this in the Admin Panel in environments, or in recover environments.

Normally when an environment is deleted they are not in that list, I understand that this is what you may see most times. But for some reason in my tenant, I am getting this one environment back.

The thing is, that even though it is returned, it has a status of deleted. So while the COE might normally get these, they are possible and they are flagged as deleted.

In the Get Environments, as in picture above in that flow there are 74 environments. I downloaded the outputs and isolated that envs json. I have anonymised it by xxxxxx the guids.

Hope this helps.

{ "id": "/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments/xxxxxxx-xxxx-xxxx-a154-43cba82032f2", "type": "Microsoft.BusinessAppPlatform/scopes/environments", "location": "europe", "name": "xxxxxxx-xxxx-xxxx-a154-43cba82032f2", "properties": { "azureRegion": "northeurope", "displayName": "xxxxxxxxxxxx_245063492_20210924T141633", "createdTime": "2021-09-24T14:16:58.067Z", "createdBy": { "id": "SYSTEM", "displayName": "SYSTEM", "type": "NotSpecified" }, "lastModifiedTime": "2021-10-02T09:03:53.0688199Z", "provisioningState": "Deleted", "provisioningDetails": { "message": "Successfully deleted environment.", "operations": [{ "name": "DELETE/PROVIDERS/MICROSOFT.POWERAPPS/ENVIRONMENTS/", "httpStatus": "OK", "code": "Deleted" }, { "name": "DELETE/PROVIDERS/MICROSOFT.FLOW/ENVIRONMENTS/", "httpStatus": "NoContent", "code": "Deleted" }, { "name": "DELETE/POWERAI/PROVISIONING/SOFT", "httpStatus": "OK", "code": "Deleted" }, { "name": "DELETE/POWERQUERY/ENVIRONMENTS/SOFT", "httpStatus": "OK", "code": "Deleted" }, { "name": "DELETE/NEPTUNE/ENVIRONMENTS/", "httpStatus": "OK", "code": "Deleted" }, { "name": "DELETE/POWERVIRTUALAGENT/ENVIRONMENTS/", "httpStatus": "OK", "code": "Deleted" }, { "name": "DELETE/TALENT/API/ENVIRONMENTS/", "httpStatus": "NotFound", "code": "Deleted" }, { "name": "POST/CXP/API/ENVIRONMENTS/DELETERESOURCES", "httpStatus": "OK", "code": "Deleted" }], "operationId": "d3ab705d-edeb-4cba-936a-dbefccdc35c0" }, "creationType": "CommonDataService", "environmentSku": "Support", "isDefault": false, "clientUris": { "admin": "https://admin.powerplatform.microsoft.com/environments/environment/xxxxxxx-xxxx-xxxx-a154-43cba82032f2/hub", "maker": "https://make.powerapps.com/environments/xxxxxxx-xxxx-xxxx-a154-43cba82032f2/home" }, "runtimeEndpoints": { "microsoft.BusinessAppPlatform": "https://europe.api.bap.microsoft.com", "microsoft.CommonDataModel": "https://europe.api.cds.microsoft.com", "microsoft.PowerApps": "https://europe.api.powerapps.com", "microsoft.Flow": "https://europe.api.flow.microsoft.com", "microsoft.PowerAppsAdvisor": "https://europe.api.advisor.powerapps.com", "microsoft.PowerVirtualAgents": "https://powervamg.eu-il109.gateway.prod.island.powerapps.com", "microsoft.ApiManagement": "https://management.EUROPE.azure-apihub.net" }, "expirationTime": "2021-10-01T14:16:58.113Z", "maxAllowedExpirationTime": "2021-10-31T14:16:58.113Z", "databaseType": "CommonDataService", "linkedEnvironmentMetadata": { "resourceId": "xxxxxxxx-xxxx-4b2c-8fb6-6218f53b9539", "friendlyName": "xxxxxxxxxxxx_245063492_20210924T141633", "uniqueName": "unqe3xxxxxxxxxxxxxxxxxxxxxxxxxxx", "domainName": "orgxxxxxxxxxxxxxxxxxxx", "version": "9.2.21091.00138", "instanceUrl": "https://orgxxxxxxxxxxxxxxxxxxx.crm4.dynamics.com/", "instanceApiUrl": "https://orgxxxxxxxxxxxxxxxxxxx.api.crm4.dynamics.com", "baseLanguage": 1033, "instanceState": "Inactive", "createdTime": "2021-09-24T14:16:58.067Z", "backgroundOperationsState": "Disabled", "scaleGroup": "XXXXXXXXXXX", "platformSku": "Standard" }, "trialScenarioType": "None", "retentionPeriod": "P7D", "states": { "management": { "id": "Running" }, "runtime": { "runtimeReasonCode": "NotSpecified", "requestedBy": { "displayName": "SYSTEM", "type": "NotSpecified" }, "id": "Warning" } }, "ongoingOperation": { "id": "d3ab705d-edeb-4cba-936a-dbefccdc35c0", "links": { "self": { "path": "/providers/Microsoft.BusinessAppPlatform/lifecycleOperations/xxxxxxx-xxxx-xxxx-xxxx-dbefccdc35c0" }, "environment": { "path": "/providers/Microsoft.BusinessAppPlatform/environments/xxxxxxx-xxxx-xxxx-a154-43cba82032f2" } }, "type": { "id": "Delete" } }, "updateCadence": { "id": "NotSpecified" }, "retentionDetails": { "retentionPeriod": "P7D", "backupsAvailableFromDateTime": "2021-11-27T11:31:40.3213999Z" }, "cluster": { "Removed from JSON":"I removed this, to anonymise" }, "connectedGroups": [], "lifecycleOperationsEnforcement": { "allowedOperations": [{ "type": { "id": "Copy" } }, { "type": { "id": "Delete" } }, { "type": { "id": "Edit" } }, { "type": { "id": "EnterprisePolicyChange" } }, { "type": { "id": "Provision" } }, { "type": { "id": "Recover" } }, { "type": { "id": "Reset" } }, { "type": { "id": "Restore" } }, { "type": { "id": "UpdateProtectionStatus" } }], "disallowedOperations": [{ "type": { "id": "Unlock" }, "reason": { "message": "Unlock cannot be performed because there is no linked CDS instance or the CDS instance version is not supported." } }, { "type": { "id": "Backup" }, "reason": { "message": "Backup cannot be performed on environment of type Support." } }, { "type": { "id": "Convert" }, "reason": { "message": "Convert cannot be performed on environment of type Support." } }, { "type": { "id": "Promote" }, "reason": { "message": "Promote cannot be performed on environment of type Support." } }] } } }

Jenefer-Monroe commented 2 years ago

I see. This support environment of yours was in a weird state before it was delete too. In my testing, as with other customers

1) People with ppadmin role are able to see support environments in ppadmin UX 2) Once the support envts are deleted they are no longer returned via Get Environments.

Given that, the flow would behave as expected and mark up the support environment as deleted in the CoE inventory. And (if set to delete from inventory in the env var) also delete it from inventory.

Unfortunately this appears to be a caching issue and you will need to contact product support and have them clean this up fo you.

binaryjam commented 2 years ago

Hi Jenefer,

I will raise a ticker with Ms Support on this thanks. If that action should absolutely not return deleted items, then I understand that the kit shouldnt be changed.

I'll see what they say.