Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.53k stars 4.97k forks source link

Delete returns successful even if the resource does not exist #20331

Open Nishant-Kumar07 opened 1 year ago

Nishant-Kumar07 commented 1 year ago

Hello,

I have been noticing a pattern for most of the azure resources I have played around with, The "Delete" operation does not return an error when the resource does not exist, what is the rationale behind this design and if this is a bug? Here is an example below:

nishantkumar@SUPERNO-KTK3FNI ~ % az container list -g nishkumar-rg
[]
nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container
Are you sure you want to perform this operation? (y/n): y
nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container --debug

cli.knack.cli: Command arguments: ['container', 'delete', '-g', 'nishkumar-rg', '-n', 'random-container', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10165e7a0>, <function OutputProducer.on_global_arguments at 0x1016b11b0>, <function CLIQuery.on_global_arguments at 0x1016d65f0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'container': ['azure.cli.command_modules.container']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: container                 0.002         1        11
cli.azure.cli.core: Total (1)                 0.002         1        11
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0  
cli.azure.cli.core: Loaded 1 groups, 11 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : container delete
cli.azure.cli.core: Command table: container delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x1020c5510>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/nishantkumar/.azure/commands/2022-08-23.11-54-30.container_delete.11653.log'.
az_command_data_logger: command args: container delete -g {} -n {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x10216a7a0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x1021baef0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x1021bb010>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1016b1240>, <function CLIQuery.handle_query_parameter at 0x1016d6680>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x1021baf80>]
Are you sure you want to perform this operation? (y/n): y
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ContainerInstanceManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/nishantkumar/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/nishantkumar/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 3351bb97-9e06-4af7-8277-59450f7eb737
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'DELETE'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': '3f47148e-22ac-11ed-9051-5a4e36a63f79'
cli.azure.cli.core.sdk.policies:     'CommandName': 'container delete'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '-g -n --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.38.0 (HOMEBREW) azsdk-python-mgmt-containerinstance/9.1.0 Python/3.10.5 (macOS-12.5-arm64-arm-64bit)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "DELETE /subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01 HTTP/1.1" 204 0
cli.azure.cli.core.sdk.policies: Response status: 204
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-deletes': '14998'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'JIOINDIACENTRAL:20220823T062434Z:5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Date': 'Tue, 23 Aug 2022 06:24:34 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: 
cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x10219b5b0>, <function _x509_from_base64_to_hex_transform at 0x10219b640>]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x1020c5750>]
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 3.665 seconds (init: 0.079, invoke: 3.587)
telemetry.save: Save telemetry record of length 3048 in cache
telemetry.check: Negative: The /Users/nishantkumar/.azure/telemetry.txt was modified at 2022-08-23 11:51:06.957833, which in less than 600.000000 `
ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @macolso.

Issue Details
Hello, I have been noticing a pattern for most of the azure resources I have played around with, The "Delete" operation does not return an error when the resource does not exist, what is the rationale behind this design and if this is a bug? Here is an example below: ``` nishantkumar@SUPERNO-KTK3FNI ~ % az container list -g nishkumar-rg [] nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container Are you sure you want to perform this operation? (y/n): y nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container --debug cli.knack.cli: Command arguments: ['container', 'delete', '-g', 'nishkumar-rg', '-n', 'random-container', '--debug'] cli.knack.cli: __init__ debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'container': ['azure.cli.command_modules.container'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: container 0.002 1 11 cli.azure.cli.core: Total (1) 0.002 1 11 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: Loaded 1 groups, 11 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : container delete cli.azure.cli.core: Command table: container delete cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/nishantkumar/.azure/commands/2022-08-23.11-54-30.container_delete.11653.log'. az_command_data_logger: command args: container delete -g {} -n {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x10216a7a0>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x1021baef0>, .add_cache_arguments at 0x1021bb010>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x1021baf80>] Are you sure you want to perform this operation? (y/n): y cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ContainerInstanceManagementClient cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/nishantkumar/.azure/msal_token_cache.json', encrypt=False cli.azure.cli.core.auth.binary_cache: load: /Users/nishantkumar/.azure/msal_http_cache.bin urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None) msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'} cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={} cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={} msal.application: Cache hit an AT msal.telemetry: Generate or reuse correlation_id: 3351bb97-9e06-4af7-8277-59450f7eb737 cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01' cli.azure.cli.core.sdk.policies: Request method: 'DELETE' cli.azure.cli.core.sdk.policies: Request headers: cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '3f47148e-22ac-11ed-9051-5a4e36a63f79' cli.azure.cli.core.sdk.policies: 'CommandName': 'container delete' cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g -n --debug' cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.38.0 (HOMEBREW) azsdk-python-mgmt-containerinstance/9.1.0 Python/3.10.5 (macOS-12.5-arm64-arm-64bit)' cli.azure.cli.core.sdk.policies: 'Authorization': '*****' cli.azure.cli.core.sdk.policies: Request body: cli.azure.cli.core.sdk.policies: This request has no body urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443 urllib3.connectionpool: https://management.azure.com:443 "DELETE /subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01 HTTP/1.1" 204 0 cli.azure.cli.core.sdk.policies: Response status: 204 cli.azure.cli.core.sdk.policies: Response headers: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache' cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache' cli.azure.cli.core.sdk.policies: 'Expires': '-1' cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-deletes': '14998' cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902' cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902' cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'JIOINDIACENTRAL:20220823T062434Z:5e197c1e-d4d9-4df3-86b2-508641b52902' cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff' cli.azure.cli.core.sdk.policies: 'Date': 'Tue, 23 Aug 2022 06:24:34 GMT' cli.azure.cli.core.sdk.policies: Response content: cli.azure.cli.core.sdk.policies: cli.knack.cli: Event: CommandInvoker.OnTransformResult [, ] cli.knack.cli: Event: CommandInvoker.OnFilterResult [] cli.knack.cli: Event: Cli.SuccessfulExecute [] cli.knack.cli: Event: Cli.PostExecute [] az_command_data_logger: exit code: 0 cli.__main__: Command ran in 3.665 seconds (init: 0.079, invoke: 3.587) telemetry.save: Save telemetry record of length 3048 in cache telemetry.check: Negative: The /Users/nishantkumar/.azure/telemetry.txt was modified at 2022-08-23 11:51:06.957833, which in less than 600.000000 ` ```
Author: Nishant-Kumar07
Assignees: -
Labels: `Container Instances`, `Service Attention`, `needs-triage`
Milestone: -
Nishant-Kumar07 commented 1 year ago

I think this is as per the RFC here - https://www.rfc-editor.org/rfc/rfc7231#section-4.3.5 .