-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Container App]: Remove quota check for 'az containerapps env create' #5548
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
Merged
zhoxing-ms
merged 9 commits into
Azure:main
from
Zijian-Ju:fixed-containerapps-quota-check
Nov 22, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6f5a857
Update History.rst and setup.rst
Zijian-Ju 1365cbb
Remove quota check while creating ManagedEnvironments
Zijian-Ju cdc12a9
Remove MAX_ENV_PER_LOCATION in Constants.py
Zijian-Ju e8f5eb0
Update up_utils to adjust az containerapp up
Zijian-Ju f5437d5
Use user input parameter as first priority
Zijian-Ju a52bb50
Remove location null check while validating environments
Zijian-Ju 4841b91
Style fix
Zijian-Ju 80ac0ff
Update location return logic
Zijian-Ju 0eebe6e
Style fix
Zijian-Ju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1506,42 +1506,19 @@ def is_registry_msi_system(identity): | |
|
|
||
|
|
||
| def validate_environment_location(cmd, location): | ||
| from ._constants import MAX_ENV_PER_LOCATION | ||
| from .custom import list_managed_environments | ||
| env_list = list_managed_environments(cmd) | ||
|
|
||
| locations = [loc["location"] for loc in env_list] | ||
| locations = list(set(locations)) # remove duplicates | ||
|
|
||
| location_count = {} | ||
| for loc in locations: | ||
| location_count[loc] = len([e for e in env_list if e["location"] == loc]) # pylint: disable=used-before-assignment | ||
|
|
||
| disallowed_locations = [] | ||
| for _, value in enumerate(location_count): | ||
| if location_count[value] > MAX_ENV_PER_LOCATION - 1: | ||
| disallowed_locations.append(value) | ||
|
|
||
| res_locations = list_environment_locations(cmd) | ||
| res_locations = [loc for loc in res_locations if loc not in disallowed_locations] | ||
|
|
||
| allowed_locs = ", ".join(res_locations) | ||
|
|
||
| if location: | ||
| try: | ||
| _ensure_location_allowed(cmd, location, CONTAINER_APPS_RP, "managedEnvironments") | ||
|
|
||
| return location | ||
| except Exception as e: # pylint: disable=broad-except | ||
| raise ValidationError("You cannot create a Containerapp environment in location {}. List of eligible locations: {}.".format(location, allowed_locs)) from e | ||
|
|
||
| if len(res_locations) > 0: | ||
| if not location: | ||
| logger.warning("Creating environment on location %s.", res_locations[0]) | ||
| return res_locations[0] | ||
| if location in disallowed_locations: | ||
| raise ValidationError("You have more than {} environments in location {}. List of eligible locations: {}.".format(MAX_ENV_PER_LOCATION, location, allowed_locs)) | ||
|
Zijian-Ju marked this conversation as resolved.
Outdated
|
||
| return location | ||
| else: | ||
| raise ValidationError("You cannot create any more environments. Environments are limited to {} per location in a subscription. Please specify an existing environment using --environment.".format(MAX_ENV_PER_LOCATION)) | ||
| return res_locations[0] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add null check
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. res_location will not be empty after the change as we don't filter by remaining quota anymore |
||
|
|
||
|
|
||
| def list_environment_locations(cmd): | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.