Repository navigation
[Container app] az containerapp up: Fix existing app being re-created when the existence check fails - #34310
Open
nabeleon94 wants to merge 1 commit into
Open
[Container app] az containerapp up: Fix existing app being re-created when the existence check fails#34310nabeleon94 wants to merge 1 commit into
az containerapp up: Fix existing app being re-created when the existence check fails#34310nabeleon94 wants to merge 1 commit into
Conversation
…ed when the existence check fails containerapp_up_logic() swallowed every exception from the GET that decides between update and create, so a throttled/transient/network failure made an existing app look missing and up sent a full create PUT, resetting identity, ingress, secrets and scale. Only fall through to create on ResourceNotFound; re-raise anything else. Fixes Azure#34193
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Thank you for your contribution nabeleon94! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change intended to prevent failed app-existence checks from overwriting an existing app’s configuration.
No open issues 🎉
What changed in this PR
Fixes #34193 by preventing az containerapp up from treating a failed existence check as a missing app, which could overwrite an existing app’s configuration.
Changes:
- Uses the existing error handler to allow creation after
ResourceNotFoundwhile propagating other lookup failures. - Adds unit tests covering existing apps, missing apps, throttling, and connection errors.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_up_logic_unit.py |
Adds regression tests for create/update selection and lookup-error propagation. |
src/azure-cli/azure/cli/command_modules/containerapp/custom.py |
Replaces silent exception handling with the existing not-found-aware handler. |
Review effort: Balanced
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation —⚠️ Review suggested
This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.
1 added suppression
src/azure-cli/azure/cli/command_modules/containerapp/custom.pyexcept Exception as e: # pylint: disable=broad-exceptRelated command
az containerapp upDescription
Fixes #34193
containerapp_up_logic()GETs the app to choose between update and create, but wrapped that GET in a bareexcept: pass. When the GET failed for any reason other than "not found" (throttling, a transient 5xx, a network or token error), an existing app was treated as missing.upthen sent a full create PUT built only from its own arguments, which reset the app's system-assigned identity, ingress, secrets and scale, as described in the issue.The GET now goes through the module's existing
handle_non_resource_not_found_exception()helper:ResourceNotFound(404 for a missing app): same as before, falls through to create.CLIInternalError('(code) message'), and non-ARM exceptions are re-raised, soupfails without overwriting the app.The first existence check in
_up_utils.py(get_container_app_if_exists) only chooses the "Updating/Creating" log line, so I left it unchanged.Note: the
containerappextension in azure-cli-extensions has the same bareexceptin its owncontainerapp_up_logic(azext_containerapp/custom.py).Testing Guide
New unit test
containerapp/tests/latest/test_containerapp_up_logic_unit.py(mocksContainerAppClient.show):ResourceNotFound→ createTooManyRequests→ raisesCLIInternalError, no createrequestsConnectionError→ re-raised, no createBefore the fix, the last two fail (create is called and nothing is raised):
2 failed, 2 passed. After the fix:4 passed.test_containerapp_utils.pyandtest_containerapp_validators.pystill pass, and flake8 (repo.flake8) is clean. pylint (repopylintrc) reports no new findings oncustom.py. Theupscenario tests are@live_onlyand weren't run.History Notes
[Container app]
az containerapp up: Fix existing app being re-created with default settings when the existence check fails for a reason other than not foundThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.