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 fleet] Hubless-Hubful PUT and reconcile commands. #7213

Merged
merged 13 commits into from
Feb 2, 2024
6 changes: 5 additions & 1 deletion src/fleet/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ Release History

1.0.2
++++++
* Minor style & linting updates to codebase.
* Minor style & linting updates to codebase.

1.0.3
++++++
* Added `az fleet reconcile` & `az fleet member reconcile` commands.
16 changes: 16 additions & 0 deletions src/fleet/azext_fleet/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
text: az fleet get-credentials -g MyFleetResourceGroup -n MyFleetName -f ~/mykubeconfigfile.txt
"""

helps['fleet reconcile'] = """
type: command
short-summary: Reconciles a fleet.
examples:
- name: Reconcile a fleet.
text: az fleet reconcile -g MyFleetResourceGroup -n MyFleetName
"""

helps['fleet wait'] = """
type: command
short-summary: Wait for a fleet resource to reach a desired state.
Expand Down Expand Up @@ -148,6 +156,14 @@
text: az fleet member delete -g MyFleetResourceGroup -f MyFleetName -n NameOfMember
"""

helps['fleet member reconcile'] = """
type: command
short-summary: Reconciles a member.
examples:
- name: Reconcile a member.
text: az fleet member reconcile -g MyFleetResourceGroup -f MyFleetName -n NameOfMember
"""

helps['fleet member wait'] = """
type: command
short-summary: Wait for a member resource to reach a desired state.
Expand Down
2 changes: 2 additions & 0 deletions src/fleet/azext_fleet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def load_command_table(self, _):
g.custom_command("list", "list_fleet")
g.custom_command("delete", "delete_fleet", supports_no_wait=True, confirmation=True)
g.custom_command("get-credentials", "get_credentials")
g.custom_command("reconcile", "reconcile_fleet", supports_no_wait=True)
g.wait_command("wait")

# fleet members command group
Expand All @@ -51,6 +52,7 @@ def load_command_table(self, _):
g.custom_command("delete", "delete_fleet_member", supports_no_wait=True, confirmation=True)
g.custom_command("list", "list_fleet_member")
g.custom_show_command("show", "show_fleet_member")
g.custom_command("reconcile", "reconcile_fleet_member", supports_no_wait=True)
g.wait_command("wait")

# fleet update runs command group
Expand Down
37 changes: 37 additions & 0 deletions src/fleet/azext_fleet/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,26 @@ def get_credentials(cmd, # pylint: disable=unused-argument
raise CLIError("Fail to find kubeconfig file.") from exc


def reconcile_fleet(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
name,
no_wait=False):

poll_interval = 5
fleet = client.get(resource_group_name, name)
if fleet.hub_profile is not None:
poll_interval = 30

return sdk_no_wait(no_wait,
Ealianis marked this conversation as resolved.
Show resolved Hide resolved
client.begin_create_or_update,
resource_group_name,
name,
fleet,
if_match=fleet.e_tag,
polling_interval=poll_interval)


def create_fleet_member(cmd,
client,
resource_group_name,
Expand Down Expand Up @@ -268,6 +288,23 @@ def delete_fleet_member(cmd, # pylint: disable=unused-argument
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, fleet_name, name)


def reconcile_fleet_member(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
name,
fleet_name,
no_wait=False):

member = client.get(resource_group_name, fleet_name, name)
return sdk_no_wait(no_wait,
client.begin_create,
resource_group_name,
fleet_name,
name,
member,
if_match=member.e_tag)


def create_update_run(cmd,
client,
resource_group_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.ContainerService/managedClusters/flmc-000003''
Expand Down Expand Up @@ -784,7 +784,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -1291,7 +1291,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -1759,7 +1759,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -1852,7 +1852,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -1945,7 +1945,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -2038,7 +2038,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down Expand Up @@ -2131,7 +2131,7 @@ interactions:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.35)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-11-01
response:
body:
string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n
Expand Down
Loading