Introducing workload orchestration init command - #10151
Introducing workload orchestration init command#10151manaswita-chichili wants to merge 9 commits into
Conversation
|
Hi @manaswita-chichili, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Adds a new top-level az workload-orchestration init command that orchestrates cluster preparation plus Context creation, and enhances target creation to auto-resolve context_id when not provided.
Changes:
- Introduce hand-authored AAZ command
workload-orchestration initto run cluster init and then create a Context, persisting the current context in CLI config. - Update target create flow to resolve
context_idfrom CLI config and, if missing, query Azure Resource Graph and cache the discovered context. - Export the new init command module from the AAZ package
__init__.py.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py | Adds fallback resolution of context_id via CLI config → Azure Resource Graph and caches resolved context info. |
| src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/_init.py | New workload-orchestration init command to initialize cluster + create Context, with config persistence. |
| src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/init.py | Exposes the new init command module for registration/import. |
Comments suppressed due to low confidence (3)
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/_init.py:334
- _set_current_context currently checks for provider segment "Private.Edge", but Context IDs are in the form "/.../providers/Microsoft.Edge/contexts/..." (see context set/use). This causes the function to return early and never persist the context. It also only writes context_id, which leaves
az workload-orchestration context currentreturning "No current context is set" because it expects context_name and resource_group too.
parts = context_id.split("/")
if len(parts) != 9 or parts[6] != "Private.Edge" or parts[7] != "contexts":
return
config = self.ctx.cli_ctx.config
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/_init.py:305
- _create_context claims the already-exists path “fetches and returns” the existing Context, but the current implementation returns None. This makes the command non-idempotent (no context output) and also skips setting the current context when the resource already exists.
if caught is not None:
message = str(caught)
if "contextalreadyexists" in message.lower():
# Already exists → surface as a warning (non-fatal).
yellow, reset = "\033[33m", "\033[0m"
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py:235
- send_raw_request is being called with the request body as the 4th positional argument. In this extension the body is consistently passed as the
body=keyword (and POSTs include Content-Type). Passing it positionally risks being interpreted as headers/other params and breaking the Resource Graph call.
resp = send_raw_request(
self.ctx.cli_ctx, "POST", url, body=json.dumps(body)
)
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
🤖 PR Validation —⚠️ Review suggested
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 azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)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.jsonautomatically.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.