Conversation
3 tasks
Collaborator
|
CI |
fengzhou-msft
approved these changes
Mar 26, 2021
Member
|
Can you submit an issue to https://github.com/azure/azure-iot-cli-extension for bumping the |
Member
Author
|
Sure. Created issue Azure/azure-iot-cli-extension#321. |
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.
Symptom
CI failure https://dev.azure.com/azure-sdk/public/_build/results?buildId=801336&view=logs&j=34631516-3f1c-501b-e428-6ea670d20b1c&t=4ecab084-061a-520a-6791-4f5413067b6d&l=1816
Root cause
This can also be reproed locally. (You may need to rename
~/cliextensions/azure-iottoaazure-iotto make it appear earlier thanarcappliance, becauseos.listdir's result is not sorted.)Same error problem can be reproed with only
azure-iot.❌ This doesn't work:
✔ This works:
This is because the change on
sys.pathdoesn't take effect ifpkg_resourcesis already imported.CLI imports
pkg_resourcesfirst:azure-cli/src/azure-cli-core/azure/cli/core/__init__.py
Line 625 in 0df58e9
Then it changes
sys.path:azure-cli/src/azure-cli-core/azure/cli/core/__init__.py
Line 337 in 0df58e9
As for why this issue doesn't happen when installed separately:
azure-iot,azure-iot/jsonschema/__init__.pyis not loaded at all (but the 🐛 is there). Whenazure-iotreally usesjsonschema,azure-iot/azext_iot/common/utility.py:415has its workaround to updatepkg_resources.working_set:arcappliance, it loadsarcappliance/jsonschema/__init__.py, which uses the newimportlib.metadataand works fineazure-iotandarcapplianceare loaded tosys.path. Ifazure-iotis loaded first,arcapplianceloadsjsonschemafromazure-iot/jsonschema/__init__.py, thus bypassing the workaround and hit the 🐛ℹ The above conclusion is derived by adding
to
pkg_resources/__init__.pyazure-iot/jsonschema/__init__.pyarcappliance/jsonschema/__init__.pyThen run
az self-testto observe the result.It is possible for CLI to load all extensions together - when command index has not been built yet.
Proposed solution
Fix the
azure-iotextension by using the latestjsonschemawhich usesimportlib.metadata(python-jsonschema/jsonschema@6a7155a, python-jsonschema/jsonschema@fe772c3)Mitigation
This PR restores
az self-testand blocksazure-iotuntiljsonschemais bumped to the latest version.