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

az cli commands should be idempotent #26770

Closed
adehaan-darwin-eu opened this issue Jun 28, 2023 · 3 comments
Closed

az cli commands should be idempotent #26770

adehaan-darwin-eu opened this issue Jun 28, 2023 · 3 comments
Assignees
Labels
Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. PostgreSQL Service Attention This issue is responsible by Azure service team.

Comments

@adehaan-darwin-eu
Copy link

Related command

az postgres flexible-server create
https://learn.microsoft.com/en-us/cli/azure/postgres/flexible-server?view=azure-cli-latest#az-postgres-flexible-server-create

Is your feature request related to a problem? Please describe.

When issuing the above command in a deployment pipeline, the pipeline exits with error code 1:

WARNING: Checking the existence of the resource group '##obfuscated##'...
WARNING: Resource group '##obfuscated##' exists ? : True
ERROR: Specified server name is already used.
##[error]Script failed with exit code: 1

Describe the solution you'd like

This command should be able to be executed even if the resource already exists. just raise a warning.

Describe alternatives you've considered

Additional context

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot CXP Attention This issue is handled by CXP team. PostgreSQL labels Jun 28, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Jun 28, 2023

Thank you for opening this issue, we will look into it.

@PramodValavala-MSFT PramodValavala-MSFT added Service Attention This issue is responsible by Azure service team. and removed CXP Attention This issue is handled by CXP team. labels Sep 28, 2023
@nachoalonsoportillo nachoalonsoportillo self-assigned this Jul 11, 2024
@nachoalonsoportillo
Copy link
Contributor

@adehaan-darwin-eu After having evaluated carefully the pros and cons of leaving the current behavior as-is or changing it in the way you're requesting, we have decided to leave it as it is now.

The main reason for having taken that decision is that such change would be considered a breaking change, and it would indeed break all existing automation that relies on a logic like the following:

1. tries to create the resource
2. if fails,, do something

because the failure logic would no longer execute.

For more context on the discussion around creation commands, please refer to this link: #7613

@adehaan-darwin-eu
Copy link
Author

Hello @nachoalonsoportillo,

Thank you for your response. Unforntunately I can't agree on your conclusion, even after reading: #7613
as there is also as post that states my point of view:

@tjprescott
tjprescott
on Mar 7, 2019
CLI commands are intended to be idempotent (though some fall short of this standard) and thus failing a create because a resource already exists by default is not something we would entertain if for no other reason that it would be a massively breaking change.

However, we are open to the idea of exposing an opt-in existence check like --fail-if-exists that create commands can opt into, and we can even consider allowing users to configure this as TRUE by default through az configure.

Also your logic is not something that can be followed. Idempotency would not disable the failure checking. Please se the ARM template deployment way of dealing with this.

Another issue is that the az cli commands are not consistent in this context. Therefor if every product group would adhere to the principle of idempotency, we as the end users can predict the execution of the commands.
Idempotency is for instance not something as the az nsg create, because that first deletes an existing one and then creates one, but is like the az group create, this can be executed numerous times and will leave everything intact if it already exists, even with resources in it, and creates if it doesn't exist.

So herewith the request to revisit this for all the az cli commands and communicate the policy with all the product groups and do a code check on compliancy before release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. PostgreSQL Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants