-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ContainerApp] Added support for Cloud Patching #7571
base: main
Are you sure you want to change the base?
Conversation
|
rule | cmd_name | rule_message | suggest_message |
---|---|---|---|
containerapp patch apply | cmd containerapp patch apply added parameter container_app_name |
||
containerapp patch apply | cmd containerapp patch apply added parameter patch_name |
||
containerapp patch configure | sub group containerapp patch configure added |
||
containerapp patch delete | cmd containerapp patch delete added |
||
containerapp patch list | cmd containerapp patch list added parameter container_app_name |
||
containerapp patch show | cmd containerapp patch show added |
Hi @harryli0108, |
ContainerApp |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take the necessary steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help to resolve
@@ -1483,7 +1484,25 @@ def set_workload_profile(cmd, resource_group_name, env_name, workload_profile_na | |||
return update_managed_environment(cmd, env_name, resource_group_name, workload_profile_type=workload_profile_type, workload_profile_name=workload_profile_name, min_nodes=min_nodes, max_nodes=max_nodes) | |||
|
|||
|
|||
def patch_list(cmd, resource_group_name=None, managed_env=None, show_all=False): | |||
def patch_list(cmd, resource_group_name=None, managed_env=None, container_app_name=None, show_all=False): | |||
from azure.cli.command_modules.containerapp._utils import format_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this import statement to the top of this file
@@ -1539,6 +1558,81 @@ def patch_list(cmd, resource_group_name=None, managed_env=None, show_all=False): | |||
return results | |||
|
|||
|
|||
def patch_show(cmd, resource_group_name=None, container_app_name=None, patch_name=None): | |||
from azure.cli.command_modules.containerapp._utils import format_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this import statement to the top and re-use across methods.
if format_location(app["location"]) != format_location("North Central US (Stage)"): | ||
logger.warning("Cloud patching is not supported in the location of the container app.") | ||
return | ||
from ._clients import PatchClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment - Move all imports to the top.
|
||
|
||
def patch_delete(cmd, resource_group_name=None, container_app_name=None, patch_name=None): | ||
from azure.cli.command_modules.containerapp._utils import format_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about moving this import statement to the top
from azure.cli.command_modules.containerapp._utils import format_location | ||
logger.warning("This command is currently only available for container app cloud patches in North Central US (Stage).") | ||
if patch_name is None: | ||
logger.error("Please provide the name of the patch to delete.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should throw a validation error instead of just logging as an error?
if format_location(app["location"]) != format_location("North Central US (Stage)"): | ||
logger.warning("Cloud patching is not supported in the location of the container app.") | ||
return | ||
from ._clients import PatchClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about import statement
if app is None: | ||
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) | ||
return | ||
if format_location(app["location"]) != format_location("North Central US (Stage)"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use safe_get instead of just app["location"]
|
||
|
||
def patch_mode_configure(cmd, resource_group_name=None, container_app_name=None, patch_mode=None): | ||
from azure.cli.command_modules.containerapp._utils import format_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move import
if patch_mode not in ["Automatic", "Manual", "Disabled"]: | ||
logger.error("Invalid patch mode provided. Please provide 'Automatic', 'Manual', or 'Disabled'.") | ||
return | ||
from ._clients import PatchClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move imort
@@ -1650,6 +1747,28 @@ def patch_apply(cmd, resource_group_name=None, managed_env=None, show_all=False) | |||
patch_apply_handle_input(cmd, patchable_check_results, "y", pack_exec_path) | |||
|
|||
|
|||
def use_cloud_patch(cmd, container_app_name, resource_group_name, patch_name): | |||
try: | |||
app = show_containerapp(cmd, container_app_name, resource_group_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this throw a not found exception if container app does not exist? Probably need to handle it separately? by check if not found exception is thrown in a separate method and return None
if it is
if app is None: | ||
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) | ||
return | ||
if app["location"] == "North Central US (Stage)": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use safe_get() here for getting the app's location and let's use STAGE_LOCATION
from the constants file instead of hardcoding it here.
patch_client = PatchClient() | ||
is_patch_success = patch_client.apply(cmd, resource_group_name, container_app_name, patch_name) | ||
if is_patch_success: | ||
print("Patch {0} for container app {1} is queued successfully to be applied.".format(patch_name, container_app_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.warning if we want this to show up on cx console?
if app["location"] == "North Central US (Stage)": | ||
logger.warning("Using cloud patching...") | ||
logger.warning("Cloud patching is only supported in North Central US (Stage) now.") | ||
from ._clients import PatchClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move import.
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) | ||
return | ||
if app["location"] == "North Central US (Stage)": | ||
logger.warning("Using cloud patching...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's combine this into a single line.
patch_client = PatchClient() | ||
is_patch_mode_configured = patch_client.patch_mode_configure(cmd, resource_group_name, container_app_name, patch_mode) | ||
if is_patch_mode_configured: | ||
print("Patch mode for container app {0} is set to {1}.".format(container_app_name, patch_mode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.warning if we want this to show up on the console.
logger.error("Failed to fetch container app {0} in resource group {1}. Error: {2}".format(container_app_name, resource_group_name, str(e))) | ||
return | ||
if app is None: | ||
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to Container App
patch_client = PatchClient() | ||
is_patch_deleted = patch_client.delete(cmd, resource_group_name, container_app_name, patch_name) | ||
if is_patch_deleted: | ||
print("Patch {0} for container app {1} is deleted successfully.".format(patch_name, container_app_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.warning instead of print
if app is None: | ||
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) | ||
return | ||
if format_location(app["location"]) != format_location("North Central US (Stage)"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use safe_get()
logger.error("Please provide the name of the patch to delete.") | ||
return | ||
try: | ||
app = show_containerapp(cmd, container_app_name, resource_group_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could throw a not found exception if container app does not exist.
if app is None: | ||
logger.error("Container app {0} not found in resource group {1}.".format(container_app_name, resource_group_name)) | ||
return | ||
if format_location(app["location"]) != format_location("North Central US (Stage)"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use safe_get() to get app's location
|
||
helps["containerapp patch configure mode"] = """ | ||
type: command | ||
short-summary: Configure the patching mode for a container app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container App
instead of container app
@@ -847,6 +871,20 @@ | |||
az containerapp patch interactive -g MyResourceGroup --environment MyContainerAppEnv --show-all | |||
""" | |||
|
|||
helps["containerapp patch configure"] = """ | |||
type: group | |||
short-summary: Commands to configure the patching settings for a container app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace container app by Container App
@@ -827,6 +830,27 @@ | |||
- name: List patchable and unpatchable container apps by managed environment with the show-all option and apply patch for patchable container apps. | |||
text: | | |||
az containerapp patch apply -g MyResourceGroup --environment MyContainerAppEnv --show-all | |||
- name: Apply a patch for a container app by patch name using Cloud Patching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container App
@@ -809,6 +809,9 @@ | |||
- name: List patchable and unpatchable container apps by managed environment with the show-all option. | |||
text: | | |||
az containerapp patch list -g MyResourceGroup --environment MyContainerAppEnv --show-all | |||
- name: List available patches for a container app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container App
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls do as well
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally? (pip install wheel==0.30.0
required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.json
automatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json
.