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

{App Service} Fixing the supported api-version for get_kube_client() function #6157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

navba-MSFT
Copy link
Contributor

@navba-MSFT navba-MSFT commented Apr 3, 2023

Fixes #6155

We get the below error while running CLI command: az appservice kube show

Enviornment:
Windows-10-10.0.20348-SP0
Python 3.10.10
Installer: MSI

azure-cli 2.47.0

Extensions:
appservice-kube 0.1.7

Error:

  File "C:\Users\Administrator\.azure\cliextensions\appservice-kube\azext_appservice_kube\custom.py", line 305, in show_kube_environments
    client = _get_kube_client(cmd)
  File "C:\Users\Administrator\.azure\cliextensions\appservice-kube\azext_appservice_kube\custom.py", line 301, in _get_kube_client
    return client.kube_environments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/web/_web_site_management_client.py", line 627, in kube_environments
ModuleNotFoundError: No module named 'azure.mgmt.web.v2021_01_01'

This error is because API version 2021-01-01 is trimmed from azure-mgmt-web SDK by scripts/trim_sdk.py to reduce MSI package size ( Azure/azure-cli#23946 )

but appservice-kube extension hardcodes 2021-01-01:

client = web_client_factory(cmd.cli_ctx, api_version="2021-01-01")

appservice-kube extension can use the latest API version api_version="2022-03-01" defined at:

https://github.com/Azure/azure-cli/blob/8c45b0feeaaa9a8ca3ed53c5cead1a8435b04fa6/src/azure-cli-core/azure/cli/core/profiles/_shared.py#L243


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

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.

We get the below error while running CLI command: `az appservice kube show`
```
Enviornment:
Windows-10-10.0.20348-SP0
Python 3.10.10
Installer: MSI

azure-cli 2.47.0

Extensions:
appservice-kube 0.1.7
```

**Error:**
```
  File "C:\Users\Administrator\.azure\cliextensions\appservice-kube\azext_appservice_kube\custom.py", line 305, in show_kube_environments
    client = _get_kube_client(cmd)
  File "C:\Users\Administrator\.azure\cliextensions\appservice-kube\azext_appservice_kube\custom.py", line 301, in _get_kube_client
    return client.kube_environments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/web/_web_site_management_client.py", line 627, in kube_environments
ModuleNotFoundError: No module named 'azure.mgmt.web.v2021_01_01'
```
This error is because API version 2021-01-01 is trimmed from azure-mgmt-web SDK by scripts/trim_sdk.py to reduce MSI package size (#23946)

but appservice-kube extension hardcodes 2021-01-01:

https://github.com/Azure/azure-cli-extensions/blob/f4033ee2830c68668f340e12c39d76b6d2b7ee3f/src/appservice-kube/azext_appservice_kube/custom.py#L300

appservice-kube extension can use the latest API version api_version="2022-03-01" defined at:

https://github.com/Azure/azure-cli/blob/8c45b0feeaaa9a8ca3ed53c5cead1a8435b04fa6/src/azure-cli-core/azure/cli/core/profiles/_shared.py#L243
@azure-client-tools-bot-prd
Copy link

Hi @navba-MSFT,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@ghost ghost requested a review from yonzhan April 3, 2023 05:58
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 3, 2023

AzureAppService

@ghost ghost requested a review from zhoxing-ms April 3, 2023 05:59
@ghost ghost added the Auto-Assign Auto assign by bot label Apr 3, 2023
@ghost ghost requested a review from wangzelin007 April 3, 2023 05:59
@ghost ghost assigned zhoxing-ms Apr 3, 2023
@ghost ghost added the App Services label Apr 3, 2023
@ghost ghost requested review from kairu-ms, jsntcy, jiasli and evelyn-ys April 3, 2023 05:59
@navba-MSFT
Copy link
Contributor Author

@StrawnSC Could you please review this once you get a chance ? Thanks in advance.

@zhoxing-ms zhoxing-ms changed the title {AzureAppService} Fixing the supported api-version for get_kube_client() function {App Service} Fixing the supported api-version for get_kube_client() function Apr 11, 2023
client = web_client_factory(cmd.cli_ctx, api_version="2021-01-01")
client = web_client_factory(cmd.cli_ctx, api_version="2022-03-01")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-record the tests affected by the upgraded api-version

@yonzhan yonzhan requested a review from yanzhudd April 11, 2023 07:34
@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Apr 18, 2023

ERROR cli.azure.cli.core.azclierror:azlogging.py:212 Can't overwrite existing cassette ('/mnt/vss/_work/1/s/src/appservice-kube/azext_appservice_kube/tests/latest/recordings/test_win_webapp_quick_create_runtime_kube.yaml') in your current record mode ('once').
No match for the request (<Request (GET) https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest000001?api-version=2022-09-01>) was found.
Found 2 similar requests with 1 different matcher(s) :

1 - (<Request (GET) https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest000001?api-version=2021-04-01>)..)
Matchers succeeded : ['method', 'scheme', 'host', 'port', 'path']
Matchers failed :
_custom_request_query_matcher - assertion failure :
None

The CI issues are caused by the bumping api-version of Resource RP from 2021-04-01 to 2022-09-01 in azure-cli-core (PR link), so you need to pull the latest code from the remote dev branch of Azure/azure-cli repo and then re-record these failed tests in live mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

az appservice kube show error
4 participants